diff --git a/fasd.zsh b/fasd.zsh new file mode 100644 index 0000000..ad9b529 --- /dev/null +++ b/fasd.zsh @@ -0,0 +1,25 @@ +# @author Sebastian Tramp +# @license http://opensource.org/licenses/gpl-license.php +# +# fasd integration +# https://github.com/clvv/fasd +# + +# init fasd, the autojump successor +#eval "$(fasd --init auto)" +eval "$(fasd --init zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)" + +# fasd_cd + outputs directory +fasd_cd() { + if [ $# -le 1 ]; then + fasd "$@" + else + local _fasd_ret="$(fasd -e 'printf %s' "$@")" + [ -z "$_fasd_ret" ] && return + [ -d "$_fasd_ret" ] && print "$_fasd_ret" && cd "$_fasd_ret" || printf %s\n "$_fasd_ret" + fi +} + +# as an autojump user, i need only this for now +alias j=' fasd_cd -d' + diff --git a/zshrc b/zshrc index e23d69c..7905deb 100644 --- a/zshrc +++ b/zshrc @@ -32,9 +32,14 @@ sources+="$ZSH_CONFIG/private.zsh" # completion config needs to be after system and private config sources+="$ZSH_CONFIG/completion.zsh" +# fasd integration and config +sources+="$ZSH_CONFIG/fasd.zsh" + # Private aliases and adoptions added at the very end (e.g. to start byuobu) sources+="$ZSH_CONFIG/private.final.zsh" + + # try to include all sources foreach file (`echo $sources`) if [[ -a $file ]]; then