dotfiles

Clean dotfiles
git clone git://git.dimitrijedobrota.com/dotfiles.git
Log | Files | Refs |

commit14cc4f66ec85a04247a095825f3ac9c6cc24073d
parent746bc7f9bd256e72c7d406743c16526b0bed22db
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateMon, 24 Jul 2023 18:54:52 +0200

Display battery percentage in prompt

Diffstat:
A.xdg/config/bash/bash_functions|+++++++++++++++++++++
M.xdg/config/bash/bashrc|+++++++++++++-

2 files changed, 34 insertions(+), 1 deletions(-)


diff --git a/.xdg/config/bash/bash_functions b/.xdg/config/bash/bash_functions

@@ -0,0 +1,21 @@

#
# ${XDG_CONFIG_HOME}/bash/bash_functions
#
battery_status(){
BATTERY=/sys/class/power_supply/BAT0
CHARGE=$(cat ${BATTERY}/capacity)
COLOUR="$RED"
[ "$CHARGE" -gt "99" ] && CHARGE=100
[ "$CHARGE" -gt "15" ] && COLOUR=$YELLOW
[ "$CHARGE" -gt "30" ] && COLOUR=$GREEN
echo -e "${COLOUR}${CHARGE}%$NORMAL"
}
export NORMAL="\[\e[0m\]"
export BOLD="\[\e[1m\]"
export RED="\[\e[1;31m\]"
export GREEN="\[\e[1;32m\]"
export YELLOW="\[\e[1;33m\]"

diff --git a/.xdg/config/bash/bashrc b/.xdg/config/bash/bashrc

@@ -5,9 +5,21 @@

# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Source functions if exist
function_file=${XDG_CONFIG_HOME}/bash/bash_functions
[[ -f "$function_file" ]] && source "$function_file"
unset function_file
# Dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
complete -F __git_wrap__git_main dotfiles
# Aliases
alias wget='wget --hsts-file="$XDG_CONFIG_HOME/wget-hsts"'
# Variables
export GPG_TTY=$(tty)
export MAKEFLAGS="-j8"
export GPG_TTY=$(tty)
# Customization
PS1="$(battery_status) | $GREEN\u [ $NORMAL\w$GREEN ]$ $NORMAL"