From b449bcaaf1e33d017a1e8b9e1b0d2271bc36c2ad Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 5 Jun 2021 03:15:23 +0200 Subject: [PATCH] Update some config files --- home/.config/sh/aliases | 20 ++++++++++++++------ home/.config/sh/environ | 4 ++++ home/.config/sh/functions | 5 +++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/home/.config/sh/aliases b/home/.config/sh/aliases index 2bfe999..6c99b19 100755 --- a/home/.config/sh/aliases +++ b/home/.config/sh/aliases @@ -34,6 +34,7 @@ alias mv='mv -iv' # Ask before overwriting, verbose alias rm='rm -v' # Verbose (asking here is too annoying) alias wget='wget -c' # Resume wget by default alias df='df -H' # Show sizes as powers of 1000 +command -v bat > /dev/null && alias cat='bat' # Use colored bat instead of cat # Directory listing aliases, defaults to exa, if aviable if command -v exa > /dev/null; then @@ -88,11 +89,13 @@ command -v xclip > /dev/null && alias pbpaste='xclip -selection clipboard -o' command -v xsel > /dev/null && alias pbcopy='xsel --clipboard --input' command -v xsel > /dev/null && alias pbpaste='xsel --clipboard --output' -# File formats and validation +# File validation and manipulation alias yamlcheck='python -c "import sys, yaml as y; y.safe_load(open(sys.argv[1]))"' # Validate YAML alias jsoncheck='jq "." >/dev/null <' # Validate JSON alias urlencode='python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"' # Encode strings as URLs (space->%20, etc.) -alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf' # Usage: `mergepdf input{1,2,3}.pdf` +alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf' # Usage: `mergepdf input{1,2,3}.pdf`` +alias encrypt='gpg -c --no-symkey-cache --cipher-algo AES256' # Encrypt file with AES256 symetric encryption +alias decrypt='gpg' # For the sake of completeness, include decrypt command to the above, though it's only just gpg alias # Regular expressions alias reg_email='echo "[a-Z0-9._%-]+@[a-Z0-9.-]+\.[a-Z]{2,10}"' @@ -172,6 +175,7 @@ alias cleanup='clean-trash && clean-down && clean-journal && clean-pacman' # Git aliases alias g='git' alias gs='git status' +alias gd='git diff' alias ga='git add' alias gaa='git add all' alias gc='git commit' @@ -234,14 +238,18 @@ alias colors-256='curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f alias tty-clock='tty-clock -Ssc' # Terminal clock screensaver alias rick='curl -s -L https://raw.githubusercontent.com/ItsDrike/rickrollrc/master/roll.sh| bash' # Terminal rickroll -# If user is not root, pass all commands via sudo +# If user is not root, pass all commands via sudo/doas if [ $UID -ne 0 ]; then - # Enable aliases to be sudo’ed + # Enable aliases to be sudoed/doased + # with doas having precedence over sudo if found ## Uncomment if you are using autocompletion (is ZSH) - #alias sudo='nocorrect sudo' + #command -v /usr/bin/sudo > /dev/null && alias doas='nocorrect sudo ' && alias sudo='nocorrect sudo ' + #command -v /usr/bin/doas > /dev/null && alias doas='nocorrect doas ' && alias sudo='nocorrect doas ' + ## if the above is uncommented, comment this - alias sudo='sudo ' + command -v /usr/bin/sudo > /dev/null && alias doas='sudo ' && alias sudo='sudo ' + command -v /usr/bin/doas > /dev/null && alias doas='doas ' && alias sudo='doas ' fi # enable color support diff --git a/home/.config/sh/environ b/home/.config/sh/environ index fa80546..bdcd175 100755 --- a/home/.config/sh/environ +++ b/home/.config/sh/environ @@ -6,9 +6,12 @@ export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within export GPG_TTY=${tty} export LESS_TERMCAP_md="${yellow}" # Highlight section titles in manual pages export BASH_SILENCE_DEPRECATION_WARNING=1 # Hide the “default interactive shell is now zsh” warning on macOS. +export MANPAGER="sh -c 'col -bx | bat -l man -p'" # Use bat as man page formatter for colored man pages # Add executable directories into PATH PATH+=":$HOME/.local/bin" +# Add npm binaries +PATH+=":$HOME/.local/share/npm/bin" # XDG Standard paths export XDG_CONFIG_HOME="$HOME/.config" @@ -41,6 +44,7 @@ export PGPASSFILE="$XDG_CONFIG_HOME/pg/pgpass" export PGSERVICEFILE="$XDG_CONFIG_HOME/pg/pg_service.conf" export MPLAYER_HOME="$XDG_CONFIG_HOME/mplayer" export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages +export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" # XDG Alias overrides alias nvidia-settings='nvidia-settings --config="$XDG_CONFIG_HOME/nvidia/settings"' diff --git a/home/.config/sh/functions b/home/.config/sh/functions index f29115c..8d193a6 100755 --- a/home/.config/sh/functions +++ b/home/.config/sh/functions @@ -20,6 +20,11 @@ function o() { fi; } +# Use bat for nicer git diffs +function batdiff() { + git diff --name-only --diff-filter=d | xargs bat --diff +} + # Determine size of a file or total size of a directory function dir-size() { if du -b /dev/null > /dev/null 2>&1; then