From 01ec92fc6ba43ea09892e7e939f84f2a9b30d714 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 7 Feb 2022 21:19:50 -0800 Subject: fix(wpcarro/fish): prefer absolute path for prompt.fish Also move prompt.fish out of configs, which is a deprecated location. Change-Id: I95360bc24b0b147a611881ed53e70bf1f9e5deea Reviewed-on: https://cl.tvl.fyi/c/depot/+/5256 Reviewed-by: wpcarro Autosubmit: wpcarro Tested-by: BuildkiteCI --- users/wpcarro/configs/.config/fish/prompt.fish | 87 -------------------------- users/wpcarro/dotfiles/config.fish | 2 +- users/wpcarro/dotfiles/prompt.fish | 87 ++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 users/wpcarro/configs/.config/fish/prompt.fish create mode 100644 users/wpcarro/dotfiles/prompt.fish (limited to 'users/wpcarro') diff --git a/users/wpcarro/configs/.config/fish/prompt.fish b/users/wpcarro/configs/.config/fish/prompt.fish deleted file mode 100644 index 58d22dab5efa..000000000000 --- a/users/wpcarro/configs/.config/fish/prompt.fish +++ /dev/null @@ -1,87 +0,0 @@ -# When the Emacs SSH client, Tramp, connects to a remote host that uses Fish, -# it's important to keep the shell prompt simple so that Tramp can parse it. -if test "$TERM" = "dumb" - function fish_prompt - echo "\$ " - end - function fish_right_prompt; end - function fish_greeting; end - function fish_title; end -else - function fish_prompt - # My custom prompt. - # - # Design objectives: - # - max-length <= 80 characters - # - minimal - # - no dependencies (well, you know what I mean) - # - # Components - # - ssh connection - # - user - # - host - # - git repo - # - git branch - # - lambda character as prompt - - # Cache status before we overwrite it. - set -l last_status $status - - # Colors - set -l color_inactive (set_color red --bold) - set -l color_active (set_color green --bold) - set -l color_normal (set_color normal) - - # SSH information - if set -q SSH_CLIENT; or set -q SSH_TTY - echo -en "$color_active \bssh ✓ [$color_normal$USER@"(hostname)"$color_active]$color_normal" - else - echo -en "$color_inactive \bssh ✗ [$color_normal$USER@"(hostname)"$color_inactive]$color_normal" - end - - # Separator - echo -n " " - - # Git information - set -l git_repo (git rev-parse --show-toplevel 2>/dev/null) - set -l git_status $status - - 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_path$color_active]$color_normal" - else - echo -en "$color_inactive \bgit ✗ [$color_normal$dir_path$color_inactive]$color_normal" - end - - # Newline - echo - - # Handle root vs non-root - if [ "$USER" = "root" ] - set -g prompt_sigil "#" - else - set -g prompt_sigil "λ" - end - - set -l time (date +"%T") - if test $last_status -eq 0 - set -l color_prompt (set_color white --bold) - echo -n "$time$color_prompt $prompt_sigil$color_normal " - else - set -l color_prompt (set_color red --bold) - echo -n "$time$color_prompt $prompt_sigil$color_normal " - end - end - function fish_right_prompt; end - function fish_greeting; end - function fish_title; end -end diff --git a/users/wpcarro/dotfiles/config.fish b/users/wpcarro/dotfiles/config.fish index 2e2006e9ca92..9d91b0086f8c 100644 --- a/users/wpcarro/dotfiles/config.fish +++ b/users/wpcarro/dotfiles/config.fish @@ -25,7 +25,7 @@ set -gx ALTERNATE_EDITOR "emacs -q -nw" set -gx VISUAL "emacsclient" # Use my custom fish prompt -source ~/.config/fish/prompt.fish +source /depot/users/wpcarro/dotfiles/prompt.fish # Configure fuzzy history, file, directory searching source (fzf-share)/key-bindings.fish && fzf_key_bindings diff --git a/users/wpcarro/dotfiles/prompt.fish b/users/wpcarro/dotfiles/prompt.fish new file mode 100644 index 000000000000..58d22dab5efa --- /dev/null +++ b/users/wpcarro/dotfiles/prompt.fish @@ -0,0 +1,87 @@ +# When the Emacs SSH client, Tramp, connects to a remote host that uses Fish, +# it's important to keep the shell prompt simple so that Tramp can parse it. +if test "$TERM" = "dumb" + function fish_prompt + echo "\$ " + end + function fish_right_prompt; end + function fish_greeting; end + function fish_title; end +else + function fish_prompt + # My custom prompt. + # + # Design objectives: + # - max-length <= 80 characters + # - minimal + # - no dependencies (well, you know what I mean) + # + # Components + # - ssh connection + # - user + # - host + # - git repo + # - git branch + # - lambda character as prompt + + # Cache status before we overwrite it. + set -l last_status $status + + # Colors + set -l color_inactive (set_color red --bold) + set -l color_active (set_color green --bold) + set -l color_normal (set_color normal) + + # SSH information + if set -q SSH_CLIENT; or set -q SSH_TTY + echo -en "$color_active \bssh ✓ [$color_normal$USER@"(hostname)"$color_active]$color_normal" + else + echo -en "$color_inactive \bssh ✗ [$color_normal$USER@"(hostname)"$color_inactive]$color_normal" + end + + # Separator + echo -n " " + + # Git information + set -l git_repo (git rev-parse --show-toplevel 2>/dev/null) + set -l git_status $status + + 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_path$color_active]$color_normal" + else + echo -en "$color_inactive \bgit ✗ [$color_normal$dir_path$color_inactive]$color_normal" + end + + # Newline + echo + + # Handle root vs non-root + if [ "$USER" = "root" ] + set -g prompt_sigil "#" + else + set -g prompt_sigil "λ" + end + + set -l time (date +"%T") + if test $last_status -eq 0 + set -l color_prompt (set_color white --bold) + echo -n "$time$color_prompt $prompt_sigil$color_normal " + else + set -l color_prompt (set_color red --bold) + echo -n "$time$color_prompt $prompt_sigil$color_normal " + end + end + function fish_right_prompt; end + function fish_greeting; end + function fish_title; end +end -- cgit 1.4.1