mirror of
https://github.com/VectorKappa/dotfiles.git
synced 2025-12-19 08:16:10 +01:00
1.0.0 - Remade structure for GNU Stow
This commit is contained in:
42
bash/.bash_prompt
Normal file
42
bash/.bash_prompt
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
prompt_git_and_status() {
|
||||
local ps1_exit=$?
|
||||
local s='';
|
||||
local branchName='';
|
||||
|
||||
if [ $ps1_exit -eq 0 ]; then
|
||||
ps1_status="${3}"
|
||||
else
|
||||
ps1_status="${4}"
|
||||
fi
|
||||
|
||||
# Check if the current directory is in a Git repository.
|
||||
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then
|
||||
|
||||
dirty=$(git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ]&& echo -e "*")
|
||||
branchName=`git symbolic-ref -q --short HEAD`
|
||||
|
||||
printf "%s" "${1}${branchName}${2}${dirty} "
|
||||
fi;
|
||||
printf "%s" "${ps1_status}\$"
|
||||
}
|
||||
|
||||
# Set the terminal title to the current working directory.
|
||||
PS1="\[\033]0;\W\007\]"; # working directory base name
|
||||
#PS1+="\[${bold}\]";
|
||||
#PS1+="\[${userStyle}\]\u"; # username
|
||||
#PS1+="\[${white}\]@";
|
||||
#PS1+="\[${hostStyle}\]\h"; # host
|
||||
#PS1+="\[${white}\] : ";
|
||||
PS1+="\[${green}\]\w"; # working directory full path
|
||||
PS1+="\$(prompt_git_and_status \"\[${white}\] on \[${violet}\]\" \"\[${blue}\]\" \"\[${white}\]\" \"\[${red}\]\")"; # Git repository details and $
|
||||
PS1+=" \[${reset}\]"; # and reset color
|
||||
export PS1;
|
||||
|
||||
PS2="\[${yellow}\]→ \[${reset}\]";
|
||||
export PS2;
|
||||
|
||||
# hack: fix slow startup of mc
|
||||
alias mc="PS1= PROMPT_COMMAND= mc"
|
||||
Reference in New Issue
Block a user