Skip to content

Instantly share code, notes, and snippets.

@anushshukla
Last active April 11, 2021 22:27
Show Gist options
  • Select an option

  • Save anushshukla/6d90fb56d703959dfab41d4a74bb853b to your computer and use it in GitHub Desktop.

Select an option

Save anushshukla/6d90fb56d703959dfab41d4a74bb853b to your computer and use it in GitHub Desktop.
Bash Aliases to run in terminal in easy and simple commands
alias checkoutsites='cd /var/www/html'
# react coverage html dump
alias getCoverageFilesList='git diff --name-only origin/develop | grep -v public/ | grep -v api/ | grep -v styles | grep -v __tests__ | grep -v action_types'
alias startNodeServer='cd /var/www/html/backend && NODE_ENV=local nvm exec v10.12.0 node . &'
alias opensqlworkbench='java -jar ~/Documents/Workbench-Build124/sqlworkbench.jar &'
alias openlocaldb='mysql -h 127.0.0.1 -u root -p1234 -A'
function spacestotab() {
# $1 -> directory # $2 -> regex matching files within the $1 directory $3 -> tabs count, generally being 2
find $1 -name '$2' ! -type d -exec bash -c 'expand -t ${3:-2} "$0" > /tmp/e && mv /tmp/e "$0"' \{\} \\
}
function debugnodeautostart() {
# DEBUG=loopback:datasource nodemon --no-lazy --inspect=${1:-9229}
nodemon --inspect=${1:-9229} --ignore '**/*.test.js' --ignore '**/*.json' --ignore '**/*.yml'
}
function getpm2id() {
# $i -> port number
$(pm2 list | grep $1 | grep -Eho "| [0-9][0-9]" | head -n1)
}
function checkoutportcode() {
cd $(pm2 show $(getpm2id $1) | grep 'repository root' | grep -o "\/opt/.*")
}
function getpm2path() {
echo $(pm2 show $(getpm2id $1) | grep 'exec cwd' | grep -o "\/opt/[-a-zA-Z/]*")
}
function reloadPort() {
pm2 reload $(getpm2id $1) && pm2 logs $(getpm2id $1)
}
function reloadpm2() {
pm2 reload $1 && pm2 logs $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment