about summary refs log tree commit diff
path: root/configs/.config
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-03-06T12·15+0000
committerWilliam Carroll <wpcarro@gmail.com>2020-03-06T18·45+0000
commita9ac4f925b8d8c52915e5f1f4419d5570086cd8a (patch)
treec6d038d9a202dc9ee20961dbc4590e358c317d4d /configs/.config
parent5d656b646f58c66ab5a144f8e90190a307c3a13c (diff)
Support root directory and dirs like /tmp
Properly handle display the root directory and sub directories.
Diffstat (limited to 'configs/.config')
-rw-r--r--configs/.config/fish/prompt.fish17
1 files changed, 11 insertions, 6 deletions
diff --git a/configs/.config/fish/prompt.fish b/configs/.config/fish/prompt.fish
index 17d807da0f02..58d22dab5efa 100644
--- a/configs/.config/fish/prompt.fish
+++ b/configs/.config/fish/prompt.fish
@@ -45,14 +45,21 @@ else
         # Git information
         set -l git_repo (git rev-parse --show-toplevel 2>/dev/null)
         set -l git_status $status
-        set -l dir_parent (basename (realpath ..))
-        set -l dir_current (basename (realpath .))
+
+        if [ (realpath .) = "/" ]
+            set -g dir_path (realpath .)
+        else if [ (realpath ..) = "/" ]
+            set -g dir_path (realpath .)
+        else
+            set -g dir_path (echo (basename (realpath ..))"/"(basename (realpath .)))
+        end
+
         if test $git_status -eq 0
             set -l git_repo_name (basename (git rev-parse --show-toplevel))
             set -l git_branch (git branch 2>/dev/null | grep '^\*' | cut -d' ' -f2-)
-            echo -en "$color_active \bgit ✓ [$color_normal$git_branch$color_active|$color_normal$git_repo_name$color_active|$color_normal$dir_parent/$dir_current$color_active]$color_normal"
+            echo -en "$color_active \bgit ✓ [$color_normal$git_branch$color_active|$color_normal$git_repo_name$color_active|$color_normal$dir_path$color_active]$color_normal"
         else
-            echo -en "$color_inactive \bgit ✗ [$color_normal$dir_parent/$dir_current$color_inactive]$color_normal"
+            echo -en "$color_inactive \bgit ✗ [$color_normal$dir_path$color_inactive]$color_normal"
         end
 
         # Newline
@@ -65,8 +72,6 @@ else
             set -g prompt_sigil "λ"
         end
 
-        # TODO(wpcarro): For root directories like /tmp, there will not be a parent
-        # directory. Support these directories.
         set -l time (date +"%T")
         if test $last_status -eq 0
             set -l color_prompt (set_color white --bold)