Created
January 31, 2017 12:20
-
-
Save plrenaudin/29b0b2dea2a5afae7cb4c5d508523ed1 to your computer and use it in GitHub Desktop.
Fish shell prompt variation with git support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://geraldkaszuba.com/tweaking-fish-shell/ for git branch support | |
function git_branch | |
set -g git_branch (git rev-parse --abbrev-ref HEAD ^ /dev/null) | |
if [ $status -ne 0 ] | |
set -ge git_branch | |
set -g git_dirty_count 0 | |
else | |
set -g git_dirty_count (git status --porcelain | wc -l | sed "s/ //g") | |
end | |
end | |
function fish_prompt | |
and set retc green; or set retc red | |
tty|string match -q -r tty; and set tty tty; or set tty pts | |
set_color $retc | |
if [ $tty = tty ] | |
echo -n .- | |
else | |
echo -n '┬─' | |
end | |
set_color -o green | |
echo -n [ | |
if test $USER = root -o $USER = toor | |
set_color -o red | |
else | |
set_color -o yellow | |
end | |
echo -n $USER | |
set_color -o white | |
echo -n @ | |
if [ -z "$SSH_CLIENT" ] | |
set_color -o blue | |
else | |
set_color -o cyan | |
end | |
echo -n (hostname) | |
set_color -o white | |
#echo -n :(prompt_pwd) | |
echo -n :(pwd|sed "s=$HOME=~=") | |
set_color -o green | |
echo -n ']' | |
set_color normal | |
set_color $retc | |
if [ $tty = tty ] | |
echo -n '-' | |
else | |
echo -n '─' | |
end | |
set_color -o green | |
git_branch | |
if set -q git_branch | |
echo -n '[' | |
if [ -z "$SSH_CLIENT" ] | |
set_color -o blue | |
else | |
set_color -o cyan | |
end | |
echo -n $git_branch | |
if test $git_dirty_count -gt 0 | |
set_color -o red | |
echo -n "$out$c0:$ce$git_dirty_count" | |
end | |
set_color -o green | |
echo -n ']' | |
set_color normal | |
set_color $retc | |
if [ $tty = tty ] | |
echo -n '-' | |
else | |
echo -n '─' | |
end | |
set_color -o green | |
end | |
echo -n '[' | |
set_color normal | |
set_color $retc | |
echo -n (date +%X) | |
set_color -o green | |
echo -n ] | |
if type -q acpi | |
if [ (acpi -a 2> /dev/null | string match -r off) ] | |
echo -n '─[' | |
set_color -o red | |
echo -n (acpi -b|cut -d' ' -f 4-) | |
set_color -o green | |
echo -n ']' | |
end | |
end | |
echo | |
set_color normal | |
for job in (jobs) | |
set_color $retc | |
if [ $tty = tty ] | |
echo -n '; ' | |
else | |
echo -n '│ ' | |
end | |
set_color brown | |
echo $job | |
end | |
set_color normal | |
set_color $retc | |
if [ $tty = tty ] | |
echo -n "'->" | |
else | |
echo -n '╰─>' | |
end | |
set_color -o red | |
echo -n '$ ' | |
set_color normal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment