Skip to content

Instantly share code, notes, and snippets.

@syohex
Created June 24, 2012 14:39
Show Gist options
  • Save syohex/2983495 to your computer and use it in GitHub Desktop.
Save syohex/2983495 to your computer and use it in GitHub Desktop.
zaw plugin for moving directory in git repository
#
# zaw-src-gitdir
#
# zaw source for git command
#
function zaw-src-gitdir () {
_dir=$(git rev-parse --show-cdup 2>/dev/null)
if [ $? -eq 0 ]
then
candidates=( $(git ls-files ${_dir} | perl -MFile::Basename -nle \
'$a{dirname $_}++; END{delete $a{"."}; print for sort keys %a}') )
fi
actions=("zaw-src-gitdir-cd")
act_descriptions=("change directory in git repos")
}
function zaw-src-gitdir-cd () {
BUFFER="cd $1"
zle accept-line
}
zaw-register-src -n gitdir zaw-src-gitdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment