Space2underscore
A CLI tool that converts spaces into underscores. Useful for creating or renaming Git branches.
Requirements
- Ruby >= 2.4.0
- Git
Installation
$ gem install space2underscore
Usage
Create a new branch
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'
Rename an existing branch
Use $(s2u ...) as a subcommand.
$ git branch -m $(s2u renamed branch)
Print the converted string
Without any options, the converted string is printed to stdout. By default, the output is downcased.
$ s2u Hello World
hello_world
Preserve original case
Use the -r (--raw) option to keep the original letter casing.
$ s2u Hello World -r
Hello_World
Options
| Option | Short | Description |
|---|---|---|
--create |
-c |
Create a new Git branch with the converted name |
--raw |
-r |
Preserve original letter casing (skip downcase) |
Caution
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.
License
MIT License - Copyright (c) 2014 Satoshi Ohmori