Skip to content

Instantly share code, notes, and snippets.

@kako-jun
Last active March 7, 2019 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kako-jun/ee07e8f4ada6ff3f16d7bbe70c3c68a5 to your computer and use it in GitHub Desktop.
Save kako-jun/ee07e8f4ada6ff3f16d7bbe70c3c68a5 to your computer and use it in GitHub Desktop.
gitpのREADME下書き

kako-junです

好きな聖地は 高岡古城公園です


gitpのREADME.mdを下書くよー


いかにもパーソナルユースな例えの絵。うがーー

git-fool 行儀が悪い git-rude

gitp pull で全リポジトリという意味 一括pullだけでも使えるかも

gitp_config.json

全部checkout . 全部git status もできる

git-foobar は使わない。 環境は汚さない

gitp clone gitp remote add gitp config user gitp pull gitp push 全てのenabledなリポジトリに同じ動作を指定したことになる

gitp clone [repository name] gitp remote add [repository name] gitp config user [repository name] gitp pull [repository name] gitp push [repository name] 1つのenabledなリポジトリに同じ動作を指定したことになる

gitp [repository name] clone hoge gitp [repository name] pull origin master gitp [repository name] add -A gitp [repository name] commit -m update. gitp [repository name] push origin master

gitp [repository name] remote add public gitp [repository name] checkout . cdandで実行される

[repository name]として使えない言葉 clone、remote、config、pull、push、on、off、add、remove

gitp -a checkout . が便利

gitp -a status がすごく便利

全てのリポジトリに同じコマンドを実行する

[repository name]はタブで補完が効くので便利 末尾についてしまう/は自動的に消去される

README_ja.md

English

🍼 gitp

Build Status

gitp は、シンプルなコマンドラインツールです

カレントディレクトリにしか効果の及ばないコマンド(gityarn など)を、カレントディレクトリを変更することなく実行します

Goで書かれているため、多くのOSで動作します

 

Description

Demo

demo

VS.

「カレントディレクトリを移動してからでなければ、実行できないコマンド」は多くあります

例えば、pwd

$ pwd

/media/removable/SD Card/current

$ pwd subdir/subsubdir

/media/removable/SD Card/current

 

cdand を使うと、簡潔に書けます

$ cdand subdir/subsubdir pwd

/media/removable/SD Card/current/subdir/subsubdir

使わない場合、カレントディレクトリが変化してしまうため、戻るコマンドが必要になります

$ cd subdir/subsubdir; pwd
$ cd ../..

cdand にPATHを通すことで、cd ../.. にお別れできます

 

Installation

Requirements

  • Operating System

    • macOS
    • Linux

Download binaries

go get

$ go get github.com/kako-jun/gohat

 

Features

Usage

$ gohat foo.sh

 

「なぜこれが便利なのか……?」の例を、以下に挙げます

Examples

e.g. Gitリポジトリのディレクトリに cd する必要がない
$ cdand your/git/repository git status
e.g. Nodeプロジェクトのディレクトリに cd する必要がない
$ cdand your/node/project yarn

 

つまり、実行ディレクトリを変えるオプションを、コマンドごとに覚える必要がなくなります

カレントディレクトリ以外で実行するオプションとして、

  • git には -C オプションが
  • node には -prefix-cwd オプションが

それぞれあります

でも覚えにくいです

 

$ (cd subdir/subsubdir; ls)

という書き方もあります

でも面倒です

 

cdand ならば cd と打ち、「あ……めんどいな……」と思ったら and と打ち足せばイイだけです

その後、ディレクトリ名を打つ時には cd と同じくTABでの補完が効くため、違和感なく高速に打てます

 

e.g. おまけ

cdand 自身を入れ子にして呼べます

$ cdand subdir cdand .. ls

特にメリットはありませんが、可能です

 

Unsupported

端末の文字色変更の効果は失われる

ls -G でも色はつきません

1コマンドで完結しないコマンドは呼べない

vim は起動しますが、端末に表示されません

less は起動しますが、ページ送りはできません

対話型コマンドも対話できず、結果がまとめて表示されます

パイプ、リダイレクトの対象は、cdand コマンド自身である

例えば、

$ cdand subdir cat my_secrets.txt | grep treasure

と書いた場合、

$ cdand subdir cat my_secrets.txt

した結果をカレントディレクトリで

$ grep treasure

するという意味になります

パイプの場合、それでも特に結果は変わらないでしょう

 

しかし、リダイレクトの場合、結果が変わります

$ cdand subdir cat my_secrets.txt > my_will.txt

を実行すると、my_will.txt が作られるのは subdir 内でなく、カレントディレクトリ内です

 

どうしても subdir 内に作りたい場合は

cat my_secrets.txt > my_will.txt

という内容の foo.sh ファイルを作って subdir 内に置き、

$ cdand subdir foo.sh

とすれば可能です (あまり意味はない気もしますが……)

 

Coding

import "github.com/kako-jun/gohat/gohat-core"

gohat.Exec()

Contributing

Pull Requestを歓迎します

  • gohat をより便利にする機能の追加
  • より洗練されたGoでの書き方
  • バグの発見、修正
  • もっと良い英訳、日本語訳があると教えたい

など、アイデアを教えてください

 

Authors

kako-jun

License

This project is licensed under the MIT License.

See the LICENSE file for details.

Acknowledgments

  • Go
  • and you

README.md

日本語はこっち (Let's try reading in Japanese.)

🍼 gitp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment