fixing bug in zsh prompt from moving functions around
This commit is contained in:
parent
06861bdd16
commit
329be70bad
2 changed files with 25 additions and 24 deletions
|
@ -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() {
|
||||
|
|
|
@ -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,~,")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue