tide/conf.d/_tide_pwd_var_change.fish

27 lines
910 B
Fish
Raw Normal View History

2020-06-10 00:16:19 +03:00
function _tide_pwd_var_change -v PWD
set -l preDirNumberPwd (string replace $HOME '~' $PWD)
2020-06-14 00:27:13 +03:00
set -l preDirNumberPwdSplit (string split '/' $preDirNumberPwd)
2020-06-10 00:16:19 +03:00
2020-06-10 00:43:43 +03:00
set -g _tide_split_pwd $preDirNumberPwdSplit[(math -s0 -$tide_pwd_max_dirs)..-1]
2020-06-10 00:16:19 +03:00
set -g _tide_pwd (string join '/' $_tide_split_pwd)
set -g _tide_git_dir (git rev-parse --show-toplevel 2>/dev/null)
set -g _tide_pwd_anchors
if contains 'first' $tide_pwd_anchors
2020-06-14 00:27:13 +03:00
if test -n "$_tide_split_pwd[1]"
set -a _tide_pwd_anchors $_tide_split_pwd[1]
else
set -a _tide_pwd_anchors $_tide_split_pwd[2]
end
2020-06-10 00:16:19 +03:00
end
if contains 'last' $tide_pwd_anchors
set -a _tide_pwd_anchors $_tide_split_pwd[-1]
end
if contains 'git' $tide_pwd_anchors
2020-06-14 00:27:13 +03:00
set -a _tide_pwd_anchors (string replace $HOME '~' $_tide_git_dir | string split -r -m1 '/')[2]
2020-06-10 00:16:19 +03:00
end
_tide_pwd
end