From 11aa32387ed4045b22f9f0e552904668a44d8013 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sun, 16 Jan 2022 12:56:16 -0800 Subject: [PATCH] alias/general: `shellcheck` --- aliases/available/general.aliases.bash | 27 +++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index f03ccb1c..fddd6a73 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -1,10 +1,9 @@ -cite about-alias +# shellcheck shell=bash about-alias 'general aliases' -if ls --color -d . &> /dev/null; then +if command ls --color -d . &> /dev/null; then alias ls="ls --color=auto" -elif ls -G -d . &> /dev/null; then - alias ls='ls -G' # Compact view, show colors + # BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set. fi # List directory contents @@ -18,13 +17,13 @@ alias lf='ls -F' alias _="sudo" # Shortcuts to edit startup files -alias vbrc="vim ~/.bashrc" -alias vbpf="vim ~/.bash_profile" +alias vbrc="${VISUAL:-vim} ~/.bashrc" +alias vbpf="${VISUAL:-vim} ~/.bash_profile" # colored grep # Need to check an existing file for a pattern that will be found to ensure # that the check works when on an OS that supports the color option -if grep --color=auto "a" "${BASH_IT}/"*.md &> /dev/null; then +if command grep --color=auto "a" "${BASH_IT?}"/*.md &> /dev/null; then alias grep='grep --color=auto' fi @@ -36,12 +35,12 @@ alias c='clear' alias k='clear' alias cls='clear' -alias edit="$EDITOR" -alias pager="$PAGER" +alias edit='${EDITOR:-${ALTERNATE_EDITOR?}}' +alias pager='${PAGER:=less}' alias q='exit' -alias irc="${IRC_CLIENT:=irc}" +alias irc='${IRC_CLIENT:=irc}' # Language aliases alias rb='ruby' @@ -74,13 +73,13 @@ alias rd='rmdir' alias xt="extract" # sudo editors -alias svim="sudo vim" +alias svim="sudo ${VISUAL:-vim}" alias snano="sudo nano" # Display whatever file is regular file or folder -catt() { +function catt() { for i in "$@"; do - if [ -d "$i" ]; then + if [[ -d "$i" ]]; then ls "$i" else cat "$i" @@ -94,5 +93,5 @@ catt() { # aliases and enable just the ones for Bash-it explicitly: # bash-it disable alias general # bash-it enable alias bash-it -# shellcheck source=./bash-it.aliases.bash +# shellcheck source-path=SCRIPTDIR source "$BASH_IT/aliases/available/bash-it.aliases.bash"