Skip to content

Instantly share code, notes, and snippets.

@wturnerharris
Last active April 10, 2019 00:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wturnerharris/8b39df6004418f5a4935d99e53d435cc to your computer and use it in GitHub Desktop.
Save wturnerharris/8b39df6004418f5a4935d99e53d435cc to your computer and use it in GitHub Desktop.
Some helpful bash aliases
#!/bin/bash
adduser()
{
if [ -z "$1" ] # Is parameter #1 zero length?
then
echo "-Parameters are zero length.-" # Or no parameter passed.
else
echo "-Parameter #1 is \"$1\".-"
fi
if [ -z "$2" ] # Is parameter #2 zero length?
then
echo "-Parameters are zero length.-" # Or no parameter passed.
else
echo "-Parameter #2 is \"$2\".-"
sudo dseditgroup -o edit -a $1 -t user $2
fi
}
alias sites='cd ~/Sites'
alias hosts='sudo vim /etc/hosts'
alias bump='git commit -am "Update changelog and bump versions"'
alias sync='git push origin develop; git checkout master; git push origin master; git push origin $(version)'
alias sync1='git checkout develop && git push origin develop && git push pantheon develop && git checkout master && git push origin master && git push pantheon master; git push origin $(version)'
alias sync2='git checkout develop && git push origin develop && git checkout master && git push origin master && git push live master'
alias sync3='git checkout develop && git push origin develop && git push acquia develop && git checkout master && git push origin master && git push acquia master'
alias homevpn='sudo openvpn --config ~/.openvpn/client3.ovpn --ca ~/.openvpn/ca.crt --cert ~/.openvpn/client.crt --key ~/.openvpn/client.key'
alias docker-kill-all='docker ps --format "{{.ID}}" | xargs docker kill'
alias octal='stat -f %Mp%Lp *'
alias sshkey='cat ~/.ssh/id_rsa.pub | pbcopy'
alias ssh-fingerprint='ssh-keygen -E md5 -lf'
alias shrug='echo "¯\_(ツ)_/¯" | pbcopy'
alias git-branch='git rev-parse --abbrev-ref HEAD'
alias version='git tag --sort v:refname | grep "^v" | tail -1'
alias test-tag='git tag --sort v:refname | grep _test_ | tail -1'
alias live-tag='git tag --sort v:refname | grep _live_ | tail -1'
alias increment="perl -pe 's/([0-9]+)\b/0\$1~01234567890/g' | perl -pe 's/0(?!9*~)|([0-9])(?=9*~[0-9]*?\1([0-9]))|~[0-9]*/\$2/g'"
alias increment-test='t=$(test-tag); p="pantheon_test_"; v=${t:${#p}}; echo $(($v+1))'
alias increment-live='t=$(live-tag); p="pantheon_live_"; v=${t:${#p}}; echo $(($v+1))'
alias pantheon-deploy-test='p="pantheon_test_"$(increment-test) && git tag $p && git push pantheon $p'
alias pantheon-deploy-live='p="pantheon_live_"$(increment-live) && git tag $p && git push pantheon $p'
alias force-push='git push -f origin $(git-branch)'
alias php-syntax='git diff --diff-filter=ACMR --name-only origin/master | grep .php | xargs -L1 php -l'
alias process='git commit -am "Process scripts and/or styles"'
alias terminus-login='terminus auth:login --machine-token=XXX'
alias lando-login='lando terminus auth:login --machine-token=XXX'
@wturnerharris
Copy link
Author

Added some bash aliases version, test-tag, live-tag, and increment to help with Pantheon deployments and gitflow releases. Increment currently only works for the Pantheon deployment tags in the form pantheon_env_x where x gets incremented. I use it by passing the result of either test-tag or live-tag through a pipe to increment and usually assign this to a variable:

#!/bin/bash
v=$(test-tag | increment); git tag $v; git push remote $v

@wturnerharris
Copy link
Author

TODO: I still need a way to increment only a piece of the semver version string (v1.2.3) as my increment alias will bump all the numbers up by 1 rather than a specific part of the version string.

@wturnerharris
Copy link
Author

wturnerharris commented Nov 30, 2017

To bootstrap this, I load it in .bash_profile

#!/bin/bash

### bashrc
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi

### aliases
if [ -f ~/.bash_alias ]; then source ~/.bash_alias; fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment