Starship Shell Prompt
- Add starship shell prompt to bash and fish shells - Add config file for starship prompt
This commit is contained in:
16
.bashrc
16
.bashrc
@@ -68,8 +68,8 @@ case "$TERM" in
|
|||||||
xterm* | rxvt*)
|
xterm* | rxvt*)
|
||||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||||
;;
|
;;
|
||||||
*)
|
*) ;;
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# enable color support of ls and also add handy aliases
|
# enable color support of ls and also add handy aliases
|
||||||
@@ -116,15 +116,6 @@ if ! shopt -oq posix; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Powerline Shell
|
|
||||||
function _update_ps1() {
|
|
||||||
PS1=$(powerline-shell $?)
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
|
|
||||||
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run neofetch when opening terminal
|
# Run neofetch when opening terminal
|
||||||
neofetch
|
neofetch
|
||||||
|
|
||||||
@@ -134,3 +125,6 @@ alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
|||||||
# EXPORTS
|
# EXPORTS
|
||||||
export EDITOR="code -w"
|
export EDITOR="code -w"
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
|
|
||||||
|
# Starship Prompt
|
||||||
|
eval "$(starship init bash)"
|
||||||
|
@@ -47,73 +47,5 @@ alias config="GIT_WORK_TREE=~ GIT_DIR=~/.cfg"
|
|||||||
###############
|
###############
|
||||||
# FISH PROMPT #
|
# FISH PROMPT #
|
||||||
###############
|
###############
|
||||||
# This was the 'sashimi' prompt from oh-my-fish.
|
# Starship Prompt
|
||||||
function fish_prompt
|
starship init fish | source
|
||||||
set -l last_status $status
|
|
||||||
set -l cyan (set_color -o $fish_color_command)
|
|
||||||
set -l yellow (set_color -o $fish_color_quote)
|
|
||||||
set -g red (set_color -o $fish_color_error)
|
|
||||||
set -g purple (set_color -o $fish_color_param)
|
|
||||||
set -l green (set_color -o $fish_color_operator)
|
|
||||||
set -g normal (set_color -o $fish_color_escape)
|
|
||||||
|
|
||||||
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(prompt_pwd)
|
|
||||||
|
|
||||||
if [ (_git_branch_name) ]
|
|
||||||
if test (_git_branch_name) = 'master' || test (_git_branch_name) = 'main'
|
|
||||||
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:($purple$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 "$purple↑$normal_c$ahead$whitespace"
|
|
||||||
case '0 *' # behind upstream
|
|
||||||
echo "$red↓$normal_c$behind$whitespace"
|
|
||||||
case '*' # diverged from upstream
|
|
||||||
echo "$purple↑$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
|
|
||||||
|
98
.config/starship.toml
Normal file
98
.config/starship.toml
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# ~/.config/starship.toml
|
||||||
|
|
||||||
|
# Don't print a new line at the start of the prompt
|
||||||
|
add_newline = false
|
||||||
|
|
||||||
|
format = "[◆](bold green) $all"
|
||||||
|
|
||||||
|
[aws]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[battery]
|
||||||
|
full_symbol = ""
|
||||||
|
charging_symbol = ""
|
||||||
|
discharging_symbol = ""
|
||||||
|
|
||||||
|
[character]
|
||||||
|
format = "$symbol"
|
||||||
|
success_symbol = "[❯](bold purple)[❯](bold cyan)[❯](bold green) "
|
||||||
|
error_symbol = "[❯❯❯](bold red) "
|
||||||
|
|
||||||
|
[cmd_duration]
|
||||||
|
min_time = 10_000
|
||||||
|
|
||||||
|
[conda]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[dart]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[directory]
|
||||||
|
format = "[$path]($style)[$read_only]($read_only_style) "
|
||||||
|
truncation_length = 4
|
||||||
|
truncate_to_repo = false
|
||||||
|
truncation_symbol = "…/"
|
||||||
|
read_only = ""
|
||||||
|
|
||||||
|
[docker]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[elixir]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[elm]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[git_branch]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[golang]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[haskell]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[hg_branch]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[java]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[julia]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[line_break]
|
||||||
|
disabled = true
|
||||||
|
|
||||||
|
[memory_usage]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[nim]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[nix_shell]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[nodejs]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[package]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[perl]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[php]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[python]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[ruby]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[rust]
|
||||||
|
symbol = " "
|
||||||
|
|
||||||
|
[swift]
|
||||||
|
symbol = "ﯣ "
|
Reference in New Issue
Block a user