Low commit activity in last 3 years
A long-lived project that still receives updates
Change the space into underscore
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 0
>= 0
~> 1.0
 Project Readme

Space2underscore

A CLI tool that converts spaces into underscores. Useful for creating or renaming Git branches.

Gem Version CI Code Climate Coverage Status Gem Downloads

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