-
-
Save slottermoser/5601888 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if status --is-interactive | |
set -gx PATH ~/bin /usr/local/bin ~/Applications/ $PATH; | |
end | |
# My colors | |
set -g fish_color_autosuggestion 444444 | |
set -g fish_color_command cyan | |
set -g fish_color_comment red | |
set -g fish_color_cwd cyan | |
set -g fish_color_cwd_root red | |
set -g fish_color_error 'red' '--bold' | |
set -g fish_color_escape cyan | |
set -g fish_color_history_current cyan | |
set -g fish_color_user cyan | |
set -g fish_color_host cyan | |
set -g fish_color_match cyan | |
set -g fish_color_normal normal | |
set -g fish_color_operator 00afff | |
set -g fish_color_param 00afff | |
set -g fish_color_quote brown | |
set -g fish_color_redirection normal | |
set -g fish_color_search_match purple | |
set -g fish_color_status red |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fish_prompt --description 'Write out the prompt' | |
set -l last_status $status | |
# Just calculate these once, to save a few cycles when displaying the prompt | |
if not set -q __fish_prompt_hostname | |
set -g __fish_prompt_hostname (hostname|cut -d . -f 1) | |
end | |
if not set -q __fish_prompt_normal | |
set -g __fish_prompt_normal (set_color normal) | |
end | |
set -l delim '$' | |
switch $USER | |
case root | |
if not set -q __fish_prompt_cwd | |
if set -q fish_color_cwd_root | |
set -g __fish_prompt_cwd (set_color $fish_color_cwd_root) | |
else | |
set -g __fish_prompt_cwd (set_color $fish_color_cwd) | |
end | |
end | |
case '*' | |
if not set -q __fish_prompt_cwd | |
set -g __fish_prompt_cwd (set_color $fish_color_cwd) | |
end | |
end | |
set -g __fish_git_prompt_showdirtystate 1 | |
set -g __fish_git_prompt_color purple | |
set -l prompt_status | |
if test $last_status -ne 0 | |
if not set -q __fish_prompt_status | |
set -g __fish_prompt_status (set_color $fish_color_status) | |
end | |
set prompt_status "$__fish_prompt_status [$last_status]$__fish_prompt_normal" | |
end | |
if not set -q __fish_prompt_user | |
set -g __fish_prompt_user (set_color $fish_color_user) | |
end | |
if not set -q __fish_prompt_host | |
set -g __fish_prompt_host (set_color $fish_color_host) | |
end | |
echo -n -s \n "$__fish_prompt_user" $USER @ "$__fish_prompt_host" (hostname) ' ' "$__fish_prompt_cwd" (prompt_pwd) (__fish_git_prompt) "$__fish_prompt_normal" \n "$delim" ' ' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Truncates the path with a leading ellipsis, like so: | |
# /System/Library/Frameworks/CoreServices.framework/Versions/A/Resources/English.lproj -> | |
# /.../CoreServices.framework/Versions/A/Resources/English.lproj | |
# | |
# ~/Library/Saved Application State/com.apple.UnifiedHIDFWUpdater.thunderboltDisplay.savedState -> | |
# ~/.../com.apple.UnifiedHIDFWUpdater.thunderboltDisplay.savedState | |
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt" | |
echo $PWD | sed -e "s|^$HOME|~|" | awk -F/ '{ | |
str = $NF | |
currfield = NF - 1 | |
maxlen = 60 # Well, possibly plus a few for "~/..." | |
while (currfield > 0 \ | |
&& length(str) + length($currfield) + 1 < maxlen \ | |
&& length($currfield) > 0 ) { | |
str = $currfield "/" str | |
currfield = currfield-1 | |
} | |
if ( currfield > 1 ) { | |
str = ".../" str; | |
} | |
if ( currfield > 0 ) { | |
str= $1 "/" str | |
} | |
print str | |
}' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment