Script: prepend + zshcd let ranger start a shell in current dir
parent
01bef24497
commit
f73902496e
|
@ -150,4 +150,7 @@ map K move up=5
|
||||||
map J move down=5
|
map J move down=5
|
||||||
|
|
||||||
## New tab in current folder. Use 'gn' for home folder.
|
## New tab in current folder. Use 'gn' for home folder.
|
||||||
map <c-n> eval fm.tab_new('%d')
|
map <c-n> eval fm.tab_new('%d')
|
||||||
|
|
||||||
|
## Start shell in current folder. Needs zshcd script.
|
||||||
|
map S shell zshcd %d
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Usage: ${0##*/} STRING FILES
|
||||||
|
|
||||||
|
Prepend STRING to FILES. STRING may not contain pipes ('|').
|
||||||
|
EOF
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
VAR="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
sed -ni '1{s|^|'$VAR'\n|;h};1!H;${x;p}' "$@"
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
## Start zsh in directory specified as first argument.
|
||||||
|
|
||||||
|
## Default files.
|
||||||
|
ZDIRS="$HOME/.cache/zsh/dirs"
|
||||||
|
SHELL_DIR="$HOME/.shell.d"
|
||||||
|
|
||||||
|
## Fetch file location dynamically.
|
||||||
|
if [ ! -f "$ZDIRS" ]; then
|
||||||
|
if [ ! -f ~/.zshrc ]; then
|
||||||
|
echo '~/.zshrc not found. Exiting.'
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
SHELL_DIR_GREP="$(grep "SHELL_DIR=" ~/.zshrc | cut -f2 -d=)"
|
||||||
|
[ -n "$SHELL_DIR_GREP" ] && SHELL_DIR="$(eval echo "$SHELL_DIR_GREP")"
|
||||||
|
ZDIRS_GREP="$(grep -rm1 'DIRSTACKFILE=' "$SHELL_DIR" | cut -f2 -d=)"
|
||||||
|
[ -n "$ZDIRS_GREP" ] && ZDIRS="$(eval echo "$ZDIRS_GREP")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$ZDIRS" ]; then
|
||||||
|
echo 'DIRSTACKFILE not found. Exiting.'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
zsh
|
||||||
|
else
|
||||||
|
if [ -n "$(grep "$1" "$ZCACHE")" ]; then
|
||||||
|
BUF="$(grep -v "$1" "$ZCACHE")"
|
||||||
|
echo "$BUF"
|
||||||
|
echo "$BUF" > "$ZCACHE"
|
||||||
|
fi
|
||||||
|
prepend "$1" "$ZCACHE"
|
||||||
|
zsh
|
||||||
|
fi
|
|
@ -1,13 +1,16 @@
|
||||||
## -*- mode:sh -*- #
|
## -*- mode:sh -*- #
|
||||||
################################################################################
|
################################################################################
|
||||||
## Zsh specific options
|
## Zsh specific options
|
||||||
## Date 2011-11-19
|
## Date 2013-07-26
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
ZCACHE=~/.cache/zsh/
|
||||||
|
[ ! -e "$ZCACHE" ] && mkdir -p "$ZCACHE"
|
||||||
|
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
## History options
|
## History options
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
HISTFILE=~/.zshistfile
|
HISTFILE="$ZCACHE/history"
|
||||||
HISTSIZE=1000
|
HISTSIZE=1000
|
||||||
SAVEHIST=1000
|
SAVEHIST=1000
|
||||||
setopt hist_ignore_all_dups
|
setopt hist_ignore_all_dups
|
||||||
|
@ -35,14 +38,16 @@ unsetopt flowcontrol
|
||||||
## VCS
|
## VCS
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
## TODO: to be continued...
|
## TODO: to be continued...
|
||||||
# autoload -Uz vcs_info zstyle ':vcs_info:*' enable git hg svn
|
# autoload -Uz vcs_info zstyle ':vcs_info:*' enable git hg
|
||||||
# autoload -Uz vcs_info
|
# autoload -Uz vcs_info
|
||||||
|
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
## Directory stack
|
## Directory stack
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
|
|
||||||
DIRSTACKFILE=~/.zdirs
|
## We use expanded path for DIRSTACKFILE since we need to locate it for the
|
||||||
|
## zshcd script.
|
||||||
|
DIRSTACKFILE="$HOME/.cache/zsh/dirs"
|
||||||
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
|
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
|
||||||
dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
|
dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
|
||||||
[[ -d $dirstack[1] ]] && cd $dirstack[1]
|
[[ -d $dirstack[1] ]] && cd $dirstack[1]
|
||||||
|
@ -62,7 +67,7 @@ setopt pushdminus
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
## ???
|
## ???
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
zstyle :compinstall filename "$HOME/.zshrc"
|
# zstyle :compinstall filename "$HOME/.zshrc"
|
||||||
|
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
## Completion
|
## Completion
|
||||||
|
@ -72,7 +77,8 @@ zstyle :compinstall filename "$HOME/.zshrc"
|
||||||
fpath=(~/.shell.d/completion $fpath)
|
fpath=(~/.shell.d/completion $fpath)
|
||||||
|
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
compinit
|
# compinit
|
||||||
|
compinit -d "$ZCACHE/compdump"
|
||||||
|
|
||||||
zstyle ':completion:*' menu select
|
zstyle ':completion:*' menu select
|
||||||
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
|
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
|
||||||
|
|
Loading…
Reference in New Issue