mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-23 08:46:51 +03:00
Update pwd test
This commit is contained in:
parent
bb129150f8
commit
69356d4a15
@ -4,10 +4,8 @@ function _tide_pwd
|
||||
|
||||
set -g _tide_pwd_output $colorDirs$_tide_pwd
|
||||
|
||||
if not test -w $PWD
|
||||
if test -n "$tide_pwd_unwritable_icon"
|
||||
set _tide_pwd_output "$tide_pwd_unwritable_icon "$_tide_pwd_output
|
||||
end
|
||||
if not test -w $PWD -a -n "$tide_pwd_unwritable_icon"
|
||||
set _tide_pwd_output "$colorDirs$tide_pwd_unwritable_icon "$_tide_pwd_output
|
||||
end
|
||||
|
||||
set -l truncatedList '.' $_tide_split_pwd
|
||||
@ -15,8 +13,7 @@ function _tide_pwd
|
||||
for dir in $_tide_split_pwd
|
||||
if contains $dir $_tide_pwd_anchors
|
||||
set _tide_pwd_output (string replace $dir (set_color -o $tide_pwd_color_anchors)$dir(set_color normal -b $tide_pwd_bg_color) $_tide_pwd_output)
|
||||
else
|
||||
if test (string length $truncatedPwd) -gt $_tide_pwd_max_length
|
||||
else if test (string length $truncatedPwd) -gt $_tide_pwd_max_length
|
||||
set -l dirTruncated $dir
|
||||
set -l truncationLength 1
|
||||
while contains $dirTruncated $truncatedList
|
||||
@ -29,7 +26,6 @@ function _tide_pwd
|
||||
set _tide_pwd_output (string replace $dir (set_color $tide_pwd_color_truncated_dirs)$dirTruncated $_tide_pwd_output)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set _tide_pwd_output (string replace -a '/' $colorDirs'/' $_tide_pwd_output)
|
||||
end
|
@ -5,18 +5,33 @@ function _pwd -a dir
|
||||
_tide_decolor (_tide_item_pwd)
|
||||
end
|
||||
|
||||
# Unwritable directories
|
||||
|
||||
sudo mkdir -p /unwritable/dir
|
||||
|
||||
set -l unwr "$tide_pwd_unwritable_icon "
|
||||
|
||||
@test '/' (_pwd '/') = $unwr'/'
|
||||
@test '/usr' (_pwd '/usr') = $unwr'/usr'
|
||||
@test '/usr/share' (_pwd '/usr/share') = $unwr'/usr/share'
|
||||
@test '~' (_pwd "$HOME") = '~'
|
||||
@test '~/.config' (_pwd "$HOME/.config") = '~/.config'
|
||||
@test '~/.config/fish' (_pwd "$HOME/.config/fish") = '~/.config/fish'
|
||||
@test '/unwritable' (_pwd '/unwritable') = $unwr'/unwritable'
|
||||
@test '/unwritable/dir' (_pwd '/unwritable/dir') = $unwr'/unwritable/dir'
|
||||
|
||||
sudo rm -rf /unwritable
|
||||
|
||||
# Normal directories
|
||||
|
||||
mkdir -p ~/normal/dir
|
||||
|
||||
@test '~' (_pwd ~) = '~'
|
||||
@test '~/normal' (_pwd ~/normal) = '~/normal'
|
||||
@test '~/normal/dir' (_pwd ~/normal/dir) = '~/normal/dir'
|
||||
|
||||
rm -rf ~/normal
|
||||
|
||||
# Long directories
|
||||
|
||||
set -l longDir "$HOME/alfa/bravo/charlie/delta/echo/foxtrot/golf/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa"
|
||||
if not test -e $longDir
|
||||
mkdir -p $longDir
|
||||
end
|
||||
mkdir -p $longDir
|
||||
|
||||
@test 'Long dir' (_pwd "$longDir") = '~/a/b/c/d/e/f/g/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa'
|
||||
rm -r $longDir
|
||||
|
||||
rm -r ~/alfa
|
Loading…
Reference in New Issue
Block a user