https://www.ostechnix.com/collection-useful-bash-scripts-heavy-commandline-users/
brew install bash-snippets
cat file.jpg
imgcat dog.gif
pbcopy < text.md
lsof -i :80
for ex npm i && npm start these are perfect for Aliases too if you are using them a lot
open .
airport -s
history
clear
caffeinate -u -t 3600
open itunes
open /Users/mel/Documents
opendiff Contract1.rtf Contract2.rtf could be any two files similar
uptime
sudo shutdown -r now
sudo shutdown now
pmset -g
sudo pmset displaysleep 15
sudo pmset sleep 30
Force Finder to show hidden files (to see . hidden files):
defaults write com.apple.finder AppleShowAllFiles TRUE
Force Finder to hide hidden files (ie: back to the default setting):
defaults write com.apple.finder AppleShowAllFiles FALSE
pbpaste | wc -l
pbpaste | wc -w
pbpaste | sort | pbcopy
Reverse each line of text in the Clipboard (ie: make each line appear backwards) and copy them back to the Clipboard:
pbpaste | rev | pbcopy
Strip duplicate lines from lines of text in the Clipboard and copy only one instance of each duplicate line back to the Clipboard (output is sorted):
pbpaste | sort | uniq | pbcopy
Find duplicate lines from lines of text in the Clipboard and copy only one instance of each duplicate line (stripping non-duplicates) back to the Clipboard (output is sorted):
pbpaste | sort | uniq -d | pbcopy
Strip duplicate lines from lines of text in the Clipboard and copy only one instance of each line (stripping duplicates entirely) back to the Clipboard (output is sorted):
pbpaste | sort | uniq -u | pbcopy
pbpaste | tidy | pbcopy
pbpaste | head -n 5
pbpaste | tail -n 5
pbpaste | expand | pbcopy
## Quick clear of terminal ##
alias c='clear'
## save time with history & jobs ##
alias h='history'
alias j='jobs -l'
## Colorize the ls output ##
alias ls='ls --color=auto'
## Use a long listing format ##
alias ll='ls -la'
## Show hidden files ##
alias l.='ls -d .* --color=auto'
## get rid of command not found ##
alias cd..='cd ..'
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'
# Git alias
alias gcm="git checkout master"
alias gcr="git checkout release"
alias gnb=gnb
alias gfc=gfc
alias gcb="git checkout $1"
alias gma="git merge abort"
alias gmm="git merge master"
alias gpom="git push origin master" # dont judge me
alias gpro="git pull --rebase origin master"
alias gpru="git pull --rebase upstream master"
alias gra="git rebase --abort"
alias grc="git rebase --continue"
# Node/NPM alias
alias cra="create-react-app"
alias purge="rm -rf node_modules package-lock.json; npm i"
alias dev="npm run dev"
alias devs="npm run dev:s"
# System alias
alias bb='/bin/bash'
## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
## Start calculator with math support ##
alias bc='bc -l'
##Generate sha1 digest ##
alias sha1='openssl sha1'
## Create parent directories on demand ##
alias mkdir='mkdir -pv'
## install colordiff package ##
alias diff='colordiff'
## Make mount command output pretty / readable ##
alias mount='mount |column -t'
## Create a new set of commands ##
alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%T"'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'
## Show open ports ##
alias ports='netstat -tulanp'
## Tune sudo and su ##
alias root='sudo -i'
alias su='sudo -i'
## Control web servers ##
alias nginxreload='sudo /usr/local/nginx/sbin/nginx -s reload'
alias nginxtest='sudo /usr/local/nginx/sbin/nginx -t'
alias lightyload='sudo /etc/init.d/lighttpd reload'
alias lightytest='sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -t'
alias httpdreload='sudo /usr/sbin/apachectl -k graceful'
alias httpdtest='sudo /usr/sbin/apachectl -t && /usr/sbin/apachectl -t -D DUMP_VHOSTS'
## Get system memory, cpu usage, & gpu memory info quick ##
## pass options to free ##
alias meminfo='free -m -l -t'
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
## Get server cpu info ##
alias cpuinfo='lscpu'
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
## get GPU ram on desktop / laptop##
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
## Control Home Router ##
# Reboot a home "Linksy" Router / Gateway , use your own stuff.
alias rebootlinksys="curl -u 'admin:my-super-password' 'http://192.168.1.2/setup.cgi?todo=reboot'"