Last active
August 29, 2015 14:02
-
-
Save riccardosven/b14eaf568a240f9d0486 to your computer and use it in GitHub Desktop.
Oh-my-zsh plugin that saves the dirstack between sessions and keeps the pwd consistent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIRSTACKSIZE=9 | |
DIRSTACKFILE=~/.zdirs | |
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then | |
dirstack=( ${(f)"$(< $DIRSTACKFILE)"} ) | |
[[ -d $dirstack[1] ]] && cd $dirstack[1] | |
fi | |
function chpwd() { | |
print -l $PWD ${(u)dirstack}> $DIRSTACKFILE | |
} | |
jump() { | |
blue=$(tput setaf 4) | |
green=$(tput setaf 2) | |
normal=$(tput sgr0) | |
i=1 | |
for dir in $dirstack | |
do | |
printf "%40s\n" "[${blue}$i${normal}] ${green}$dir${normal}" | |
let i+=1 | |
done | |
printf "jump to directory: " | |
read dir | |
cd $dirstack[$dir] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment