Use starship prompt

This commit is contained in:
Phantop 2020-07-31 16:06:08 -04:00
parent 8fc9d9dd51
commit a0e142af87
7 changed files with 13 additions and 92 deletions

90
.bashrc
View File

@ -1,92 +1,4 @@
# Clean and minimalistic Bash prompt
# Author: Artem Sapegin, sapegin.me
#
# Inspired by: https://github.com/sindresorhus/pure & https://github.com/dreadatour/dotfiles/blob/master/.bash_profile
#
# Notes:
# - $local_username - username you dont want to see in the prompt - can be defined in ~/.bashlocal : `local_username="admin"`
# - Colors ($RED, $GREEN) - defined in ../tilde/bash_profile.bash
#
# User color
case $(id -u) in
0) user_color="$RED" ;; # root
*) user_color="$GREEN" ;;
esac
# Symbols
prompt_symbol=""
prompt_clean_symbol="☀ "
prompt_dirty_symbol="☂ "
prompt_venv_symbol="☁ "
function prompt_command() {
# Local or SSH session?
local remote=
[ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && remote=1
# Git branch name and work tree status (only when we are inside Git working tree)
local git_prompt=
if [[ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]]; then
# Branch name
local branch="$(git symbolic-ref HEAD 2>/dev/null)"
branch="${branch##refs/heads/}"
# Working tree status (red when dirty)
local dirty=
# Modified files
git diff --no-ext-diff --quiet --exit-code --ignore-submodules 2>/dev/null || dirty=1
# Untracked files
[ -z "$dirty" ] && test -n "$(git status --porcelain)" && dirty=1
# Format Git info
if [ -n "$dirty" ]; then
git_prompt=" $RED$prompt_dirty_symbol$branch$NOCOLOR"
else
git_prompt=" $GREEN$prompt_clean_symbol$branch$NOCOLOR"
fi
fi
# Virtualenv
local venv_prompt=
if [ -n "$VIRTUAL_ENV" ]; then
venv_prompt=" $BLUE$prompt_venv_symbol$(basename $VIRTUAL_ENV)$NOCOLOR"
fi
# Only show username if not default
local user_prompt=
[ "$USER" != "$local_username" ] && user_prompt="$user_color$USER$NOCOLOR"
# Show hostname inside SSH session
local host_prompt=
[ -n "$remote" ] && host_prompt="@$YELLOW$HOSTNAME$NOCOLOR"
# Show delimiter if user or host visible
local login_delimiter=
[ -n "$user_prompt" ] || [ -n "$host_prompt" ] && login_delimiter=":"
# Format prompt
first_line="$user_prompt$host_prompt$login_delimiter$WHITE\w$NOCOLOR$git_prompt$venv_prompt"
# Text (commands) inside \[...\] does not impact line length calculation which fixes stange bug when looking through the history
# $? is a status of last command, should be processed every time prompt prints
second_line="\`if [ \$? = 0 ]; then echo \[\$CYAN\]; else echo \[\$RED\]; fi\`\$prompt_symbol\[\$NOCOLOR\] "
PS1="\n$first_line\n$second_line"
# Multiline command
PS2="\[$CYAN\]$prompt_symbol\[$NOCOLOR\] "
# Terminal title
local title="$(basename "$PWD")"
[ -n "$remote" ] && title="$title \xE2\x80\x94 $HOSTNAME"
echo -ne "\033]0;$title"; echo -ne "\007"
}
# Show awesome prompt only if Git is istalled
command -v git >/dev/null 2>&1 && PROMPT_COMMAND=prompt_command
bind 'set show-all-if-ambiguous on'
bind 'TAB:menu-complete'
eval "$(starship init bash)"
# Sensible Bash - An attempt at saner Bash defaults
# Maintainer: mrzool <http://mrzool.cc>

View File

@ -4,7 +4,6 @@ fishd.*
functions/_*.fish
functions/bax.fish
functions/fish_greeting.fish
functions/fish_mode_prompt.fish
functions/fish_prompt.fish
functions/fish_title.fish

View File

@ -8,3 +8,5 @@ set -gx PAGER nvimpager
set -U Z_CMD "j"
set -x QT_QPA_PLATFORMTHEME gtk2
starship init fish | source

View File

@ -1,3 +1,2 @@
rafaelrinaldi/pure
jethrokuan/z
jorgebucaran/fish-bax

View File

@ -0,0 +1,4 @@
# Defined in /tmp/fish.hGIIv7/fish_greeting.fish @ line 2
function fish_greeting
end

@ -1 +1 @@
Subproject commit 682becf5b5115c2a206b4f0bdee413d4be8b5bef
Subproject commit 19b87cb42406112fec089c71b526a2ab46780002

5
.config/starship.toml Executable file
View File

@ -0,0 +1,5 @@
# Don't print a new line at the start of the prompt
add_newline = false
[git_branch]
symbol = ""