diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-08-16 16:49:30 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-08-16 16:49:30 +0200 |
commit | 68931fdf3e94c9e0096c151f57d9ee99acb5f8e3 (patch) | |
tree | 004d76ea4e9424705ce20b33f045522b41ed79a3 /shellrc | |
parent | 9d0e379976e7fd2358ae43f0fc6d27450c3f3baa (diff) | |
download | myconfigs-68931fdf3e94c9e0096c151f57d9ee99acb5f8e3.tar.gz myconfigs-68931fdf3e94c9e0096c151f57d9ee99acb5f8e3.tar.bz2 myconfigs-68931fdf3e94c9e0096c151f57d9ee99acb5f8e3.zip |
Some more shell utility function
Diffstat (limited to 'shellrc')
-rw-r--r-- | shellrc | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -57,12 +57,35 @@ genpasswd() { # Clip stdin to clipboard clip() { - xclip -selection clipboard + # Note: printf as magic to remove trailing new lines + printf %s "$(cat)" | xclip -selection clipboard } # Clip current HEAD hash to clipboard +# Optionally you can pass commit as argument gitclip() { - git rev-parse HEAD | clip + [ -n "$1" ] && local CMT="$1" || local CMT=HEAD + git rev-parse "$CMT"| clip +} +# Clip current head message to clipboard +# Optionally you can pass commit as argument +gitmclip() { + [ -n "$1" ] && local CMT="$1" || local CMT=HEAD + git log --format=%B -n 1 "$CMT" | clip +} + +# Automatic branch merger (merge branch, push it to server and remove branch) +# Expects name of the branch as argument +gitbmerge() { + ( + set -e + local WT="$(git worktree list | sed -nE "/\[$1\]/{s/([^ ]+) .*/\1/p}")" + if [ -n "$WT" ]; then + rm -r "$WT" + git worktree prune + fi + git merge "$1" && git push && git branch -d "$1" && git push origin :"$1" + ) } # Make screenshot |