Tweak prompt. f switches fancy prompt
Add vera and tetralith hosts
This commit is contained in:
@@ -1,5 +1,51 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
format_modified_detailed() {
|
||||||
|
local txtrst='$(tput sgr0)'
|
||||||
|
local txtred='\e[0;31m'
|
||||||
|
local txtgrn='$(tput setaf 2)'
|
||||||
|
local txtyel='$(tput setaf 3)'
|
||||||
|
|
||||||
|
# Modified, staged and untracked
|
||||||
|
# A added (new file) M modified, D deleted, R renamed, T typechange
|
||||||
|
stat="$(git status --porcelain 2>/dev/null)"
|
||||||
|
n_sta=""
|
||||||
|
n_mod=""
|
||||||
|
for i in A M D R T; do
|
||||||
|
c=$(echo "$stat" | grep "^[$i]" | wc -l)
|
||||||
|
[ "$c" != "0" ] && n_sta="$n_sta$i$c"
|
||||||
|
c=$(echo "$stat" | grep "^ [$i]" | wc -l)
|
||||||
|
[ "$c" != "0" ] && n_mod="$n_mod$i$c"
|
||||||
|
done
|
||||||
|
n_unt=$(echo "$stat" | grep "??" | wc -l)
|
||||||
|
|
||||||
|
out=""
|
||||||
|
[ ! -z "$n_sta" ] && out+="\[$txtgrn\]+$n_sta\[$txtrst\]"
|
||||||
|
[ ! -z "$n_mod" ] && out+="\[$txtred\]*$n_mod\[$txtrst\]"
|
||||||
|
[ ! -z "$n_unt" ] && out+="\[$txtyel\]^$n_unt\[$txtrst\]"
|
||||||
|
echo "$out"
|
||||||
|
}
|
||||||
|
|
||||||
|
format_modified() {
|
||||||
|
local txtrst='$(tput sgr0)'
|
||||||
|
local txtred='\e[0;31m'
|
||||||
|
local txtgrn='$(tput setaf 2)'
|
||||||
|
local txtyel='$(tput setaf 3)'
|
||||||
|
|
||||||
|
# Modified, staged and untracked
|
||||||
|
# A added (new file) M modified, D deleted, R renamed, T typechange
|
||||||
|
stat="$(git status --porcelain 2>/dev/null)"
|
||||||
|
n_sta=$(echo "$stat" | grep "^[AMDRT]" | wc -l)
|
||||||
|
n_mod=$(echo "$stat" | grep "^ [AMDRT]" | wc -l)
|
||||||
|
n_unt=$(echo "$stat" | grep "??" | wc -l)
|
||||||
|
|
||||||
|
out=""
|
||||||
|
[ "$n_sta" != 0 ] && out+="\[$txtgrn\]+$n_sta\[$txtrst\]"
|
||||||
|
[ "$n_mod" != 0 ] && out+="\[$txtred\]*$n_mod\[$txtrst\]"
|
||||||
|
[ "$n_unt" != 0 ] && out+="\[$txtyel\]^$n_unt\[$txtrst\]"
|
||||||
|
echo "$out"
|
||||||
|
}
|
||||||
|
|
||||||
set_prompt_fancy()
|
set_prompt_fancy()
|
||||||
{
|
{
|
||||||
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
||||||
@@ -43,31 +89,12 @@ set_prompt_fancy()
|
|||||||
PS1+="\[$txtred\]$fancyx \[$txtwht\]($last_cmd)"
|
PS1+="\[$txtred\]$fancyx \[$txtwht\]($last_cmd)"
|
||||||
fi
|
fi
|
||||||
# Line 4: grn git branch
|
# Line 4: grn git branch
|
||||||
PS1+="\[$txtgrn\]$(__git_ps1 ' (%s)')\[$txtwht\]"
|
PS1+="\[$txtgrn\]$(__git_ps1 '(%s')\[$txtwht\]"
|
||||||
|
PS1+="$(format_modified_detailed)\[$txtgrn\])\[$txtrst\] "
|
||||||
# Line 4: good old prompt, $ for user, # for root
|
# Line 4: good old prompt, $ for user, # for root
|
||||||
PS1+=" \\$ "
|
PS1+=" \\$ "
|
||||||
}
|
}
|
||||||
|
|
||||||
format_modified() {
|
|
||||||
local txtrst='$(tput sgr0)'
|
|
||||||
local txtred='\e[0;31m'
|
|
||||||
local txtgrn='$(tput setaf 2)'
|
|
||||||
local txtyel='$(tput setaf 3)'
|
|
||||||
|
|
||||||
# Modified, staged and untracked
|
|
||||||
# A added (new file) M modified, D deleted, T typechange
|
|
||||||
stat="$(git status --porcelain 2>/dev/null)"
|
|
||||||
n_mod=$(echo "$stat" | grep "^ [AMDT]" | wc -l)
|
|
||||||
n_sta=$(echo "$stat" | grep "^[AMDT]" | wc -l)
|
|
||||||
n_unt=$(echo "$stat" | grep "??" | wc -l)
|
|
||||||
|
|
||||||
out=""
|
|
||||||
[ "$n_sta" != 0 ] && out+="\[$txtgrn\]+$n_sta\[$txtrst\]"
|
|
||||||
[ "$n_mod" != 0 ] && out+="\[$txtred\]*$n_mod\[$txtrst\]"
|
|
||||||
[ "$n_unt" != 0 ] && out+="\[$txtyel\]-$n_unt\[$txtrst\]"
|
|
||||||
echo "$out"
|
|
||||||
}
|
|
||||||
|
|
||||||
set_prompt()
|
set_prompt()
|
||||||
{
|
{
|
||||||
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
|
||||||
@@ -106,4 +133,15 @@ set_prompt()
|
|||||||
# Good old prompt, $ for user, # for root
|
# Good old prompt, $ for user, # for root
|
||||||
PS1+="\[$txtrst\]\\$ "
|
PS1+="\[$txtrst\]\\$ "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f() {
|
||||||
|
case $PROMPT_COMMAND in
|
||||||
|
set_prompt )
|
||||||
|
export PROMPT_COMMAND='set_prompt_fancy'
|
||||||
|
;;
|
||||||
|
set_prompt_fancy )
|
||||||
|
export PROMPT_COMMAND='set_prompt'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
export PROMPT_COMMAND='set_prompt'
|
export PROMPT_COMMAND='set_prompt'
|
||||||
|
|||||||
16
.ssh/config
16
.ssh/config
@@ -50,3 +50,19 @@ Host tegner
|
|||||||
GSSAPIKeyExchange yes
|
GSSAPIKeyExchange yes
|
||||||
GSSAPIDelegateCredentials yes
|
GSSAPIDelegateCredentials yes
|
||||||
PreferredAuthentications gssapi-keyex,gssapi-with-mic
|
PreferredAuthentications gssapi-keyex,gssapi-with-mic
|
||||||
|
|
||||||
|
Host vera
|
||||||
|
Hostname vera1.c3se.chalmers.se
|
||||||
|
User fojt
|
||||||
|
|
||||||
|
Host vera2
|
||||||
|
Hostname vera2.c3se.chalmers.se
|
||||||
|
User fojt
|
||||||
|
|
||||||
|
Host tetralith
|
||||||
|
Hostname tetralith1.nsc.liu.se
|
||||||
|
User x_jakfo
|
||||||
|
|
||||||
|
Host tetralith2
|
||||||
|
Hostname tetralith2.nsc.liu.se
|
||||||
|
User x_jakfo
|
||||||
|
|||||||
Reference in New Issue
Block a user