Changes to how cat works mainly

Cat is now a function rather than an alias. It will tie in with grc if
possible and add syntax highlighting to the file

if not, will fall back do using bat
Jonathan Hodgson 4 years ago
parent 5d263147b1
commit 5b77ceb763
  1. 12
      shells/shared/aliases
  2. 13
      shells/shared/functions

@ -102,7 +102,8 @@ type -p exa > /dev/null && alias l="exa -lahg --git --grid" || alias l="ls -lah"
type -p exa > /dev/null && alias tree="exa -FT" || alias tree='tree -F -C' type -p exa > /dev/null && alias tree="exa -FT" || alias tree='tree -F -C'
# Alias cat to bat if it's available # Alias cat to bat if it's available
type -p bat > /dev/null && alias cat="bat" #type -p bat > /dev/null && alias cat="bat"
# This has been moved into a function
# If nvim is available, alias vim to neovim # If nvim is available, alias vim to neovim
type -p nvim > /dev/null && alias vim="nvim" type -p nvim > /dev/null && alias vim="nvim"
@ -186,7 +187,11 @@ alias snmp-check="/usr/bin/snmpcheck-nothink"
#alias irmgpg="gpg --no-default-keyring --keyring=irm.gpg" #alias irmgpg="gpg --no-default-keyring --keyring=irm.gpg"
alias irmgpg="gpg --options ~/.gnupg/irmgpg.conf --keyring=irm.gpg" alias irmgpg="gpg --options ~/.gnupg/irmgpg.conf --keyring=irm.gpg"
if [ -f "$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl" ]; then
alias weakopenssl="$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl" alias weakopenssl="$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl"
alias testssl="testssl --openssl=\"$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl\""
fi
############## ##############
@ -196,7 +201,7 @@ alias weakopenssl="$HOME/GitRepos/openssl-weak/openssl-1.0.2-chacha/apps/openssl
# Keyboard - reset # Keyboard - reset
# Sometimes, if I turn the screens off, the keyboard resets itself to defaults. Not sure why but this will put my keyboard back to how I like it # Sometimes, if I turn the screens off, the keyboard resets itself to defaults. Not sure why but this will put my keyboard back to how I like it
#alias kb="xmodmap ~/.Xmodmap; xset r rate 200 70; xcape" #alias kb="xmodmap ~/.Xmodmap; xset r rate 200 70; xcape"
alias kb="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle; xset r rate 200 70; xinput --list | grep -Ei 'ErgoDox EZ\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs setxkbmap -layout gb -device" alias kb="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle; xset r rate 200 70; xinput --list | grep -Ei 'ErgoDox EZ\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs -r setxkbmap -layout gb -device"
alias colemak="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle" alias colemak="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle"
alias qwerty="setxkbmap -layout gb" alias qwerty="setxkbmap -layout gb"
@ -254,6 +259,9 @@ alias globalip="drill myip.opendns.com @resolver1.opendns.com | sed -n '/ANSWER
alias chrome-curl="node $HOME/GitRepos/chrome-curl/index.js" alias chrome-curl="node $HOME/GitRepos/chrome-curl/index.js"
# Plays a youtube video or playlist - audio only
alias ytaudio='mpv --ytdl-format="bestaudio"'
if type grc > /dev/null 2>&1; then if type grc > /dev/null 2>&1; then
for cmd in "nmap" "ping" "traceroute" "mount" "netstat" "ps" "dig" "du" "df" "ip" "iptables" "lsblk" "id" "free" "tcpdump" "uptime" "showmount" "whois" ; do for cmd in "nmap" "ping" "traceroute" "mount" "netstat" "ps" "dig" "du" "df" "ip" "iptables" "lsblk" "id" "free" "tcpdump" "uptime" "showmount" "whois" ; do
alias "$cmd"="grc $(whence $cmd)" alias "$cmd"="grc $(whence $cmd)"

@ -306,3 +306,16 @@ function debugToggle(){
fi fi
} }
function cat(){
local grcConfigs="$HOME/.config/grc/"
if [ -f "$1" ]; then
local ext="${1##*.}"
if [ -f "${grcConfigs}conf.${ext}" ]; then
/usr/bin/cat "$1" | /usr/bin/grcat "${grcConfigs}conf.${ext}" | /usr/bin/bat --file-name "$1"
else
/usr/bin/bat "$@"
fi
else
/usr/bin/bat "$@"
fi
}

Loading…
Cancel
Save