From 329be70bad807fb77fd4950c61bcd17e9647e04d Mon Sep 17 00:00:00 2001 From: Andrew Davidson Date: Mon, 9 Mar 2020 09:54:07 -0400 Subject: [PATCH] fixing bug in zsh prompt from moving functions around --- zsh/.zsh/functions.zsh | 24 ------------------------ zsh/.zsh/prompt.zsh | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/zsh/.zsh/functions.zsh b/zsh/.zsh/functions.zsh index b34b10b..7e93d1d 100644 --- a/zsh/.zsh/functions.zsh +++ b/zsh/.zsh/functions.zsh @@ -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() { diff --git a/zsh/.zsh/prompt.zsh b/zsh/.zsh/prompt.zsh index dbb3246..e15ec4b 100644 --- a/zsh/.zsh/prompt.zsh +++ b/zsh/.zsh/prompt.zsh @@ -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,~,") }