dotfiles

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

commit 5193984918636719f823a8c9e1b576490dd76953
parent cd180f24d2330e6aa0f3e537bd9da516bed367cd
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 24 Jul 2023 20:54:52 +0200

Display battery percentage in prompt

Diffstat:
A.xdg/config/bash/bash_functions | 21+++++++++++++++++++++
M.xdg/config/bash/bashrc | 14+++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)

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/magaknuto/.dotfiles --work-tree=/home/magaknuto' +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"