Last active
March 31, 2017 20:00
-
-
Save nocash/773fc18d529e4c11e4e9f5e86c8884b2 to your computer and use it in GitHub Desktop.
Easily create branch names from pasted story titles.
This file contains hidden or 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] | |
br- = "!f() { git branch $(dasherize \"$@\"); }; f" | |
cob- = "!f() { git checkout -b $(dasherize \"$@\"); }; f" |
This file contains hidden or 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 | |
echo -n "$@" \ | |
| tr '[:upper:]' '[:lower:]' \ | |
| tr '_' ' ' \ | |
| tr -d '[:punct:]' \ | |
| tr -s '[:space:]' '-' |
You'll probably want to rename the git aliases to something that makes more sense to you. Or you could ignore the aliases and change the dasherize script to create the branch.
The aliases aren't smart enough to allow for additional option flags to be passed in so watch out for that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dasherize
script needs to be made executable (chmod +x
) and put in your PATH. Add Git aliases to your.gitconfig
.