A CLI tool that converts spaces into underscores. Useful for creating or renaming Git branches.
- Ruby >= 2.4.0
- Git
$ gem install space2underscore
Use the -c (--create) option to create a new Git branch with spaces converted to underscores.
$ s2u new branch -c
=> Switched to a new branch 'new_branch'
Use $(s2u ...) as a subcommand.
$ git branch -m $(s2u renamed branch)
Without any options, the converted string is printed to stdout. By default, the output is downcased.
$ s2u Hello World
hello_world
Use the -r (--raw) option to keep the original letter casing.
$ s2u Hello World -r
Hello_World
| Option | Short | Description |
|---|---|---|
--create |
-c |
Create a new Git branch with the converted name |
--raw |
-r |
Preserve original letter casing (skip downcase) |
This is a command line tool. DO NOT include this module in other Ruby applications, as it uses the system command internally, which may introduce command injection vulnerabilities.
MIT License - Copyright (c) 2014 Satoshi Ohmori