Skip to content

Instantly share code, notes, and snippets.

Last active Apr 7, 2020
What would you like to do?
My FISH prompt (avoids shortened path names, unless too long or in subshells)
# name: Classic + Vcs (custom)
# author: Lily Ballard & Lionello Lunesu
function fish_prompt --description 'Write out the prompt'
set -l last_pipestatus $pipestatus
set -l normal (set_color normal)
# Color the prompt differently when we're root
set -l color_cwd $fish_color_cwd
set -l prefix
set -l suffix '\n$ '
if contains -- $USER root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
set suffix '\n# '
# If we're running via SSH, change the host color.
set -l color_host $fish_color_host
if set -q SSH_TTY
set color_host $fish_color_host_remote
# Write pipestatus
set -l prompt_status (__fish_print_pipestatus " [" "]" "|" (set_color $fish_color_status) (set_color --bold $fish_color_status) $last_pipestatus)
# Shorten the prompt, but only when it's too long (or in subshell)
set -g fish_prompt_pwd_dir_length (expr $SHLVL - 1)
set -l longprompt $USER (prompt_hostname) (prompt_pwd) (__fish_vcs_prompt) $prompt_status
if test (expr length "$longprompt") -gt $COLUMNS
set -g fish_prompt_pwd_dir_length 1
echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $color_host) (prompt_hostname) $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal $prompt_status
builtin printf $suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment