diff options
author | EuAndreh <eu@euandre.org> | 2019-01-03 06:12:39 -0200 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-01-03 06:42:41 -0200 |
commit | b679e7d91f7af2d97bead966a17b715cdb020b1a (patch) | |
tree | 71926893088a93513971d950d5a19b012722fedf /bash | |
parent | Add custom nu gitconfig options in nugitconfig.ini file. (diff) | |
download | dotfiles-b679e7d91f7af2d97bead966a17b715cdb020b1a.tar.gz dotfiles-b679e7d91f7af2d97bead966a17b715cdb020b1a.tar.xz |
Fix shellcheck ofsenses on bash scripts.
Diffstat (limited to 'bash')
-rw-r--r-- | bash/agents.sh | 3 | ||||
-rw-r--r-- | bash/aliases.sh | 13 | ||||
-rw-r--r-- | bash/bash_profile.sh | 2 | ||||
-rw-r--r-- | bash/bashrc.sh | 5 | ||||
-rw-r--r-- | bash/colors.sh | 3 | ||||
-rw-r--r-- | bash/env.sh | 2 | ||||
-rw-r--r-- | bash/facepalm/rotten-apple.sh | 4 | ||||
-rw-r--r-- | bash/fake-symlinks.sh | 26 | ||||
-rw-r--r-- | bash/init.sh | 12 | ||||
-rw-r--r-- | bash/npm.sh | 4 | ||||
-rw-r--r-- | bash/platform.sh | 4 | ||||
-rw-r--r-- | bash/symlinks.sh | 80 | ||||
-rwxr-xr-x | bash/tmuxinator-templates.sh | 9 | ||||
-rw-r--r-- | bash/util.sh | 32 | ||||
-rw-r--r-- | bash/youtube.sh | 2 |
15 files changed, 105 insertions, 96 deletions
diff --git a/bash/agents.sh b/bash/agents.sh index 5dec196..d49757b 100644 --- a/bash/agents.sh +++ b/bash/agents.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2015 eval "$(thefuck --alias f)" @@ -11,13 +12,11 @@ start_agent() { ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" echo succeeded chmod 600 "${SSH_ENV}" - # shellcheck source=/dev/null . "${SSH_ENV}" > /dev/null ssh-add } [ -f "${SSH_ENV}" ] && { - # shellcheck source=/dev/null . "${SSH_ENV}" > /dev/null pgrep ^ssh-agent$ > /dev/null || { start_agent diff --git a/bash/aliases.sh b/bash/aliases.sh index 403709c..52d24b4 100644 --- a/bash/aliases.sh +++ b/bash/aliases.sh @@ -8,13 +8,14 @@ alias l="ls -lahp" alias ll="ls -lhp" alias yt-dl="yt_dl" isLinux && { - alias copy="tr -d '\n' | xclip -sel clip" + alias copy="tr -d '\\n' | xclip -sel clip" } isMac && { - alias copy="tr -d '\n' | pbcopy" + alias copy="tr -d '\\n' | pbcopy" } -alias trim="tr -d '\n'" -alias lower="tr [:upper:] [:lower:]" +alias trim="tr -d '\\n'" +alias lowercase="tr [:upper:] [:lower:]" +alias lc="tr [:upper:] [:lower:]" alias pia-vpn="sudo openvpn --config $DOTFILES/VPN/euandreh.ovpn" # Source: https://unix.stackexchange.com/questions/25327/watch-command-alias-expansion#25329 alias watch="watch --color " @@ -31,9 +32,9 @@ alias fim="play $DOTFILES/bash/Positive.ogg &> /dev/null" alias mux="tmuxinator" u() { - pushd ~/annex > /dev/null; + pushd ~/annex > /dev/null || exit 1; git annex info --fast | grep available; - popd > /dev/null; + popd > /dev/null || exit 1; } export -f u diff --git a/bash/bash_profile.sh b/bash/bash_profile.sh index 12ce7f9..41bc7e9 100644 --- a/bash/bash_profile.sh +++ b/bash/bash_profile.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + source ~/annex/dev/code/dotfiles/bash/bashrc.sh diff --git a/bash/bashrc.sh b/bash/bashrc.sh index d06692b..a895df1 100644 --- a/bash/bashrc.sh +++ b/bash/bashrc.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + export DOTFILES=~/annex/dev/code/dotfiles source $DOTFILES/bash/platform.sh @@ -10,7 +12,6 @@ source $DOTFILES/bash/agents.sh source $DOTFILES/bash/init.sh source $DOTFILES/bash/symlinks.sh source $DOTFILES/bash/youtube.sh -source $DOTFILES/bash/tmuxinator-templates.sh source $DOTFILES/bash/facepalm/rotten-apple.sh source $DOTFILES/bash/npm.sh source $DOTFILES/bash/x.sh @@ -28,7 +29,7 @@ export PATH="$HOME/annex/dev/code/songbooks/cli:$PATH" alias sb="songbooks" isLinux && { - source "$(dirname $(readlink $(which autojump)))/../share/autojump/autojump.bash" + source "$(dirname "$(readlink "$(command -v autojump)")")/../share/autojump/autojump.bash" } export PATH="$HOME/.perl6/bin:$PATH" diff --git a/bash/colors.sh b/bash/colors.sh index 90cabc4..68acb06 100644 --- a/bash/colors.sh +++ b/bash/colors.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=1117 disable=1004 disable=2034 disable=2154 # Customize BASH PS1 prompt to show current GIT repository and branch. # by Mike Stewart - http://MediaDoneRight.com @@ -208,7 +209,7 @@ function lightblueb { } export -f lightblueb -function ,colors { +function colors { black "black" blackb "blackb" white "white" diff --git a/bash/env.sh b/bash/env.sh index 8ac8a25..5a09663 100644 --- a/bash/env.sh +++ b/bash/env.sh @@ -33,7 +33,7 @@ export EDITOR=vi export PATH="$DOTFILES/scripts/:$PATH" export PATH="$DOTFILES/encrypted/scripts/:$PATH" export INPUTRC=~/.inputrc -export CACHE_DIR="~/Nextcloud/cache" +export CACHE_DIR="$HOME/Nextcloud/cache" export PATH="$HOME/dev/libre/website/:$PATH" diff --git a/bash/facepalm/rotten-apple.sh b/bash/facepalm/rotten-apple.sh index 50d85c8..222a2b0 100644 --- a/bash/facepalm/rotten-apple.sh +++ b/bash/facepalm/rotten-apple.sh @@ -6,8 +6,8 @@ isMac && { alias limpar-derived-data="rm -rf ~/Library/Developer/Xcode/DerivedData/" alias fim="afplay $DOTFILES/bash/facepalm/Positive.mp3" - if [ -f $(brew --prefix)/etc/bash_completion ]; then - . $(brew --prefix)/etc/bash_completion + if [ -f "$(brew --prefix)/etc/bash_completion" ]; then + . "$(brew --prefix)/etc/bash_completion" fi [ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion diff --git a/bash/fake-symlinks.sh b/bash/fake-symlinks.sh index 336f0c5..3927b0c 100644 --- a/bash/fake-symlinks.sh +++ b/bash/fake-symlinks.sh @@ -1,19 +1,33 @@ #!/usr/bin/env bash if [[ -n "$GITHUB_TOKEN" ]]; then - cat $DOTFILES/git/gitconfig.ini | envsubst > ~/.gitconfig + envsubst < "$DOTFILES/git/gitconfig.ini" > ~/.gitconfig fi -SRHT_REPOS=("website" "mentat" "cement" "pouchdb-materialized-view" "pires" "superlogin" "superlogin-client") +SRHT_REPOS=(website mentat cement pouchdb-materialized-view pires superlogin superlogin-client) SRHT_REPOS_PATH="$HOME/dev/libre" -for repo in ${SRHT_REPOS[@]}; do - cat $DOTFILES/templates/sr-ht-build.yaml | REPO="$repo" envsubst > "$SRHT_REPOS_PATH/$repo/.build.yml" +for repo in "${SRHT_REPOS[@]}"; do + REPO="$repo" envsubst < "$DOTFILES/templates/sr-ht-build.yaml" > "$SRHT_REPOS_PATH/$repo/.build.yml" done -for repo in ${SRHT_REPOS[@]}; do +for repo in "${SRHT_REPOS[@]}"; do if [[ "$repo" != "website" ]]; then - cat "$DOTFILES/templates/env.sh" | REPO="$repo" envsubst > "$SRHT_REPOS_PATH/$repo/env.sh" + REPO="$repo" envsubst < "$DOTFILES/templates/env.sh" > "$SRHT_REPOS_PATH/$repo/env.sh" fi done + +mkdir -p ~/.tmuxinator + +TMUXINATOR_TEMPLATES=(annex pires songbooks sosps) + +for template in "${TMUXINATOR_TEMPLATES[@]}"; do + cp "$DOTFILES/tmux/projects/$template.yml" "$HOME/.tmuxinator/$template.yml" +done + +# DHALL_BUILD_REPOS=(website) + +# for repo in "${DHALL_BUILD_REPOS[@]}"; do +# dhall 2> /dev/null <<< "./sr-ht-build.dhall \"$repo\"" | dhall-to-json --pretty > "$SRHT_REPOS_PATH/$repo/.build.yml" +# done diff --git a/bash/init.sh b/bash/init.sh index 777a322..4e0ee65 100644 --- a/bash/init.sh +++ b/bash/init.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash locked_init() { - pushd ~/ > /dev/null + pushd ~/ > /dev/null || exit 1 mkdir -p ~/.emacs.d/.cache/ - mkdir -p $(dirname "$AUTOJUMP_TXT") + mkdir -p "$(dirname "$AUTOJUMP_TXT")" touch "$AUTOJUMP_TXT" # clone all missing repos @@ -13,12 +13,12 @@ locked_init() { printf "" > /tmp/mr-repos mr inject > /dev/null - printf "(\n" > /tmp/mr-projectile + printf "(\\n" > /tmp/mr-projectile sed -E 's/\/home\/andreh/~/' /tmp/mr-repos | awk '{print "\""$1"/""\""}' >> /tmp/mr-projectile printf ")" >> /tmp/mr-projectile cp /tmp/mr-projectile ~/.emacs.d/.cache/projectile-bookmarks.eld - popd > /dev/null + popd > /dev/null || exit 1 } export -f locked_init @@ -32,7 +32,7 @@ export -f locked_init # Tests -pushd $DOTFILES > /dev/null +pushd "$DOTFILES" > /dev/null || exit 1 sizes=$(git diff-files --ignore-submodules | awk '{print $6}' | xargs du | awk '{print $1}') for size in $sizes; do @@ -42,4 +42,4 @@ for size in $sizes; do fi done -popd > /dev/null +popd > /dev/null || exit 1 diff --git a/bash/npm.sh b/bash/npm.sh index c23c074..7fbe4f7 100644 --- a/bash/npm.sh +++ b/bash/npm.sh @@ -2,9 +2,9 @@ # FIXME: port to NixOS npm_i() { - (which $1 &> /dev/null) || { + (command -v "$1" &> /dev/null) || { yellow "Installing $2" - npm i -g $2 + npm i -g "$2" } } diff --git a/bash/platform.sh b/bash/platform.sh index efa5061..eb262e9 100644 --- a/bash/platform.sh +++ b/bash/platform.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash isMac () { - [[ `uname` == 'Darwin' ]] + [[ "$(uname)" == 'Darwin' ]] } isLinux () { - [[ `uname` == 'Linux' ]] + [[ "$(uname)" == 'Linux' ]] } isMac && { diff --git a/bash/symlinks.sh b/bash/symlinks.sh index 39d0a0b..e56ee58 100644 --- a/bash/symlinks.sh +++ b/bash/symlinks.sh @@ -1,77 +1,77 @@ #!/usr/bin/env bash function upsert_dir_symlink() { - local readonly from="$1" - local readonly to="$2" - ([ -d "$to" ] || [ -L "$to" ]) || { + local from="$1" + local to="$2" + { [ -d "$to" ] || [ -L "$to" ]; } || { ln -s "$from" "$to" } } export -f upsert_dir_symlink -upsert_dir_symlink $DOTFILES/encrypted/borg ~/.config/borg +upsert_dir_symlink "$DOTFILES/encrypted/borg" ~/.config/borg -ln -fs $DOTFILES/bash/bashrc.sh ~/.bashrc -ln -fs $DOTFILES/bash/bash_profile.sh ~/.bash_profile -ln -fs $DOTFILES/git/gitattributes ~/.gitattributes -ln -fs $DOTFILES/git/gitignore ~/.gitignore_global -ln -fs $DOTFILES/git/bash_git.sh ~/.bash_git -ln -fs $DOTFILES/encrypted/nugitconfig.ini ~/.nugitconfig -ln -fs $DOTFILES/sbclrc.lisp ~/.sbclrc -ln -fs $DOTFILES/inputrc.conf ~/.inputrc -ln -fs $DOTFILES/Xmodmap.conf ~/.Xmodmap +ln -fs "$DOTFILES/bash/bashrc.sh" ~/.bashrc +ln -fs "$DOTFILES/bash/bash_profile.sh" ~/.bash_profile +ln -fs "$DOTFILES/git/gitattributes" ~/.gitattributes +ln -fs "$DOTFILES/git/gitignore" ~/.gitignore_global +ln -fs "$DOTFILES/git/bash_git.sh" ~/.bash_git +ln -fs "$DOTFILES/encrypted/nugitconfig.ini" ~/.nugitconfig +ln -fs "$DOTFILES/sbclrc.lisp" ~/.sbclrc +ln -fs "$DOTFILES/inputrc.conf" ~/.inputrc +ln -fs "$DOTFILES/Xmodmap.conf" ~/.Xmodmap isLinux && { - ln -fs $DOTFILES/nixos/npmrc.sh ~/.npmrc + ln -fs "$DOTFILES/nixos/npmrc.sh" ~/.npmrc } ## SSH config mkdir -p ~/.ssh -ln -fs $DOTFILES/ssh_config.conf ~/.ssh/config +ln -fs "$DOTFILES/ssh_config.conf" ~/.ssh/config -ln -fs $DOTFILES/git/mrconfig.ini ~/.mrconfig +ln -fs "$DOTFILES/git/mrconfig.ini" ~/.mrconfig -upsert_dir_symlink $MEDIA_PREFIX/UTCLOUD ~/UTCLOUD -upsert_dir_symlink $MEDIA_PREFIX/SNEAKER ~/SNEAKER +upsert_dir_symlink "$MEDIA_PREFIX/UTCLOUD" ~/UTCLOUD +upsert_dir_symlink "$MEDIA_PREFIX/SNEAKER" ~/SNEAKER ## Clojure mkdir -p ~/.lein ~/.clojure -ln -fs $DOTFILES/lein/profiles.clj ~/.lein/profiles.clj -ln -fs $DOTFILES/lein/deps.edn ~/.clojure/deps.edn +ln -fs "$DOTFILES/lein/profiles.clj" ~/.lein/profiles.clj +ln -fs "$DOTFILES/lein/deps.edn" ~/.clojure/deps.edn ## AWS mkdir -p ~/.aws -ln -fs $DOTFILES/encrypted/aws/config ~/.aws/config -ln -fs $DOTFILES/encrypted/aws/credentials ~/.aws/credentials +ln -fs "$DOTFILES/encrypted/aws/config" ~/.aws/config +ln -fs "$DOTFILES/encrypted/aws/credentials" ~/.aws/credentials ## tmux -ln -fs $DOTFILES/tmux/tmux.conf ~/.tmux.conf -ln -fs $DOTFILES/tmux/tmux-macos.conf ~/.tmux-macos.conf -ln -fs $DOTFILES/tmux/tmux-gnu-linux.conf ~/.tmux-gnu-linux.conf +ln -fs "$DOTFILES/tmux/tmux.conf" ~/.tmux.conf +ln -fs "$DOTFILES/tmux/tmux-macos.conf" ~/.tmux-macos.conf +ln -fs "$DOTFILES/tmux/tmux-gnu-linux.conf" ~/.tmux-gnu-linux.conf ## NixOS -ln -fs $DOTFILES/nixos/evince.destkop ~/.local/share/applications/evince.desktop -ln -fs $DOTFILES/nixos/firefox.destkop ~/.local/share/applications/firefox.desktop +ln -fs "$DOTFILES/nixos/evince.destkop" ~/.local/share/applications/evince.desktop +ln -fs "$DOTFILES/nixos/firefox.destkop" ~/.local/share/applications/firefox.desktop ## Emacs -mkdir -p $HOME/.emacs.d/private/layers/ -ln -fs $DOTFILES/spacemacs.el ~/.spacemacs -ln -fs $DOTFILES/emacs/gnus.el ~/.gnus.el -ln -fs $CACHE_DIR/euandreh-auto-save.el ~/.emacs.d/.cache/layouts/euandreh-auto-save +mkdir -p "$HOME/.emacs.d/private/layers/" +ln -fs "$DOTFILES/spacemacs.el" ~/.spacemacs +ln -fs "$DOTFILES/emacs/gnus.el" ~/.gnus.el +ln -fs "$CACHE_DIR/euandreh-auto-save.el" ~/.emacs.d/.cache/layouts/euandreh-auto-save ## xmonad mkdir -p ~/.xmonad -ln -fs $DOTFILES/xmonad/xsession.sh ~/.xsession -ln -fs $DOTFILES/xmonad/xmonad.hs ~/.xmonad/xmonad.hs -ln -fs $DOTFILES/xmonad/xmobar.hs ~/.xmobarrc +ln -fs "$DOTFILES/xmonad/xsession.sh" ~/.xsession +ln -fs "$DOTFILES/xmonad/xmonad.hs" ~/.xmonad/xmonad.hs +ln -fs "$DOTFILES/xmonad/xmobar.hs" ~/.xmobarrc ## Mail mkdir -p ~/mbsync/.notmuch/hooks ~/mbsync/EuAndreh ~/mbsync/Gmail ~/mbsync/Nubank -ln -fs $DOTFILES/mail/notmuch-post.sh ~/mbsync/.notmuch/hooks/post-new -ln -fs $DOTFILES/mail/mbsyncrc.ini ~/.mbsyncrc -ln -fs $DOTFILES/mail/notmuch.ini ~/.notmuch-config -ln -fs /tmp/mbsync.$(date +%Y-%m-%d).log /tmp/mbsync.log -ln -fs /tmp/notmuch.$(date +%Y-%m-%d).log /tmp/notmuch.log +ln -fs "$DOTFILES/mail/notmuch-post.sh" ~/mbsync/.notmuch/hooks/post-new +ln -fs "$DOTFILES/mail/mbsyncrc.ini" ~/.mbsyncrc +ln -fs "$DOTFILES/mail/notmuch.ini" ~/.notmuch-config +ln -fs /tmp/mbsync."$(date +%Y-%m-%d)".log /tmp/mbsync.log +ln -fs /tmp/notmuch."$(date +%Y-%m-%d)".log /tmp/notmuch.log ## GNUS -ln -fs $DOTFILES/encrypted/IMAP/authinfo.gpg ~/.authinfo.gpg +ln -fs "$DOTFILES/encrypted/IMAP/authinfo.gpg" ~/.authinfo.gpg diff --git a/bash/tmuxinator-templates.sh b/bash/tmuxinator-templates.sh deleted file mode 100755 index adbbb5c..0000000 --- a/bash/tmuxinator-templates.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -mkdir -p ~/.tmuxinator - -templates=(annex pires songbooks sosps) - -for template in ${templates[@]}; do - cp $DOTFILES/tmux/projects/$template.yml ~/.tmuxinator/$template.yml -done diff --git a/bash/util.sh b/bash/util.sh index 833bc9c..e29d02f 100644 --- a/bash/util.sh +++ b/bash/util.sh @@ -1,20 +1,20 @@ #!/usr/bin/env bash extract () { - if [ -f $1 ] ; then - case $1 in - *.tar.bz2) tar xvjf $1 ;; - *.tar.gz) tar xvzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xvf $1 ;; - *.tbz2) tar xvjf $1 ;; - *.tgz) tar xvzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *.xz) unxz $1 ;; + if [ -f "$1" ] ; then + case "$1" in + *.tar.bz2) tar xvjf "$1" ;; + *.tar.gz) tar xvzf "$1" ;; + *.bz2) bunzip2 "$1" ;; + *.rar) unrar x "$1" ;; + *.gz) gunzip "$1" ;; + *.tar) tar xvf "$1" ;; + *.tbz2) tar xvjf "$1" ;; + *.tgz) tar xvzf "$1" ;; + *.zip) unzip "$1" ;; + *.Z) uncompress "$1" ;; + *.7z) 7z x "$1" ;; + *.xz) unxz "$1" ;; *) echo "don't know how to extract '$1'..." ;; esac else @@ -24,11 +24,11 @@ extract () { merkle-tree () { dirname="${1-.}" - pushd "$dirname" > /dev/null + pushd "$dirname" > /dev/null || exit 1 find . -type f | \ sort | \ xargs -I{} sha256sum "{}" | \ sha256sum | \ awk '{print $1}' - popd > /dev/null + popd > /dev/null || exit 1 } diff --git a/bash/youtube.sh b/bash/youtube.sh index c40e0a7..19c9af0 100644 --- a/bash/youtube.sh +++ b/bash/youtube.sh @@ -2,7 +2,7 @@ export DEFAULT_PLAYLIST_END=15 export DEFAULT_INC_STEP=10 -export YT_TEMPLATE="~/Downloads/yt-dl/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" +export YT_TEMPLATE="$HOME/Downloads/yt-dl/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" # Always downloads video, doesn't look at the download-archive yt_dl() { |