diff --git a/files/git/.config/git/shell/description b/files/git/.config/git/shell/description index 7fe02ec..c5aae29 100755 --- a/files/git/.config/git/shell/description +++ b/files/git/.config/git/shell/description @@ -38,4 +38,4 @@ fi description="$(printf '%s\n' "$3" | cut -c 1-80)" test_description description "${description}" -printf '%s\n' "${description}" | tee "${description_file}" +printf '%s\n' "${description}" | tee -- "${description_file}" diff --git a/files/sh/.config/bash/bashrc b/files/sh/.config/bash/bashrc index 03be5ab..022e466 100644 --- a/files/sh/.config/bash/bashrc +++ b/files/sh/.config/bash/bashrc @@ -43,7 +43,11 @@ _reset_line() { esac ## Credit: Can't find the source, posted on StackExchange or alike. ## Does not work well on Bash 5.0 and older. - bash_version_clean="$(printf '%s\n' "${BASH_VERSION%.*}" | tr -d ".")" + bash_version_clean="${BASH_VERSION%.*}" + bash_version_clean="${bash_version_clean//\./}" + if [[ ! ${bash_version_clean} =~ ^[0-9]+$ ]]; then + return + fi if test "${bash_version_clean}" -lt 51; then unset bash_version_clean return @@ -76,6 +80,7 @@ _print_ec(){ else printf '%s' "(${_ec_ps1})" fi + unset _ec_ps1 } _save_ec() { _ec_ps1=$?; } @@ -119,7 +124,7 @@ if ! shopt -oq posix; then source_readable /usr/share/bash-completion/bash_completion fi -unset newline ps1_symbol +unset newline ps1_symbol dircolor reset_color usercolor ## }}} ## {{{ Plugins if has zoxide; then diff --git a/files/sh/.config/sh/profile b/files/sh/.config/sh/profile index ea3a508..1a21056 100644 --- a/files/sh/.config/sh/profile +++ b/files/sh/.config/sh/profile @@ -10,7 +10,7 @@ # shellcheck disable=SC2312 : "${USER:=$(id -un || printf '%s' "${HOME##*/}")}" # shellcheck disable=SC2312 -: "${UID:=$(id -u || awk -F ":" -v user="${USER}" -- '/^user:/{print $3}' \ +: "${UID:=$(id -u || awk -F ":" -v user="${USER}" -- '$1 == user {print $3}' \ /etc/passwd)}" # shellcheck disable=SC2312 : "${HOSTNAME:=$(hostname)}" @@ -28,6 +28,7 @@ mkdir -p -- "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_DATA_HOME}" \ xdg_dirs="$(awk -- '/^[ ]*XDG_[A-Z]*_DIR=/{print "export " $1}' \ "${XDG_CONFIG_HOME}/user-dirs.dirs")" eval "${xdg_dirs}" +unset xdg_dirs ## Set directory to be used for coding. CODEDIR="${HOME}/src" @@ -156,7 +157,7 @@ if test -z "${SSH_AUTH_SOCK-}" && has ssh-agent; then ssh_agent_env="$(ssh-agent -s -a "${ssh_agent_sock}")" eval "${ssh_agent_env}" >/dev/null unset ssh_agent_env - printf '%s\n' "${SSH_AGENT_PID}" | tee "${ssh_agent_pid}" >/dev/null + printf '%s\n' "${SSH_AGENT_PID}" | tee -- "${ssh_agent_pid}" >/dev/null fi fi unset ssh_agent_dir ssh_agent_sock ssh_agent_pid @@ -170,6 +171,7 @@ for f in "${XDG_CONFIG_HOME}/sh/profile.d"/*.sh; do # shellcheck disable=SC1090,SC1091 ! test -r "${f}" || . "${f}" done +unset f ## Source local profile. # shellcheck disable=SC1090,SC1091 diff --git a/files/sh/.config/sh/shrc b/files/sh/.config/sh/shrc index 72fbe5b..f9be870 100644 --- a/files/sh/.config/sh/shrc +++ b/files/sh/.config/sh/shrc @@ -34,9 +34,10 @@ alias cp="cp -i" alias mv="mv -i" alias ls="ls -hF --group-directories-first --color=auto" if has lsblk; then - _lsblk_options="NAME,FSTYPE,LABEL,SIZE,FSAVAIL,FSUSE%,MOUNTPOINT" - alias lsblk='lsblk -o ${_lsblk_options}' - alias lsblku='lsblk -o ${_lsblk_options},UUID,PARTUUID' + lsblk_options="NAME,FSTYPE,LABEL,SIZE,FSAVAIL,FSUSE%,MOUNTPOINT" + alias lsblk='lsblk -o ${lsblk_options}' + alias lsblku='lsblk -o ${lsblk_options},UUID,PARTUUID' + unset lsblk_options fi if ! grep --color 2>&1 | grep -qE -e "(unrecognized|unknown) option" && ! grep --exclude 2>&1 | grep -qE -e "(unrecognized|unknown) option" @@ -110,7 +111,7 @@ has qubesctl && { alias qctlu="qctl --skip-dom0 --targets" qctlus(){ test -n "${2-}" || return 1 - qubesctl --skip-dom0 --targets "${1}" state.apply "${2}" + qubesctl --skip-dom0 --targets "${1}" state.apply "${@}" } } has gpg && alias gpgs="gpg --show-keys" @@ -124,9 +125,10 @@ has tmux && { alias tcl="clear && t clear-history" # clear buffer cus memory tcla(){ ## Clear all the panes of the current session. - for _t_pane in $(tmux list-panes -s -F '#{pane_id}'); do - tmux clear-history -t "${_t_pane}" + for t_pane in $(tmux list-panes -s -F '#{pane_id}'); do + tmux clear-history -t "${t_pane}" done + unset t_pane } } ## }}} @@ -149,7 +151,7 @@ then # shellcheck disable=SC2139,SC2140 alias "g${key}"="git ${key}" done - unset g_alias + unset key g_alias fi ## }}} ## }}} @@ -176,7 +178,7 @@ if test "${color_prompt-}" = "yes"; then if has dircolors; then ## Use dircolors if available. if test -r "${XDG_CONFIG_HOME}/dircolors/dircolors"; then - dircolors="$(dircolors -b "${XDG_CONFIG_HOME}/dircolors/dircolors")" + dircolors="$(dircolors -b -- "${XDG_CONFIG_HOME}/dircolors/dircolors")" eval "${dircolors}" else dircolors="$(dircolors -b)" @@ -223,9 +225,10 @@ fi _get_prompt_time(){ test -n "${SECONDS:-}" || return # shellcheck disable=SC2154 - _ptime="$((SECONDS-_saved_prompt_time))" + ptime="$((SECONDS-_saved_prompt_time))" printf '%02d:%02d:%02d' \ - "$((_ptime/3600))" "$(((_ptime%3600)/60))" "$((_ptime%60))" + "$((ptime/3600))" "$(((ptime%3600)/60))" "$((ptime%60))" + unset ptime } _git_prompt_info(){ @@ -247,13 +250,13 @@ _git_prompt_info(){ esac if test -n "${ZSH_VERSION-}"; then # shellcheck disable=2016 - if test "${color_prompt}" = "yes"; then + if test "${color_prompt-}" = "yes"; then print -Pn '(%%{${branchcolor}%%}%20>...>${ref}%<<%%{\033[0m%%})' else print -Pn '(%20>...>${ref}%<<)' fi else - if test "${color_prompt}" = "yes"; then + if test "${color_prompt-}" = "yes"; then printf '%s' "(${branchcolor}${ref}${reset_color})" else printf '%s' "(${ref})" @@ -303,6 +306,8 @@ if test "${color_prompt-}" = "yes"; then else PS1="${user}@$(hostname -s)${ps1_symbol} " fi + +unset user uid ## }}} ## {{{ External Functions @@ -313,6 +318,7 @@ source_readable(){ # shellcheck disable=SC1090 ! test -r "${_file}" || . "${_file}" done + unset _file } _fzf_comprun() { @@ -338,6 +344,7 @@ _fzf_comprun() { fzf --preview 'test -d {} || cat -- {}' "${@}" ;; esac + unset _fzf_command } ## }}} diff --git a/files/sh/.config/zsh/.zshrc b/files/sh/.config/zsh/.zshrc index c5d4545..da7682e 100644 --- a/files/sh/.config/zsh/.zshrc +++ b/files/sh/.config/zsh/.zshrc @@ -134,8 +134,8 @@ case "${TERM-}" in ;; esac -unset hostcolor hostletter hostcode dircolor usercolor usercode reset_color -unset newline +unset hostcolor hostletter hostcode dircolor usercolor usercode reset_color \ + newline ps1_symbol ## }}} ## {{{ Completions @@ -340,7 +340,7 @@ case "${TERM-}" in ""|dumb|linux*|vt100*|vt220*) ;; *) zle-keymap-select zle-line-init() { - case $KEYMAP in + case "${KEYMAP:-}" in vicmd) print -n -- "\033[2 q";; viins|main) print -n -- "\033[5 q";; esac diff --git a/files/sh/.local/bin/has b/files/sh/.local/bin/has index 4efe9e0..4a8498e 100755 --- a/files/sh/.local/bin/has +++ b/files/sh/.local/bin/has @@ -29,7 +29,7 @@ for prog in "${@}"; do test -x "${cmd}" || continue case "${action-}" in - show) printf '%s\n' "${cmd}"; exit 0;; + show) printf '%s\n' "${cmd}"; unset cmd; exit 0;; *) exit 0;; esac done diff --git a/files/x11/.config/x11/xprofile b/files/x11/.config/x11/xprofile index 7f74ce9..75a8f7f 100755 --- a/files/x11/.config/x11/xprofile +++ b/files/x11/.config/x11/xprofile @@ -19,7 +19,9 @@ fi ## If running normal OS or Qubes: Dom0, apply settings. # shellcheck disable=3028 hostname="${HOSTNAME:-$(hostname)}" -if ! command -v qubesdb-read >/dev/null || test "${hostname}" = "dom0"; then +if ! command -v qubesdb-read >/dev/null || test "${hostname}" = "dom0" || + test -f /var/run/qubes-service/guivm +then ## Decrease key repeat delay to X ms. ## Increase key repeat rate to Y per second. xset r rate 275 60 @@ -32,6 +34,7 @@ if ! command -v qubesdb-read >/dev/null || test "${hostname}" = "dom0"; then #qvm-prefs dom0 keyboard_layout "us+dvorak+grp:win_space_toggle,ctrl:nocaps" fi +unset hostname ## Autostart desktop applications if the WM does not. desktop_autostart(){ @@ -50,6 +53,7 @@ desktop_autostart(){ command -v "${autostart_exec%% *}" >/dev/null || continue ${autostart_exec} & done + unset f } ## Source Xorg profiles. @@ -59,6 +63,7 @@ if test -r "${HOME}/.xprofile.local"; then # shellcheck disable=SC1090,SC1091 ! test -r "${x11_profile}" || . "${x11_profile}" done + unset x11_profile fi : "${wm_list:="dwm"}" @@ -69,6 +74,7 @@ for wm in ${wm_list}; do while true; do xroot_name="$(display-statusbar)" xsetroot -name "${xroot_name}" + unset xroot_name sleep 60 done & fi @@ -76,5 +82,7 @@ for wm in ${wm_list}; do ${wm} & wm_pid="${!}" done +unset wm test -z "${wm_pid:-}" || wait "${wm_pid}" +unset wm_pid