mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-20 10:44:38 +10:00
Adding starship prompt.
This commit is contained in:
@@ -4,116 +4,28 @@
|
||||
# | |_| || | http://www.gitlab.com/dwt1/
|
||||
# |____/ |_|
|
||||
#
|
||||
# My fish config. Not much to see here. Some pretty standard stuff.
|
||||
# My fish config. Not much to see here; just some pretty standard stuff.
|
||||
|
||||
### EXPORT ###
|
||||
set -U fish_user_paths $fish_user_paths $HOME/.local/bin/
|
||||
set fish_greeting # Supresses fish's intro message
|
||||
set TERM "xterm-256color" # Sets the terminal type
|
||||
set EDITOR "emacsclient -t -a ''" # $EDITOR use Emacs in terminal
|
||||
set VISUAL "emacsclient -c -a emacs" # $VISUAL use Emacs in GUI mode
|
||||
|
||||
|
||||
### PROMPT ###
|
||||
# This was the 'sashimi' prompt from oh-my-fish.
|
||||
function fish_prompt
|
||||
set -l last_status $status
|
||||
set -l cyan (set_color -o 98be65)
|
||||
set -l yellow (set_color -o yellow)
|
||||
set -g red (set_color -o 98be65)
|
||||
set -g blue (set_color -o blue)
|
||||
set -l green (set_color -o green)
|
||||
set -g normal (set_color magenta)
|
||||
|
||||
set -l ahead (_git_ahead)
|
||||
set -g whitespace ' '
|
||||
|
||||
if test $last_status = 0
|
||||
set initial_indicator "$green◆"
|
||||
set status_indicator "$normal❯$cyan❯$green❯"
|
||||
else
|
||||
set initial_indicator "$red✖ $last_status"
|
||||
set status_indicator "$red❯$red❯$red❯"
|
||||
end
|
||||
set -l cwd $cyan(basename (prompt_pwd))
|
||||
|
||||
if [ (_git_branch_name) ]
|
||||
if test (_git_branch_name) = 'master'
|
||||
set -l git_branch (_git_branch_name)
|
||||
set git_info "$normal git:($red$git_branch$normal)"
|
||||
else
|
||||
set -l git_branch (_git_branch_name)
|
||||
set git_info "$normal git:($blue$git_branch$normal)"
|
||||
end
|
||||
if [ (_is_git_dirty) ]
|
||||
set -l dirty "$yellow ✗"
|
||||
set git_info "$git_info$dirty"
|
||||
end
|
||||
end
|
||||
# Notify if a command took more than 5 minutes
|
||||
if [ "$CMD_DURATION" -gt 300000 ]
|
||||
echo The last command took (math "$CMD_DURATION/1000") seconds.
|
||||
end
|
||||
|
||||
echo -n -s $initial_indicator $whitespace $cwd $git_info $whitespace $ahead $status_indicator $whitespace
|
||||
end
|
||||
|
||||
function _git_ahead
|
||||
set -l commits (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null)
|
||||
if [ $status != 0 ]
|
||||
return
|
||||
end
|
||||
set -l behind (count (for arg in $commits; echo $arg; end | grep '^<'))
|
||||
set -l ahead (count (for arg in $commits; echo $arg; end | grep -v '^<'))
|
||||
switch "$ahead $behind"
|
||||
case '' # no upstream
|
||||
case '0 0' # equal to upstream
|
||||
return
|
||||
case '* 0' # ahead of upstream
|
||||
echo "$blue↑$normal_c$ahead$whitespace"
|
||||
case '0 *' # behind upstream
|
||||
echo "$red↓$normal_c$behind$whitespace"
|
||||
case '*' # diverged from upstream
|
||||
echo "$blue↑$normal$ahead $red↓$normal_c$behind$whitespace"
|
||||
end
|
||||
end
|
||||
|
||||
function _git_branch_name
|
||||
echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
|
||||
end
|
||||
|
||||
function _is_git_dirty
|
||||
echo (command git status -s --ignore-submodules=dirty ^/dev/null)
|
||||
end
|
||||
|
||||
function fish_mode_prompt
|
||||
switch $fish_bind_mode
|
||||
case default
|
||||
set_color --bold red
|
||||
echo '(N) '
|
||||
case insert
|
||||
set_color --bold green
|
||||
echo '(I) '
|
||||
case replace_one
|
||||
set_color --bold green
|
||||
echo '(R) '
|
||||
case visual
|
||||
set_color --bold brmagenta
|
||||
echo '(V) '
|
||||
case '*'
|
||||
set_color --bold red
|
||||
echo '(?) '
|
||||
end
|
||||
set_color normal
|
||||
end
|
||||
### END OF PROMPT ###
|
||||
|
||||
|
||||
### DEFAULT EMACS MODE OR VI MODE ###
|
||||
### SET EITHER DEFAULT EMACS MODE OR VI MODE ###
|
||||
function fish_user_key_bindings
|
||||
# fish_default_key_bindings
|
||||
fish_vi_key_bindings
|
||||
end
|
||||
### END OF VI MODE ###
|
||||
|
||||
### AUTOCOMPLETE AND HIGHLIGHT COLORS ###
|
||||
set fish_color_normal brcyan
|
||||
set fish_color_autosuggestion '#7d7d7d'
|
||||
set fish_color_command brcyan
|
||||
set fish_color_error '#ff6c6b'
|
||||
set fish_color_param brcyan
|
||||
|
||||
### SPARK ###
|
||||
set -g spark_version 1.0.0
|
||||
@@ -378,3 +290,6 @@ alias kakd="/usr/bin/kak -d -s mysession &"
|
||||
# Get this script from my GitLab: gitlab.com/dwt1/shell-color-scripts
|
||||
# Or install it from the Arch User Repository: shell-color-scripts
|
||||
colorscript random
|
||||
|
||||
### SETTING THE STARSHIP PROMPT ###
|
||||
starship init fish | source
|
||||
|
||||
Reference in New Issue
Block a user