Support root directory and dirs like /tmp
Properly handle display the root directory and sub directories.
This commit is contained in:
		
							parent
							
								
									5d656b646f
								
							
						
					
					
						commit
						a9ac4f925b
					
				
					 1 changed files with 11 additions and 6 deletions
				
			
		|  | @ -45,14 +45,21 @@ else | ||||||
|         # Git information |         # Git information | ||||||
|         set -l git_repo (git rev-parse --show-toplevel 2>/dev/null) |         set -l git_repo (git rev-parse --show-toplevel 2>/dev/null) | ||||||
|         set -l git_status $status |         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 |         if test $git_status -eq 0 | ||||||
|             set -l git_repo_name (basename (git rev-parse --show-toplevel)) |             set -l git_repo_name (basename (git rev-parse --show-toplevel)) | ||||||
|             set -l git_branch (git branch 2>/dev/null | grep '^\*' | cut -d' ' -f2-) |             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 |         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 |         end | ||||||
| 
 | 
 | ||||||
|         # Newline |         # Newline | ||||||
|  | @ -65,8 +72,6 @@ else | ||||||
|             set -g prompt_sigil "λ" |             set -g prompt_sigil "λ" | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         # TODO(wpcarro): For root directories like /tmp, there will not be a parent |  | ||||||
|         # directory. Support these directories. |  | ||||||
|         set -l time (date +"%T") |         set -l time (date +"%T") | ||||||
|         if test $last_status -eq 0 |         if test $last_status -eq 0 | ||||||
|             set -l color_prompt (set_color white --bold) |             set -l color_prompt (set_color white --bold) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue