ranger: Drop zshcd in favor of the more universal SHELL_CD

master
Pierre Neidhardt 2016-10-13 15:18:48 +05:30
parent 0172237c82
commit bc94633efa
2 changed files with 4 additions and 49 deletions

View File

@ -166,9 +166,10 @@ map J move down=5
## New tab in current folder. Use 'gn' for home folder.
map <c-n> eval fm.tab_new('%d')
## Start shell in current folder. Needs zshcd script. This is useful if you have
## multiple tabs and you do not want to lose them just to run a shell.
map S shell zshcd %d
## Start shell in current folder. The shell must be configured to read the
## SHELL_CD variable. This is useful if you have multiple tabs and you do not
## want to lose them just to run a shell.
map S shell SHELL_CD=%d bash
## Image preview toggle
map zi set preview_images=True

View File

@ -1,46 +0,0 @@
#!/bin/sh
## Start zsh in the directory specified as first argument. Useful for file
## browsers to start shell in pointed folder.
if [ ! -d "$1" ]; then
zsh
exit
fi
## Default files.
ZDIRS="$HOME/.cache/zsh/dirs"
## Fetch file location dynamically.
if [ ! -f ~/.zshrc ]; then
echo '~/.zshrc not found'
exit 1
fi
## We need realpath to prevent us from adding duplicates to the zsh
## DIRSTACKFILE.
if ! command -v realpath >/dev/null 2>&1; then
echo "'realpath' not found"
exit 1
fi
SHELL_DIR_GREP="$(grep "SHELL_DIR=" ~/.zshrc | cut -f2 -d=)"
[ -n "$SHELL_DIR_GREP" ] && SHELL_DIR="$(eval echo "$SHELL_DIR_GREP")"
if [ ! -d "$SHELL_DIR" ]; then
echo 'SHELL_DIR not found'
exit 1
fi
ZDIRS_GREP="$(grep -rm1 'DIRSTACKFILE=' "$SHELL_DIR" | cut -f2 -d=)"
[ -n "$ZDIRS_GREP" ] && ZDIRS="$(eval echo "$ZDIRS_GREP")"
if [ ! -f "$ZDIRS" ]; then
echo 'DIRSTACKFILE not found'
exit 1
fi
## Prepend argument to zsh dirstack.
BUF="$(realpath "$1")
$(grep -v "$(realpath "$1")" "$ZDIRS")"
echo "$BUF" > "$ZDIRS"
zsh