mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-09 13:10:40 +00:00
25 lines
560 B
Fish
25 lines
560 B
Fish
# SYNOPSIS
|
|
# set -l segs (prompt_segments) # root dir base
|
|
#
|
|
# OVERVIEW
|
|
# Extract the root (top-most parent directory), dirname and basename
|
|
# from fish_prompt
|
|
|
|
function prompt_segments -d "extract root, dir and base from fish_prompt"
|
|
set -l root (prompt_pwd | cut -d "/" -f1)
|
|
if test -z "$root"
|
|
echo "/"
|
|
else
|
|
echo "$root"
|
|
end
|
|
set -l path (prompt_pwd | cut -d "/" -f2-)
|
|
set -l dir (dirname $path)
|
|
if test $dir != "."
|
|
echo $dir
|
|
end
|
|
set -l base (basename $path)
|
|
if test -n "$base" -a "$base" != "~"
|
|
echo $base
|
|
end
|
|
end
|