Initial checkin

This commit is contained in:
2015-08-21 02:14:05 -07:00
commit d7ebb8e0d2
15 changed files with 395 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
function fish_prompt
# $status gets nuked as soon as something else is run, e.g. set_color
# so it has to be saved asap.
set -l last_status $status
fish_prompt_colors
# Clear the line because fish seems to emit the prompt twice. The initial
# display, then when you press enter.
# printf "\033[K"
# Current Directory
# 1st sed for colourising forward slashes
# 2nd sed for colourising the deepest path (the 'm' is the last char in the
# ANSI colour code that needs to be stripped)
printf $c1
printf (prompt_pwd | sed "s,/,$c0/$c1,g" | sed "s,\(.*\)/[^m]*m,\1/$c3,")
if test ! $last_status = "0"
printf $ce
else
printf $c4
end
printf " > "
printf $c4
end

View File

@@ -0,0 +1,10 @@
function fish_prompt_colors
# c0 to c4 progress from dark to bright
# ce is the error colour
set -g c0 (set_color 005284)
set -g c1 (set_color 0075cd)
set -g c2 (set_color 009eff)
set -g c3 (set_color 6dc7ff)
set -g c4 (set_color ffffff)
set -g ce (set_color $fish_color_error)
end

View File

@@ -0,0 +1,41 @@
# prints "ARG1:ARG2" with appropriate colors
function section
printf ", "
printf $c1
printf $argv[1]
printf $c0
printf ":"
printf $c3
printf $argv[2]
printf $c0
end
function machine_tag
hostname | cut -f1 -d. - | tr '[a-z]' '[A-Z]'
end
function fish_right_prompt
# Current time
printf $c0
printf "["
printf (date "+$c2%H$c0:$c2%M")
# Show last execution time
if test $CMD_DURATION
if test $CMD_DURATION -gt (math "1000 * 2")
set secs (math "$CMD_DURATION / 1000")
section took {$secs}s
end
end
printf $c0
printf "]"
if set -q SSH_CLIENT
printf "["
printf $c1
printf (machine_tag)
printf $c0
printf "]"
end
end