mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
Polyfill path sort for older fishes
This commit is contained in:
parent
4f0b0a5638
commit
0c15ff1cbc
@ -1255,6 +1255,15 @@ function __bobthefish_prompt_dir -S -a real_pwd -d 'Display a shortened form of
|
|||||||
__bobthefish_path_segment "$real_pwd" pwd
|
__bobthefish_path_segment "$real_pwd" pwd
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Polyfill for fish < 3.5.0
|
||||||
|
function __bobthefish_closest_parent -S
|
||||||
|
if builtin -q path
|
||||||
|
echo (path sort -r $argv)[1]
|
||||||
|
else
|
||||||
|
string join \n $argv | awk '{ print length, $0 }' | sort -nsr | head -1 | cut -d" " -f2-
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# ==============================
|
# ==============================
|
||||||
# Apply theme
|
# Apply theme
|
||||||
@ -1314,7 +1323,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
|
|||||||
set -l fossil_root_dir (__bobthefish_fossil_project_dir $real_pwd)
|
set -l fossil_root_dir (__bobthefish_fossil_project_dir $real_pwd)
|
||||||
|
|
||||||
# only show the closest parent
|
# only show the closest parent
|
||||||
switch (path sort -r "$git_root_dir" "$hg_root_dir" "$fossil_root_dir")[1]
|
switch (__bobthefish_closest_parent "$git_root_dir" "$hg_root_dir" "$fossil_root_dir")
|
||||||
case ''
|
case ''
|
||||||
__bobthefish_prompt_dir $real_pwd
|
__bobthefish_prompt_dir $real_pwd
|
||||||
case "$git_root_dir"
|
case "$git_root_dir"
|
||||||
|
Loading…
Reference in New Issue
Block a user