Last active
October 25, 2018 17:29
-
-
Save idlehands/d425c7a32e6a6d8162c2ff123758ca42 to your computer and use it in GitHub Desktop.
Bash functions for happy life
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
# a log of these assume the exsistence of a branch called `utility` | |
# the code in `utility` doesn't have to be up to date | |
function reset_develop { | |
git checkout utility | |
git branch -D develop | |
git fetch | |
git checkout -b develop origin/develop | |
} | |
function reset_current_branch { | |
branch_name=“$(git symbolic-ref HEAD 2>/dev/null)” || | |
branch_name=“(unnamed branch)” # detached HEAD | |
branch_name=${branch_name##refs/heads/} | |
git checkout utility | |
git branch -D $branch_name | |
git fetch | |
git checkout $branch_name | |
} | |
function start_branch { | |
reset_develop | |
git checkout -b $1 | |
} | |
# example: `remove_branches_with SRVC` | |
function remove_branches_with { | |
git branch -D `git branch | grep $1` | |
} | |
function gcheckout { | |
branch_name=`git branch | grep $1 | tail -1` | |
echo $branch_name | |
git checkout $branch_name | |
} | |
function check_format { | |
mix format --check-formatted | |
} | |
# example: `unset_envs POST` would unset any environment variable with `POST` in the name, like `POSTGRES_URL` | |
function unset_envs { | |
for name in “$@“; do | |
matches=$(env | grep $name | sed ‘s/=.*$//’) | |
for entry in $matches; do | |
unset $entry | |
done | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment