fixing bug in zsh prompt from moving functions around

This commit is contained in:
Andrew Davidson 2020-03-09 09:54:07 -04:00
parent 06861bdd16
commit 329be70bad
Signed by: amd
GPG key ID: 17AF8F2A49CF25C6
2 changed files with 25 additions and 24 deletions

View file

@ -1,27 +1,3 @@
# Truncate working directory
function truncated_pwd() {
n=$1
path=`collapse_pwd`
dirs=("${(s:/:)path}")
dirs_length=$#dirs
if [[ $dirs_length -ge $n ]]; then
((max=dirs_length - n))
for (( i = 1; i <= $max; i++ )); do
step="$dirs[$i]"
if [[ -z $step ]]; then
continue
fi
if [[ $stem =~ "^\." ]]; then
dirs[$i]=$step[0,2]
else
dirs[$i]=$step[0,1]
fi
done
fi
echo ${(j:/:)dirs}
}
# Show what requires a reboot if one is required
reboot_for() {

View file

@ -29,6 +29,31 @@ function git_unstaged {
fi
}
# Truncate working directory
function truncated_pwd() {
n=$1
path=`current_pwd`
dirs=("${(s:/:)path}")
dirs_length=$#dirs
if [[ $dirs_length -ge $n ]]; then
((max=dirs_length - n))
for (( i = 1; i <= $max; i++ )); do
step="$dirs[$i]"
if [[ -z $step ]]; then
continue
fi
if [[ $stem =~ "^\." ]]; then
dirs[$i]=$step[0,2]
else
dirs[$i]=$step[0,1]
fi
done
fi
echo ${(j:/:)dirs}
}
function current_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}