zsh: add safeguards to auto directory save/load
This commit is contained in:
parent
f7ba268e24
commit
cf7a24ab92
1 changed files with 6 additions and 4 deletions
10
.zshrc
10
.zshrc
|
@ -668,10 +668,12 @@ load_working_dir() {
|
|||
if test -d "$(cat "$WORKING_DIR_SAVE_FILE")"; then
|
||||
cd "$PREVIOUS_WORKING_DIR" || error $LINENO
|
||||
else
|
||||
echo "Invalid saved working directory ($PREVIOUS_WORKING_DIR)"
|
||||
echo "Invalid saved working directory ($PREVIOUS_WORKING_DIR)" > /dev/null
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "Invalid working directory save file ($WORKING_DIR_SAVE_FILE)"
|
||||
echo "Invalid working directory save file ($WORKING_DIR_SAVE_FILE)" > /dev/null
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -682,8 +684,8 @@ save_working_dir() {
|
|||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd save_working_dir
|
||||
|
||||
load_working_dir
|
||||
cd - > /dev/null
|
||||
load_working_dir &&
|
||||
cd - > /dev/null
|
||||
# <<<
|
||||
# <<<
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue