Simplify pwd item, remove pwd_max_dirs

This commit is contained in:
Ilan Cosman 2021-01-15 20:08:33 -08:00
parent 306a918dd9
commit 18c687b2d6
6 changed files with 6 additions and 17 deletions

View File

@ -156,7 +156,6 @@ Most of Tide's git capabilities are inherited from Fish's built-in [fish_git_pro
| color_dirs | color of normal directories | color |
| color_truncated_dirs | color of truncated directories | color |
| markers | if a directory contains any of these files/directories, it will be anchored | list |
| max_dirs | max number of directories to display, 0 or less equals unlimited | integer |
| truncate_margin | start truncating when pwd is this many columns from terminal edge | integer |
| unwritable_icon | symbol to display when the directory is not writable by the user | string |

View File

@ -1,16 +1,10 @@
function _tide_item_pwd
set -l preMaxDirsSplitPwd (string replace $HOME '~' $PWD | string split '/')
set -l splitPwd $preMaxDirsSplitPwd[(math -$tide_pwd_max_dirs)..-1]
set -l splitPwd (string replace $HOME '~' $PWD | string split --no-empty '/')
set -l splitPwdForLength $splitPwd
set -l splitPwdForOutput $splitPwd
set -l anchorDirs
contains first $tide_pwd_anchors && if test -n "$splitPwd[1]"
set -a anchorDirs 1
else
set -a anchorDirs 2
end
contains last $tide_pwd_anchors && set -a anchorDirs (count $splitPwd)
contains first $tide_pwd_anchors && set -la anchorDirs 1
contains last $tide_pwd_anchors && set -la anchorDirs (count $splitPwd)
set -l colorDirs (set_color $tide_pwd_color_dirs || echo)
set -l colorAnchors (set_color -o $tide_pwd_color_anchors || echo)
@ -31,9 +25,7 @@ function _tide_item_pwd
set -l parentDir (string join '/' $splitPwd[1..(math $i-1)] | string replace '~' $HOME)
# Returns true if any markers exist in splitPwd[$i], or if anchorDirs contains i
if test -z thisIsFalse (string split -m 2 " " -- "-o -e "$parentDir/$tide_pwd_markers) ||
contains $i $anchorDirs
if test -z false (string split -m 2 " " -- "-o -e "$parentDir/$tide_pwd_markers) || contains $i $anchorDirs
set splitPwdForOutput[$i] $colorAnchors$splitPwd[$i]$keepBackgroundColor$colorDirs
else if test (string join '/' $splitPwdForLength | string length) -gt $pwdMaxLength
set -l truncationLength 1
@ -49,5 +41,7 @@ function _tide_item_pwd
end
end
test $splitPwd[1] = '~' || printf '%s' '/'
string join '/' $splitPwdForOutput
end

View File

@ -62,7 +62,6 @@ tide_pwd_color_truncated_dirs 8787AF
tide_pwd_dir_icon
tide_pwd_home_icon
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_pwd_max_dirs 0
tide_pwd_truncate_margin 10
tide_pwd_unwritable_icon ''
tide_right_prompt_frame_color 6C6C6C

View File

@ -62,7 +62,6 @@ tide_pwd_color_truncated_dirs 8787AF
tide_pwd_dir_icon
tide_pwd_home_icon
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_pwd_max_dirs 0
tide_pwd_truncate_margin 10
tide_pwd_unwritable_icon ''
tide_right_prompt_frame_color 6C6C6C

View File

@ -62,7 +62,6 @@ tide_pwd_color_truncated_dirs 8787AF
tide_pwd_dir_icon
tide_pwd_home_icon
tide_pwd_markers
tide_pwd_max_dirs 0
tide_pwd_truncate_margin 10
tide_pwd_unwritable_icon
tide_right_prompt_frame_color 6C6C6C

View File

@ -62,7 +62,6 @@ tide_pwd_color_truncated_dirs BCBCBC
tide_pwd_dir_icon
tide_pwd_home_icon
tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json
tide_pwd_max_dirs 0
tide_pwd_truncate_margin 10
tide_pwd_unwritable_icon ''
tide_right_prompt_frame_color 6C6C6C