Last active
April 10, 2019 00:32
-
-
Save wturnerharris/8b39df6004418f5a4935d99e53d435cc to your computer and use it in GitHub Desktop.
Some helpful bash aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
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.
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
Added some bash aliases
version
,test-tag
,live-tag
, andincrement
to help with Pantheon deployments and gitflow releases. Increment currently only works for the Pantheon deployment tags in the formpantheon_env_x
where x gets incremented. I use it by passing the result of eithertest-tag
orlive-tag
through a pipe toincrement
and usually assign this to a variable: