New fish theme

This commit is contained in:
Colin Powell
2020-01-31 18:54:43 -05:00
parent daed97f08b
commit 25382ad2c7
38 changed files with 32 additions and 451 deletions

View File

@ -1,8 +0,0 @@
# Deactivate the default virtualenv prompt so that we can add our own
set --global --export VIRTUAL_ENV_DISABLE_PROMPT 1
# Whether or not is a fresh session
set --global _pure_fresh_session true
# Register `_pure_prompt_new_line` as an event handler fot `fish_prompt`
functions -q _pure_prompt_new_line

View File

@ -1,66 +0,0 @@
set --global pure_version 2.5.2 # used for bug report
# Base colors
_pure_set_default pure_color_primary blue
_pure_set_default pure_color_info cyan
_pure_set_default pure_color_mute brblack
_pure_set_default pure_color_success magenta
_pure_set_default pure_color_normal normal
_pure_set_default pure_color_danger red
_pure_set_default pure_color_light white
_pure_set_default pure_color_warning yellow
_pure_set_default pure_color_dark black
# Prompt
_pure_set_default pure_symbol_prompt ""
_pure_set_default pure_symbol_reverse_prompt "" # used for VI mode
_pure_set_default pure_color_prompt_on_error pure_color_danger
_pure_set_default pure_color_prompt_on_success pure_color_success
# Current Working Directory
_pure_set_default pure_color_current_directory pure_color_primary
# Git
_pure_set_default pure_enable_git true
_pure_set_default pure_symbol_git_unpulled_commits "⇣"
_pure_set_default pure_symbol_git_unpushed_commits "⇡"
_pure_set_default pure_symbol_git_dirty "*"
_pure_set_default pure_color_git_unpulled_commits pure_color_info
_pure_set_default pure_color_git_unpushed_commits pure_color_info
_pure_set_default pure_color_git_branch pure_color_mute
_pure_set_default pure_color_git_dirty pure_color_mute
# SSH info
_pure_set_default pure_color_ssh_hostname pure_color_mute
_pure_set_default pure_color_ssh_separator pure_color_mute
_pure_set_default pure_color_ssh_user_normal pure_color_mute
_pure_set_default pure_color_ssh_user_root pure_color_light
# Number of running jobs
_pure_set_default pure_show_jobs false
_pure_set_default pure_color_jobs pure_color_normal
# Virtualenv for Python
_pure_set_default pure_color_virtualenv pure_color_mute
# Print current working directory at the beginning of prompt
# true (default): current directory, git, user@hostname (ssh-only), command duration
# false: user@hostname (ssh-only), current directory, git, command duration
_pure_set_default pure_begin_prompt_with_current_directory true
# Show exit code of last command as a separate prompt character (cf. https://github.com/sindresorhus/pure/wiki#show-exit-code-of-last-command-as-a-separate-prompt-character)
# false - single prompt character, default
# true - separate prompt character
_pure_set_default pure_separate_prompt_on_error false
# Max execution time of a process before its run time is shown when it exits
_pure_set_default pure_threshold_command_duration 5
_pure_set_default pure_color_command_duration pure_color_warning
# VI mode indicator
# true (default): indicate a non-insert mode by reversing the prompt symbol ()
# false: indicate vi mode with [I], [N], [V]
_pure_set_default pure_reverse_prompt_symbol_in_vimode true
# Title
_pure_set_default pure_symbol_title_bar_separator "—"

View File

@ -5,7 +5,6 @@ set -gx PATH ~/.emacs.d/bin $PATH
set -gx PATH ~/.fzf/bin $PATH
set -gx PATH ~/.local/bin $PATH
set -gx PATH ~/.asdf/install/rust/stable/bin $PATH
set -gx SLACK_CLI_TOKEN (pass personal/slack/token)
fzf_key_bindings
set -gx EDITOR vi
set -gx XDG_RUNTIME_DIR /run/user/(id -u)

View File

@ -14,6 +14,7 @@ SETUVAR __fish_init_2_3_0:\x1d
SETUVAR __fish_init_3_x:\x1d
SETUVAR __tf_func:function\x20__tf_alias\x20\x2dd\x20\x22Correct\x20your\x20previous\x20console\x20command\x22\x3b\x20\x20set\x20\x2dl\x20fucked_up_command\x20\x24history\x5b1\x5d\x3b\x20\x20env\x20TF_SHELL\x3dfish\x20TF_ALIAS\x3d__tf_alias\x20PYTHONIOENCODING\x3dutf\x2d8\x20thefuck\x20\x24fucked_up_command\x20\x7c\x20read\x20\x2dl\x20unfucked_command\x3b\x20\x20if\x20\x5b\x20\x22\x24unfucked_command\x22\x20\x21\x3d\x20\x22\x22\x20\x5d\x3b\x20\x20\x20\x20eval\x20\x24unfucked_command\x3b\x20\x20\x20\x20builtin\x20history\x20delete\x20\x2d\x2dexact\x20\x2d\x2dcase\x2dsensitive\x20\x2d\x2d\x20\x24fucked_up_command\x3b\x20\x20\x20\x20builtin\x20history\x20merge\x20\x5e\x20/dev/null\x3b\x20\x20end\x3bend\x3b
SETUVAR __tf_vers:The\x20Fuck\x203\x2e28\x20using\x20Python\x203\x2e7\x2e1\x20and\x20Fish\x20Shell\x202\x2e7\x2e1
SETUVAR chain_links:chain\x2elinks\x2eroot\x1echain\x2elinks\x2ejobs\x1echain\x2elinks\x2epwd\x1echain\x2elinks\x2evcs_branch\x1echain\x2elinks\x2evcs_dirty\x1echain\x2elinks\x2evcs_stashed
SETUVAR fish_color_autosuggestion:555\x1ebrblack
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:\x2d\x2dbold

View File

@ -4,4 +4,4 @@ jethrokuan/fzf
oh-my-fish/plugin-direnv
joseluisq/gitnow
fishpkg/fish-git-util
rafaelrinaldi/pure
oh-my-fish/theme-krisleech

View File

@ -1,32 +0,0 @@
set fail 1
function _pure_format_time \
--description="Format milliseconds to a human readable format" \
--argument-names milliseconds threshold
if test $milliseconds -lt 0; return $fail; end
set --local seconds (math -s0 "$milliseconds / 1000 % 60")
set --local minutes (math -s0 "$milliseconds / 60000 % 60")
set --local hours (math -s0 "$milliseconds / 3600000 % 24")
set --local days (math -s0 "$milliseconds / 86400000")
set --local time
if test $days -gt 0
set time $time (printf "%sd" $days)
end
if test $hours -gt 0
set time $time (printf "%sh" $hours)
end
if test $minutes -gt 0
set time $time (printf "%sm" $minutes)
end
if test $seconds -gt $threshold
set time $time (printf "%ss" $seconds)
end
echo -e (string join ' ' $time)
end

View File

@ -1,14 +0,0 @@
function _pure_get_prompt_symbol \
--description 'Print prompt symbol' \
--argument-names exit_code
set --local prompt_symbol $pure_symbol_prompt
set --local is_vi_mode (string match -r "fish_(vi|hybrid)_key_bindings" $fish_key_bindings)
if test -n "$is_vi_mode" \
-a "$pure_reverse_prompt_symbol_in_vimode" = true \
-a "$fish_bind_mode" != "insert"
set prompt_symbol $pure_symbol_reverse_prompt
end
echo "$prompt_symbol"
end

View File

@ -1,14 +0,0 @@
function _pure_parse_directory \
--description "Replace '$HOME' with '~'" \
--argument-names max_path_length
set --local folder (string replace $HOME '~' $PWD)
if test -n "$max_path_length";
if test (string length $folder) -gt $max_path_length;
# If path exceeds maximum symbol limit, use default fish path formating function
set folder (prompt_pwd)
end
end
echo $folder
end

View File

@ -1,4 +0,0 @@
function _pure_parse_git_branch --description "Parse current Git branch name"
command git symbolic-ref --short HEAD 2>/dev/null;
or command git name-rev --name-only HEAD 2>/dev/null
end

View File

@ -1,5 +0,0 @@
function _pure_place_iterm2_prompt_mark
if functions -q iterm2_prompt_mark
iterm2_prompt_mark
end
end

View File

@ -1,11 +0,0 @@
function _pure_print_prompt
set --local prompt
for prompt_part in $argv
if test (_pure_string_width $prompt_part) -gt 0
set prompt "$prompt $prompt_part"
end
end
echo (string trim -l $prompt)
end

View File

@ -1,11 +0,0 @@
function _pure_prompt \
--description 'Print prompt symbol' \
--argument-names exit_code
set --local jobs (_pure_prompt_jobs)
set --local virtualenv (_pure_prompt_virtualenv) # Python virtualenv name
set --local vimode_indicator (_pure_prompt_vimode) # vi-mode indicator
set --local pure_symbol (_pure_prompt_symbol $exit_code)
echo (_pure_print_prompt $jobs $virtualenv $vimode_indicator $pure_symbol)
end

View File

@ -1,6 +0,0 @@
function _pure_prompt_beginning
# Clear existing line content
set --local clear_line "\r\033[K"
echo $clear_line
end

View File

@ -1,11 +0,0 @@
function _pure_prompt_command_duration
set --local command_duration
# Get command execution duration
if test -n "$CMD_DURATION"
set command_duration (_pure_format_time $CMD_DURATION $pure_threshold_command_duration)
end
set --local command_duration_color (_pure_set_color $pure_color_command_duration)
echo "$command_duration_color$command_duration"
end

View File

@ -1,11 +0,0 @@
set fail 1
function _pure_prompt_current_folder --argument-names current_prompt_width
if test -z "$current_prompt_width"; return $fail; end
set --local current_folder (_pure_parse_directory (math $COLUMNS - $current_prompt_width - 1))
set --local current_folder_color (_pure_set_color $pure_color_current_directory)
echo "$current_folder_color$current_folder"
end

View File

@ -1,3 +0,0 @@
function _pure_prompt_ending
echo (set_color normal)" "
end

View File

@ -1,35 +0,0 @@
function _pure_prompt_first_line \
--description 'Print contextual information before prompt.'
if not type -fq git # exit if git is not available
return 1
end
set --local prompt_ssh (_pure_prompt_ssh)
set --local prompt_git (_pure_prompt_git)
set --local prompt_command_duration (_pure_prompt_command_duration)
set --local prompt (_pure_print_prompt \
$prompt_ssh \
$prompt_git \
$prompt_command_duration
)
set --local prompt_width (_pure_string_width $prompt)
set --local current_folder (_pure_prompt_current_folder $prompt_width)
set --local prompt_components
if test $pure_begin_prompt_with_current_directory = true
set prompt_components \
$current_folder \
$prompt_git \
$prompt_ssh \
$prompt_command_duration
else
set prompt_components \
$prompt_ssh \
$current_folder \
$prompt_git \
$prompt_command_duration
end
echo (_pure_print_prompt $prompt_components)
end

View File

@ -1,20 +0,0 @@
function _pure_prompt_git \
--description 'Print git repository informations: branch name, dirty, upstream ahead/behind'
if test $pure_enable_git != true
return
end
set --local is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null)
if test -n "$is_git_repository"
set --local git_prompt (_pure_prompt_git_branch)(_pure_prompt_git_dirty)
set --local git_pending_commits (_pure_prompt_git_pending_commits)
if test (_pure_string_width $git_pending_commits) -ne 0
set git_prompt $git_prompt $git_pending_commits
end
echo $git_prompt
end
end

View File

@ -1,6 +0,0 @@
function _pure_prompt_git_branch
set --local git_branch (_pure_parse_git_branch) # current git branch
set --local git_branch_color (_pure_set_color $pure_color_git_branch)
echo "$git_branch_color$git_branch"
end

View File

@ -1,18 +0,0 @@
function _pure_prompt_git_dirty
set --local git_dirty_symbol
set --local git_dirty_color
set --local is_git_dirty (
# The first checks for staged changes, the second for unstaged ones.
# We put them in this order because checking staged changes is *fast*.
not command git diff-index --ignore-submodules --cached --quiet HEAD -- >/dev/null 2>&1
or not command git diff --ignore-submodules --no-ext-diff --quiet --exit-code >/dev/null 2>&1
and echo "true"
)
if test -n "$is_git_dirty" # untracked or un-commited files
set git_dirty_symbol "$pure_symbol_git_dirty"
set git_dirty_color (_pure_set_color $pure_color_git_dirty)
end
echo "$git_dirty_color$git_dirty_symbol"
end

View File

@ -1,27 +0,0 @@
function _pure_prompt_git_pending_commits
set --local git_unpushed_commits
set --local git_unpulled_commits
set --local has_upstream (command git rev-parse --abbrev-ref '@{upstream}' 2>/dev/null)
if test -n "$has_upstream" # check there is an upstream repo configured
and test "$has_upstream" != '@{upstream}' # Fixed #179, dont check the empty repo
command git rev-list --left-right --count 'HEAD...@{upstream}' \
| read --local --array git_status
set --local commit_to_push $git_status[1]
set --local commit_to_pull $git_status[2]
if test $commit_to_push -gt 0 # upstream is behind local repo
set --local git_unpushed_commits_color \
(_pure_set_color $pure_color_git_unpushed_commits)
set git_unpushed_commits "$git_unpushed_commits_color$pure_symbol_git_unpushed_commits"
end
if test $commit_to_pull -gt 0 # upstream is ahead of local repo
set --local git_unpulled_commits_color \
(_pure_set_color $pure_color_git_unpulled_commits)
set git_unpulled_commits "$git_unpulled_commits_color$pure_symbol_git_unpulled_commits"
end
end
echo "$git_unpushed_commits$git_unpulled_commits"
end

View File

@ -1,9 +0,0 @@
function _pure_prompt_jobs --description "Display number of running jobs"
if test $pure_show_jobs = true
set --local njobs (count (jobs -p))
set --local jobs_color (_pure_set_color $pure_color_jobs)
if test $njobs -gt 0
echo "$jobs_color"[$njobs]
end
end
end

View File

@ -1,11 +0,0 @@
function _pure_prompt_new_line \
--description "Do not add a line break to a brand new session" \
--on-event fish_prompt
set --local new_line
if test $_pure_fresh_session = false
set new_line "\n"
end
echo -e -n "$new_line"
end

View File

@ -1,5 +0,0 @@
function _pure_prompt_ssh
if test "$SSH_CONNECTION" != ""
echo (_pure_prompt_ssh_user)(_pure_prompt_ssh_separator)(_pure_prompt_ssh_host)
end
end

View File

@ -1,7 +0,0 @@
function _pure_prompt_ssh_host
set --query --global hostname
or set --local hostname (hostname -s) # current host name compatible busybox
set --local hostname_color (_pure_set_color $pure_color_ssh_hostname)
echo "$hostname_color$hostname"
end

View File

@ -1,6 +0,0 @@
function _pure_prompt_ssh_separator
set --local separator_symbol "@"
set --local separator_symbol_color (_pure_set_color $pure_color_ssh_separator)
echo "$separator_symbol_color$separator_symbol"
end

View File

@ -1,10 +0,0 @@
function _pure_prompt_ssh_user
set --local username (whoami) # current user name
set --local username_color (_pure_set_color $pure_color_ssh_user_normal) # default color
if test "$username" = "root"
set username_color (_pure_set_color $pure_color_ssh_user_root) # different color for root
end
echo "$username_color$username"
end

View File

@ -1,20 +0,0 @@
function _pure_prompt_symbol \
--description 'Print prompt symbol' \
--argument-names exit_code
set --local prompt_symbol (_pure_get_prompt_symbol)
set --local symbol_color_success (_pure_set_color $pure_color_prompt_on_success)
set --local symbol_color_error (_pure_set_color $pure_color_prompt_on_error)
set --local command_succeed 0
set --local symbol_color $symbol_color_success # default pure symbol color
if test $exit_code -ne $command_succeed
set symbol_color $symbol_color_error # different pure symbol color when previous command failed
if test "$pure_separate_prompt_on_error" = true
set symbol_color "$symbol_color_error$prompt_symbol$symbol_color_success"
end
end
echo "$symbol_color$prompt_symbol"
end

View File

@ -1,5 +0,0 @@
function _pure_prompt_vimode
if test $pure_reverse_prompt_symbol_in_vimode = false
echo (fish_default_mode_prompt)
end
end

View File

@ -1,8 +0,0 @@
function _pure_prompt_virtualenv --description "Display virtualenv directory"
if test -n "$VIRTUAL_ENV"
set --local virtualenv (basename "$VIRTUAL_ENV")
set --local virtualenv_color (_pure_set_color $pure_color_virtualenv)
echo "$virtualenv_color$virtualenv"
end
end

View File

@ -1,19 +0,0 @@
function _pure_set_color \
--description 'Set color' \
--argument-names var
set --local color $var
# Backwards compatibility for colors defined as control sequencies instead of fish colors
if not string match --quiet --all --regex '\e\[[^m]*m' $color[1]
and set -q $color
set color $$var
end
set --local result $color
if not string match --quiet --all --regex '\e\[[^m]*m' $result[1]
and not test -z $result[1]
set result (set_color $color)
end
echo "$result"
end

View File

@ -1,8 +0,0 @@
function _pure_set_default \
--description 'Set default value for configuration variable' \
--argument-names var default
if not set -q --universal $var
set --universal $var $default
end
end

View File

@ -1,9 +0,0 @@
function _pure_string_width \
--description 'returns raw string length, i.e. ignore ANSI-color' \
--argument-names prompt
set --local empty ''
set --local raw_prompt (string replace --all --regex '\e\[[^m]*m' $empty -- $prompt)
string length -- $raw_prompt
end

View File

@ -1,2 +0,0 @@
function fish_greeting
end

View File

@ -1,2 +0,0 @@
function fish_mode_prompt
end

View File

@ -1,11 +1,31 @@
function fish_prompt
set --local exit_code $status # save previous exit code
echo -e -n (_pure_prompt_beginning) # init prompt context (clear current line, etc.)
echo -e (_pure_prompt_first_line) # print current path, git branch/status, command duration
_pure_place_iterm2_prompt_mark # place iTerm shell integration mark
echo -e -n (_pure_prompt $exit_code) # print prompt
echo -e (_pure_prompt_ending) # reset colors and end prompt
set _pure_fresh_session false
# name: Krisleech
function _git_branch_name
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
end
function fish_prompt
set -l cyan (set_color -o cyan)
set -l yellow (set_color -o yellow)
set -l red (set_color -o red)
set -l blue (set_color -o blue)
set -l green (set_color -o green)
set -l normal (set_color normal)
set -l cwd $cyan(basename (prompt_pwd))
if [ (_git_branch_name) ]
set -l git_branch (_git_branch_name)
set git_info "$green$git_branch "
if [ (_is_git_dirty) ]
set -l dirty "$yellow"
set git_info "$git_info$dirty"
end
end
echo -n -s $cwd $red '|' $git_info $normal' ' $normal
end

View File

@ -1,16 +0,0 @@
function fish_title \
--description "Set title to current folder and shell name" \
--argument-names last_command
set --local basename (string replace -r '^.*/' '' -- $PWD)
set --local current_folder (_pure_parse_directory)
set --local current_command (status current-command 2>/dev/null; or echo $_)
set --local prompt "$basename: $last_command $pure_symbol_title_bar_separator $current_command"
if test -z "$last_command"
set prompt "$current_folder $pure_symbol_title_bar_separator $current_command"
end
echo $prompt
end