Skip to content

Instantly share code, notes, and snippets.

@nocash
Last active March 31, 2017 20:00
Show Gist options
  • Save nocash/773fc18d529e4c11e4e9f5e86c8884b2 to your computer and use it in GitHub Desktop.
Save nocash/773fc18d529e4c11e4e9f5e86c8884b2 to your computer and use it in GitHub Desktop.
Easily create branch names from pasted story titles.
[alias]
br- = "!f() { git branch $(dasherize \"$@\"); }; f"
cob- = "!f() { git checkout -b $(dasherize \"$@\"); }; f"
#!/bin/bash
echo -n "$@" \
| tr '[:upper:]' '[:lower:]' \
| tr '_' ' ' \
| tr -d '[:punct:]' \
| tr -s '[:space:]' '-'
@nocash
Copy link
Author

nocash commented Mar 31, 2017

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.

@nocash
Copy link
Author

nocash commented Mar 31, 2017

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