2017-11-15 14:37:19 +00:00
|
|
|
####################################
|
|
|
|
# Jessie Hildebrandt's Fish Config #
|
|
|
|
####################################
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Setting Variables #
|
|
|
|
#####################
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
set __fish_git_prompt_show_informative_status true
|
2017-11-15 14:37:19 +00:00
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
set fish_greeting "Hello, commander."
|
2017-11-15 14:37:19 +00:00
|
|
|
set fish_key_bindings fish_default_key_bindings
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
set VIRTUAL_ENV_DISABLE_PROMPT true
|
|
|
|
|
2019-10-29 21:55:03 +00:00
|
|
|
####################
|
|
|
|
# Battery Function #
|
|
|
|
####################
|
|
|
|
|
|
|
|
function battery --description 'Display the current status of the battery'
|
|
|
|
|
|
|
|
#################
|
|
|
|
# Local variables
|
|
|
|
|
|
|
|
set -l battery_file /sys/class/power_supply/BAT0/capacity
|
|
|
|
|
|
|
|
set -l normal (set_color normal)
|
|
|
|
set -l yellow (set_color bryellow)
|
|
|
|
set -l orange (set_color yellow)
|
|
|
|
set -l blue (set_color brblue)
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# ACPI battery status
|
|
|
|
|
|
|
|
if type acpi > /dev/null
|
|
|
|
set -l battery_str (acpi | cut -d "," -f 2- | string trim)
|
|
|
|
set battery_str (string replace -r '([[:digit:]]{1,3}%), (.*)$' "$yellow\$1$normal $orange(\$2)$normal" $battery_str)
|
|
|
|
printf "%s" $blue "Remaining battery:$normal " $battery_str
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
#########################
|
|
|
|
# Fallback battery status
|
|
|
|
|
|
|
|
if test -f $battery_file
|
|
|
|
printf "%s" $blue "Remaining battery:$normal " $yellow (cat $battery_file) "%$normal"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Unsupported battery
|
|
|
|
|
|
|
|
printf "%s" $blue "No battery detected.$normal"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2019-10-29 00:12:52 +00:00
|
|
|
##################
|
|
|
|
# Title Function #
|
|
|
|
##################
|
|
|
|
|
|
|
|
function fish_title --description 'Print the title of the window'
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
# Trying to set the title inside of Emacs will break it
|
2019-10-29 00:12:52 +00:00
|
|
|
if set -q INSIDE_EMACS
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# Set title to the command status + working directory
|
|
|
|
echo (status current-command) (__fish_pwd)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2017-11-15 14:37:19 +00:00
|
|
|
###################
|
|
|
|
# Prompt Function #
|
|
|
|
###################
|
|
|
|
|
|
|
|
function fish_prompt --description 'Write out the prompt'
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
####################
|
|
|
|
# Exit Status
|
|
|
|
|
|
|
|
# Cache the exit status of the last command
|
2018-05-05 02:08:29 +00:00
|
|
|
set -l last_status $status
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
##################
|
|
|
|
# Global Variables
|
|
|
|
|
|
|
|
# Format host name variable if not yet set
|
|
|
|
if not set -q __fish_prompt_hostname
|
|
|
|
set -g __fish_prompt_hostname (prompt_hostname)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Format prompt character variable if not yet set
|
|
|
|
if not set -q __fish_prompt_char
|
|
|
|
switch (id -u)
|
|
|
|
case 0
|
|
|
|
# Root
|
|
|
|
set -g __fish_prompt_char "#"
|
|
|
|
case '*'
|
|
|
|
# Everyone else
|
|
|
|
set -g __fish_prompt_char ">"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#################
|
|
|
|
# Local Variables
|
|
|
|
|
|
|
|
set -l normal (set_color normal)
|
|
|
|
set -l white (set_color brwhite)
|
|
|
|
set -l yellow (set_color ffeb3b bryellow)
|
|
|
|
set -l cyan (set_color 62d7ff brcyan)
|
|
|
|
set -l magenta (set_color f358dc brmagenta)
|
2019-10-29 21:55:03 +00:00
|
|
|
set -l gray (set_color 5e5e5e brblack)
|
|
|
|
set -l darkgray (set_color 3b3b3b brblack)
|
2019-10-29 07:30:07 +00:00
|
|
|
set -l red (set_color f44336 brred)
|
|
|
|
|
|
|
|
#############
|
|
|
|
# SSH Segment
|
2018-05-05 02:08:29 +00:00
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
set -l ssh_seg ""
|
2018-05-05 02:25:53 +00:00
|
|
|
if test -n "$SSH_CONNECTION"
|
2019-10-29 07:30:07 +00:00
|
|
|
set ssh_seg "$white[ssh]$normal "
|
2018-05-05 02:25:53 +00:00
|
|
|
end
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
#############################
|
|
|
|
# Virtual Environment Segment
|
|
|
|
|
|
|
|
set -l venv_seg ""
|
|
|
|
if test -n "$VIRTUAL_ENV"
|
|
|
|
set venv_seg "$gray(" (basename $VIRTUAL_ENV) ")$normal "
|
|
|
|
end
|
|
|
|
|
|
|
|
#################
|
|
|
|
# User@Host Segment
|
2018-05-05 02:08:29 +00:00
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
set -l user_host_seg "$cyan$USER$normal at $magenta$__fish_prompt_hostname$normal "
|
2018-05-05 02:08:29 +00:00
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
###########################
|
|
|
|
# Working Directory (PWD) Segment
|
2018-05-05 02:08:29 +00:00
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
set -g fish_prompt_pwd_dir_length 1
|
|
|
|
set -l pwd_seg "in $gray" (prompt_pwd)
|
|
|
|
set pwd_seg (string replace -ar '(.+/)([^/]*$)' "$darkgray\$1$gray\$2$normal" $pwd_seg)
|
2018-05-05 02:08:29 +00:00
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
####################
|
|
|
|
# VCS Status Segment
|
|
|
|
|
|
|
|
set -l vcs_seg (__fish_vcs_prompt) ""
|
|
|
|
|
|
|
|
##################
|
|
|
|
# Prompt Character
|
|
|
|
|
|
|
|
set -l prompt_char "$cyan$__fish_prompt_char$normal "
|
2018-05-05 02:08:29 +00:00
|
|
|
if test $last_status -ne 0
|
2019-10-29 07:30:07 +00:00
|
|
|
set prompt_char "$red$__fish_prompt_char$normal "
|
2018-05-05 02:08:29 +00:00
|
|
|
end
|
|
|
|
|
2019-10-29 07:30:07 +00:00
|
|
|
#########
|
|
|
|
# Output
|
|
|
|
|
|
|
|
printf "\n"
|
2019-10-29 21:55:03 +00:00
|
|
|
printf "%s" $venv_seg $ssh_seg $user_host_seg $pwd_seg $vcs_seg
|
2019-10-29 07:30:07 +00:00
|
|
|
printf "\n%s" $prompt_char
|
2017-11-15 14:37:19 +00:00
|
|
|
|
2018-02-04 07:26:27 +00:00
|
|
|
end
|