Last active
December 21, 2022 20:35
-
-
Save voronoipotato/cfa4344658fc8efa9c44ce19cb43ce12 to your computer and use it in GitHub Desktop.
dotfiles for git bash
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
alias _="declare -F | grep -v _; alias;" | |
alias we="curl -s 'wttr.in/{Raleigh,Chicago,Los_Angeles,Austin}?format=3'" | |
alias ll='ls -lh' | |
alias gh='history|grep' | |
alias vs='"C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/devenv.exe"' | |
_userpass='user:pass' | |
_jira_domain='http://jira.domain' | |
_proget_domain='https://proget.domain' | |
function b (){ | |
# $@ All positional arguments (as separate strings) | |
./build.cmd $@ | |
} | |
function svgviz(){ | |
dot -Tsvg "~/$1.svg" | |
} | |
function tests_added() { | |
xmllint build/*/testResults.xml --xpath "//*/test/@method" | sed "s/.*=\"\(.*\)\"/\1/" | sed "s/'//" | xargs -d "\n" -i bash -c "git diff develop | grep '+' | grep -o '{}' " | |
} | |
function _optsExample(){ | |
while getopts 'lha:' OPTION; do | |
case "$OPTION" in | |
l) | |
echo "linuxconfig" | |
;; | |
h) | |
echo "you have supplied the -h option" | |
;; | |
a) | |
avalue="$OPTARG" | |
echo "The value provided is $OPTARG" | |
;; | |
?) | |
echo "script usage: $(basename \$0) [-l] [-h] [-a somevalue]" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
shift "$(($OPTIND -1))" | |
} | |
function work(){ | |
if test -n "$2"; then | |
current=$2; | |
else | |
current=$(git symbolic-ref --short -q HEAD); | |
fi | |
git worktree add -B $1 ../$current/$1 $current; | |
cd ../$current/$1; | |
} | |
function workin(){ | |
cd $(git worktree list | awk 'NR==2{print $1}') | |
} | |
# function workon(){ | |
# current=$(git symbolic-ref --short -q HEAD); | |
# git checkout develop; | |
# git worktree add ../develop/$current $current; | |
# pushd ../develop/$current > /dev/null; | |
# } | |
function _isGit(){ | |
git -C . rev-parse &> /dev/null | |
status=$? | |
if [ $status -ne 0 ] | |
then | |
echo "directory is not a git repository" 1>&2; | |
fi | |
return $status | |
} | |
function curr(){ | |
if [ "$1" == '--help' ] | |
then | |
printf '\n Usage: curr \n returns current branch name' | |
return 0 | |
fi | |
_isGit && git symbolic-ref --short -q HEAD | |
} | |
function jira_id(){ | |
if [ "$1" == '--help' ] | |
then | |
printf '\n Usage: jira_id \n returns jira-id associated with the git branch' | |
return 0 | |
fi | |
curr | awk -v OFS='-' -F '-' '{print $1, $2}' | |
} | |
function c() { | |
if ! _isGit | |
then | |
return 1 | |
fi | |
git commit -m "$(jira_id): $@" | |
} | |
function jira_link(){ | |
if ! _isGit | |
then | |
return 1 | |
fi | |
if [ "$1" == '--help' ] | |
then | |
printf '\n Usage: jira_link [PR-ID] \n Adds link for pull request to the associated jira' | |
return 0 | |
fi | |
if [[ $1 == '-t' || $1 == '--template' ]] | |
then | |
prnum=$2 | |
title='PR -> Template' | |
else | |
prnum=$1 | |
title='PR -> Develop' | |
fi | |
url=$(git remote -v | head -1 | awk -F " " '{print $2}' | sed 's/\.git/\/pull\/'"${prnum}"'/') | |
data='{"object": {"url":"'"${url}"'","title":"'"${title}"'"}}' | |
echo ${data} | |
curl -s -X POST -u ${_userpass} -H "Content-Type: application/json" "${_jira_domain}/rest/api/2/issue/$(jira_id)/remotelink" -d | |
} | |
function _jira_json(){ | |
if [ "$1" == '--help' ] | |
then | |
printf '\n Usage: _jira_json [JIRA-ID] \n returns json for jira-id \n uses jira-id on the git branch name if not provided' | |
return 0 | |
fi | |
if [[ $# -eq 0 ]] | |
then | |
_isGit && curl -s -u ${_userpass} -H "Content-Type: application/json" "${_jira_domain}/rest/api/2/issue/$(jira_id)" | |
else | |
curl -s -u ${_userpass} -H "Content-Type: application/json" "${_jira_domain}/rest/api/2/issue/$1" | |
fi | |
} | |
function jira(){ | |
if [ "$1" == '--help' ] | |
then | |
printf '\n Usage: jira [JIRA-ID] \n returns key, summary, description, and DOD requirements \n uses jira-id on the git branch name if not provided ' | |
return 0 | |
fi | |
query='"\n\n"+.key+ ": " + .fields.summary,"\n\nurl: '"${_jira_domain}"'/browse/"+.key, "\n\nDesc:\n"+.fields.description, "\n\nDOD: \n"+.fields.customfield_10200' | |
if [[ $# -eq 0 ]] | |
then | |
_isGit && _jira_json | jq -r "${query}" | |
else | |
_jira_json $1 | jq -r "${query}" | |
fi | |
} | |
function yaba(){ | |
if [ "$1" == '--help' ] | |
then | |
printf '\n Usage: yaba \n flintstones "Yaba dabba doo" \n commits changes, changes back to the source worktree and removes this worktree' | |
return 0 | |
fi | |
current=$(git symbolic-ref --short -q HEAD); | |
git commit -am "${current} change"; | |
cd $(git worktree list | awk 'NR==1{print $1}') | |
git worktree remove $(git worktree list | awk 'NR==2{print $1}'); | |
} | |
#[ -f ~/.fzf.bash ] && source ~/.fzf.bash | |
#fd -d 2 -t d --changed-within 2weeks | |
function fd_dir(){ | |
#searches directories, shallow | |
fd -t d --prune $1 | sort | |
} | |
function fd_cd(){ | |
if test -n "$2"; then | |
cd $(fcd $1 | sort | awk 'NR==$2'); | |
else | |
cd $(fcd $1 | sort | head -1); | |
fi | |
} | |
function release_version_notes(){ | |
if [ "$1" == '--help' ] | |
then | |
printf 'usage release_version_notes \n returns the top version number from the release notes' | |
return 0 | |
fi | |
cat RELEASE_NOTES.md | head -1 | sed -E -e '1 s/## ([0-9|.]+)\s.*/\1/' | |
} | |
function _release_search_json(){ | |
if [ "$1" == '--help' ] | |
then | |
printf 'Usage: release_search_json PACKAGE_NAME /n returns the proget json' | |
return 0 | |
fi | |
if [ $# -eq 0 ] | |
then | |
echo "Package name required" | |
else | |
curl -sk '${_proget_domain}/nuget/sbs-nuget/v3/search/query?q='"$1"'&prerelease=false' | |
fi | |
} | |
function release_version_nuget(){ | |
if [ "$1" == '--help' ] | |
then | |
printf 'Usage: release_version_nuget PACKAGE_NAME \n takes package name, returns the latest release version from proget' | |
return 0 | |
fi | |
if [ $# -eq 0 ] | |
then | |
echo "Package name required" | |
else | |
_release_search_json $1 | jq -r '.data[] | .versions[] | .version' | sort -Vr | head -1 | |
fi | |
} | |
function _release_note(){ | |
if [ "$1" == '--help' ] | |
then | |
echo "release_note: returns the release note that would be added by the release command" | |
return 0 | |
fi | |
_jira_json | jq -r '"* "+.key + ": "+ .fields.summary' | |
} | |
function _release_note_fix(){ | |
sed -i -E -e '0,/^\s*$/s//'"$(_release_note)"'\n/' RELEASE_NOTES.md | |
} | |
function _release_date(){ | |
date -I | |
} | |
function _release_date_fix(){ | |
if [ "$1" == '--help' ] | |
then | |
printf "Usage: release_date \n updates the latest release in the RELEASE_NOTES.md to be the current date" | |
return 0 | |
fi | |
sed -i -E '1 s/([0-9]{4}-[0-9]{2}-[0-9]{2})/'"$(_release_date)"'/' RELEASE_NOTES.md | |
} | |
function release(){ | |
if [ "$1" == '--help' ] | |
then | |
printf "Usage: release -M --major, -m --minor -n --notes \n updates date and adds an entry to release_notes based on the current jira summary" | |
return 0 | |
fi | |
release_ver=$(cat RELEASE_NOTES.md | head -1 | sed -E -e '1 s/## ([0-9|.]+)\s.*/\1/') | |
if [[ $1 == '-M' || $1 == '--major' ]] | |
then | |
new_release_ver=$(echo $release_ver | awk 'BEGIN { FS = "."; OFS = "." }; {print $1+1,0,0}') | |
sed -i '1i'"$(_release_note)"'\n' RELEASE_NOTES.md | |
sed -i '1i## '"$new_release_ver"' ('"$(Date -I)"') ' RELEASE_NOTES.md | |
fi | |
if [[ $1 == '-m' || $1 == '--minor' ]] | |
then | |
new_release_ver=$(echo $release_ver | awk 'BEGIN { FS = "."; OFS = "." }; {print $1,$2+1,0}') | |
sed -i '1i'"$(_release_note)"'\n' RELEASE_NOTES.md | |
sed -i '1i## '"$new_release_ver"' ('"$(Date -I)"') ' RELEASE_NOTES.md | |
fi | |
_release_date_fix | |
echo 'updated release date ('"$(_release_date)"')' | |
jira_id_present=$(cat RELEASE_NOTES.md | grep "$(jira_id)" -o) | |
if [[ $1 == '-n' || $1 == '--notes' || $(jira_id) != ${jira_id_present} ]] | |
then | |
_release_note_fix | |
echo 'updated release notes ('"$(_release_note)"')' | |
fi | |
unix2dos RELEASE_NOTES.md | |
} | |
#not working... | |
#function nuget_package(){ | |
#rg 'let packageName' | awk -F '"' '{print $2}' | awk -F '.' -v OFS='.' '{print $1,$2}' | |
#} | |
#not working... |
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
[user] | |
name = Alan Ball | |
email = alan.ball@lexisnexisrisk.com | |
email = vash.arclan@gmail.com | |
[alias] | |
undo=reset --soft HEAD^ | |
graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f" | |
dot = ! git graphviz | dot -Tpng > ~/commits.png | |
svg = ! git graphviz | dot -Tsvg > ~/commits.svg | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
tg = lg --topo-order | |
yeet = push | |
yoink = pull | |
windex = clean -nfdx | |
wipe = clean -fdx | |
ammend = commit --amend; echo "amend" | |
amend = commit --amend | |
#get = "!f() { mkdir -p $1; cd $1; git clone --depth 1 --branch $1 $2; cd ..; }; f" | |
#template = get fi-template-develop | |
#develop = get develop | |
#badd = "!f() { remote set-branches --add origin $1; git fetch -u origin $1:$1; }; f" | |
fu = ! git fetch -u origin $1:$1 | |
current = symbolic-ref --short -q HEAD | |
#murge = ! git fetch -u origin $1:$2 | |
#workdev = ! git work $1 develop | |
# $2 -> $(git check $1) | |
berry = "!f() { git rev-list --grep=$1 --reverse --no-merges --author=\"Alan Ball\" $(git check $1); }; f" | |
basket = "!f() { git rev-list --grep=$1 --no-merges --author=\"Alan Ball\" $(git check $1) --pretty='short'; }; f" | |
pick = cherry-pick --stdin | |
check = "!f(){ git branch --format '%(refname:short)' | grep $1 ; }; f" | |
[pull] | |
rebase = false | |
[push] | |
autoSetupRemote = true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://git.wiki.kernel.org/index.php/Aliases#Use_graphviz_for_display