diff --git a/bash/bash_aliases b/bash/bash_aliases index 21c39b915..99410cb9b 100644 --- a/bash/bash_aliases +++ b/bash/bash_aliases @@ -54,8 +54,8 @@ alias isdistrobox='[ -f "/run/.toolboxenv" ] && grep -oP "(?<=name=\")[^\";]+" / # Flag that the directory was just changed (used with prompt) alias cd='export DIRCHANGED="1"; cd' -if [ $(isdistrobox) ]; then - source $HOME/.dotfiles/bash/bash_aliases.distrobox +if [ "$(isdistrobox)" ]; then + source "$HOME/.dotfiles/bash/bash_aliases.distrobox" else - source $HOME/.dotfiles/bash/bash_aliases.host + source "$HOME/.dotfiles/bash/bash_aliases.host" fi diff --git a/bash/bash_aliases.distrobox b/bash/bash_aliases.distrobox index 22ecae3b0..e18dcec7b 100644 --- a/bash/bash_aliases.distrobox +++ b/bash/bash_aliases.distrobox @@ -1,2 +1,4 @@ +# vim: ft=sh + # Already in a toolbox alias toolbox="echo You are already in a toolbox" diff --git a/bash/bash_aliases.host b/bash/bash_aliases.host index c7ce7140c..40acd3f99 100644 --- a/bash/bash_aliases.host +++ b/bash/bash_aliases.host @@ -1,2 +1,4 @@ +# vim: ft=sh + # Script to restore toolbox after it was replaced with distrobox and removed the default 'toolbox' name alias toolbox="$HOME/scripts/toolbox.sh" diff --git a/bash/bash_login b/bash/bash_login index 5170b56a4..24879eb4a 100644 --- a/bash/bash_login +++ b/bash/bash_login @@ -1,9 +1,9 @@ -#!/bin/bash +# vim: ft=sh systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP # Load aliases -source ${HOME}/.dotfiles/bash/bash_aliases +source "${HOME}/.dotfiles/bash/bash_aliases" export LANG="C" export LC_ALL="C" @@ -22,12 +22,12 @@ export GDK_BACKEND="wayland" export DCONF=".config/dconf/user" # Suggest session start command if last session is not known -if [ ! -e ${HOME}/.spool/last_login_gui ]; then +if [ ! -e "${HOME}/.spool/last_login_gui" ]; then echo "Use 'startsway' or 'starti3' to launch a GUI" fi if [ -f "/run/.containerenv" ]; then - source $HOME/.dotfiles/bash/bash_login.distrobox + source "$HOME/.dotfiles/bash/bash_login.distrobox" else - source $HOME/.dotfiles/bash/bash_login.host + source "$HOME/.dotfiles/bash/bash_login.host" fi diff --git a/bash/bash_login.distrobox b/bash/bash_login.distrobox index e69de29bb..1760efb00 100644 --- a/bash/bash_login.distrobox +++ b/bash/bash_login.distrobox @@ -0,0 +1,2 @@ +# vim: ft=sh + diff --git a/bash/bash_login.host b/bash/bash_login.host index d96e2932a..0699ad4ba 100644 --- a/bash/bash_login.host +++ b/bash/bash_login.host @@ -1,15 +1,17 @@ -# Configure static SSH Agent -export SSH_AUTH_SOCK=$HOME/.spool/ssh-agent.sock +# vim: ft=sh + +## Configure static SSH Agent +export SSH_AUTH_SOCK="$HOME/.spool/ssh-agent.sock" if [ -e $SSH_AUTH_SOCK ]; then rm $SSH_AUTH_SOCK fi -if [ -e $HOME/.spool/ssh-agent.env ]; then - rm $HOME/.spool/ssh-agent.env +if [ -e "$HOME/.spool/ssh-agent.env "]; then + rm "$HOME/.spool/ssh-agent.env" fi if [[ "`pgrep ssh-agent`" ]]; then pkill ssh-agent fi -. $HOME/scripts/ssh-agent.sh +. "$HOME/scripts/ssh-agent.sh" # Static/predictable Sway socket -export SWAYSOCK=`sway --get-socketpath` +export SWAYSOCK="`sway --get-socketpath`" diff --git a/bash/bash_logout b/bash/bash_logout index 18cb6baf8..0b53b941e 100644 --- a/bash/bash_logout +++ b/bash/bash_logout @@ -1,7 +1,7 @@ # vim: ft=sh if [ -f "/run/.containerenv" ]; then - source $HOME/.dotfiles/bash/bash_logout.distrobox + source "$HOME/.dotfiles/bash/bash_logout.distrobox" else - source $HOME/.dotfiles/bash/bash_logout.host + source "$HOME/.dotfiles/bash/bash_logout.host" fi diff --git a/bash/bash_logout.distrobox b/bash/bash_logout.distrobox index e69de29bb..1760efb00 100644 --- a/bash/bash_logout.distrobox +++ b/bash/bash_logout.distrobox @@ -0,0 +1,2 @@ +# vim: ft=sh + diff --git a/bash/bash_logout.host b/bash/bash_logout.host index a3aea801e..b16ddab14 100644 --- a/bash/bash_logout.host +++ b/bash/bash_logout.host @@ -1,8 +1,10 @@ -if [ ! $SSH_TTY ]; then +# vim: ft=sh + +if [ ! "$SSH_TTY" ]; then # Remove socket files - rm $SSH_AUTH_SOCK - rm $HOME/.spool/ssh-agent.env - rm $SWAYSOCK + rm "$SSH_AUTH_SOCK" + rm "$HOME/.spool/ssh-agent.env" + rm "$SWAYSOCK" fi # when leaving the console clear the screen to increase privacy diff --git a/bash/bash_profile b/bash/bash_profile index d272491aa..f94d2b6d2 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -17,7 +17,7 @@ PERL_MB_OPT="--install_base \"${HOME}/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=${HOME}/perl5"; export PERL_MM_OPT; if [ -f "/run/.containerenv" ]; then - source $HOME/.dotfiles/bash/bash_profile.distrobox + source "$HOME/.dotfiles/bash/bash_profile.distrobox" else - source $HOME/.dotfiles/bash/bash_profile.host + source "$HOME/.dotfiles/bash/bash_profile.host" fi diff --git a/bash/bash_profile.host b/bash/bash_profile.host index e69de29bb..1760efb00 100644 --- a/bash/bash_profile.host +++ b/bash/bash_profile.host @@ -0,0 +1,2 @@ +# vim: ft=sh + diff --git a/bash/bashrc b/bash/bashrc index 337656e8c..6566f2607 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -8,9 +8,9 @@ esac # agetty is set to automatically log me in on tty1 # Automatically launch GUI on tty1 after login -if [ "$(tty)" == '/dev/tty1' ] && [ ! $SSH_TTY ]; then - . ${HOME}/.dotfiles/bash/bash_login - LAST_GUI=`cat ${HOME}/.spool/last_login_gui 2>/dev/null` +if [ "$(tty)" == '/dev/tty1' ] && [ ! "$SSH_TTY" ]; then + . "${HOME}/.dotfiles/bash/bash_login" + LAST_GUI=$(cat "${HOME}/.spool/last_login_gui" 2>/dev/null) if [ -f "${HOME}/.spool/last_login_gui" ]; then ${HOME}/scripts/${LAST_GUI}/start${LAST_GUI}.sh fi @@ -51,7 +51,7 @@ PROMPT_COMMAND="$PROMPT_COMMAND;printf \"\a\"; history -a" # Enable color support if possible if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + test -r ${HOME}/.dircolors && eval "$(dircolors -b ${HOME}/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias dir='dir --color=auto' alias vdir='vdir --color=auto' @@ -62,16 +62,16 @@ if [ -x /usr/bin/dircolors ]; then fi # Load aliases -if [ -f ~/.dotfiles/bash/bash_aliases ]; then - . ~/.dotfiles/bash/bash_aliases +if [ -f ${HOME}/.dotfiles/bash/bash_aliases ]; then + . "${HOME}/.dotfiles/bash/bash_aliases" fi # Add snaps and flatpaks to path #export XDG_DATA_DIRS="$XDG_DATA_DIRS:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/var/lib/flatpak/exports/share" # Perl configs -PERL5LIB="${HOME}/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; -PERL_LOCAL_LIB_ROOT="${HOME}/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; +PERL5LIB="${HOME}/perl5/lib/perl5:${HOME}/perl5/lib/perl5/x86_64-linux-thread-multi:${PERL5LIB}"; export PERL5LIB; +PERL_LOCAL_LIB_ROOT="${HOME}/perl5/lib/perl5:${HOME}/perl5/lib/perl5/x86_64-linux-thread-multi:${PERL_LOCAL_LIB_ROOT}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"${HOME}/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=${HOME}/perl5"; export PERL_MM_OPT; @@ -94,9 +94,9 @@ export TERM="xterm" echo -e -n "\033]2;Welcome to Bash\007" if [ -f "/run/.containerenv" ]; then - source $HOME/.dotfiles/bash/bashrc.distrobox + source "$HOME/.dotfiles/bash/bashrc.distrobox" else - source $HOME/.dotfiles/bash/bashrc.host + source "$HOME/.dotfiles/bash/bashrc.host" fi source "$HOME/.cargo/env" diff --git a/bash/bashrc.distrobox b/bash/bashrc.distrobox index fbbd52196..cdf0fe2e9 100644 --- a/bash/bashrc.distrobox +++ b/bash/bashrc.distrobox @@ -1,3 +1,5 @@ -export DISTROBOX=`grep -oP "(?<=name=\")[^\";]+" /run/.containerenv` -HISTFILE=${HISTFILE}.$DISTROBOX +# vim: ft=sh + +export DISTROBOX=$(grep -oP "(?<=name=\")[^\";]+" /run/.containerenv) +HISTFILE="${HISTFILE}.$DISTROBOX" neofetch diff --git a/bash/bashrc.host b/bash/bashrc.host index 5b71d683e..9eeb9f536 100644 --- a/bash/bashrc.host +++ b/bash/bashrc.host @@ -1,10 +1,12 @@ +# vim: ft=sh + export SSH_AUTH_SOCK="$HOME/.spool/ssh-agent.sock" -if [ -z $SSH_AGENT_PID ]; then +if [ -z "$SSH_AGENT_PID" ]; then if [ -f "$HOME/.spool/ssh-agent.env" ]; then - source $HOME/.spool/ssh-agent.env >/dev/null + source "$HOME/.spool/ssh-agent.env" >/dev/null else - if [ ! -f $SSH_AUTH_SOCK ]; then - touch $SSH_AUTH_SOCK + if [ ! -f "$SSH_AUTH_SOCK" ]; then + touch "$SSH_AUTH_SOCK" fi $HOME/scripts/ssh-agent.sh fi diff --git a/bash/path b/bash/path index b6985dca0..e1ba5ed40 100644 --- a/bash/path +++ b/bash/path @@ -1,3 +1,5 @@ +# vim: ft=sh + # Local user bin if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" @@ -32,9 +34,9 @@ fi PATH="${HOME}/perl5/bin:$PATH" if [ -f "/run/.containerenv" ]; then - source $HOME/.dotfiles/bash/path.distrobox + source "$HOME/.dotfiles/bash/path.distrobox" else - source $HOME/.dotfiles/bash/path.host + source "$HOME/.dotfiles/bash/path.host" fi # Rust diff --git a/bash/path.distrobox b/bash/path.distrobox index e69de29bb..1834ba74c 100644 --- a/bash/path.distrobox +++ b/bash/path.distrobox @@ -0,0 +1 @@ +# vim: ft=sh diff --git a/bash/path.host b/bash/path.host index 2de2b139e..11ec60ea5 100644 --- a/bash/path.host +++ b/bash/path.host @@ -1,5 +1,7 @@ -for i in `find $HOME/scripts/distrobox -maxdepth 1`; do - if [ -d $i ]; then +# vim: ft=sh + +for i in $(find $HOME/scripts/distrobox -maxdepth 1); do + if [ -d "$i" ]; then PATH="$i:$PATH" fi done diff --git a/bash/prompt.sh b/bash/prompt.sh index 984421832..b071c9b14 100755 --- a/bash/prompt.sh +++ b/bash/prompt.sh @@ -10,9 +10,9 @@ elif [[ $ARG != '' ]]; then fi # If directory was just changed to the root of a git repository, print onefetch -if [ ! -z $DIRCHANGED ]; then - if [ -d $PWD/.git ]; then - $HOME/bin/onefetch +if [ -n "$DIRCHANGED" ]; then + if [ -d "$PWD/.git" ]; then + ${HOME}/bin/onefetch fi unset DIRCHANGED fi @@ -53,10 +53,10 @@ declare -A COLOURS='( # Get current git branch function parse_git_branch() { - BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` + BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') if [ ! "${BRANCH}" == "" ] then - STAT=`parse_git_dirty` + STAT=$(parse_git_dirty) echo "${COLOURS[\"$GC\",\"PS\"]}(${BRANCH}${STAT})${COLOURS[\"0\",\"PS\"]}" else echo "" @@ -65,13 +65,13 @@ function parse_git_branch() { # Get git status function parse_git_dirty { - status=`git status 2>&1 | tee` - dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"` - untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"` - ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"` - newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"` - renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"` - deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"` + status=$(git status 2>&1 | tee) + dirty=$(echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?") + untracked=$(echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?") + ahead=$(echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?") + newfile=$(echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?") + renamed=$(echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?") + deleted=$(echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?") bits='' if [ "${renamed}" == "0" ]; then bits=">${bits}" @@ -116,9 +116,9 @@ if [[ $ARG == '-h' ]]; then fi # Python venv -if [ $VIRTUAL_ENV ]; then +if [ "$VIRTUAL_ENV" ]; then VENV="${VIRTUAL_ENV##*/}" - VENV=`echo $VENV | sed -r 's/.*/[\0]/'` + VENV=$(echo "$VENV" | sed -r 's/.*/[\0]/') PS1="${PS1}${COLOURS["$EC","PS"]}${VENV} " if [[ $ARG == '-h' ]]; then setterm --foreground ${COLOURS["$EC","SET"]}; echo "venv"; setterm --foreground default @@ -134,7 +134,7 @@ if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then fi # User -if [[ `whoami` == 'root' ]]; then +if [[ $(whoami) == 'root' ]]; then UC=$RC fi PS1="${PS1}${COLOURS["$UC","PS"]}\\u" @@ -179,4 +179,4 @@ fi # \n - start input on new line, again to support copy-paste into bash script PS1="${PS1}${COLOURS["$PC","PS"]}\\n" -export PS1=$PS1 +export PS1