Skip to content

Instantly share code, notes, and snippets.

@kako-jun
Last active March 7, 2019 16:18
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/0ac11564eb67aada6766bf85b44058f1 to your computer and use it in GitHub Desktop.
Save kako-jun/0ac11564eb67aada6766bf85b44058f1 to your computer and use it in GitHub Desktop.
cdandのREADME下書き

kako-junです

好きなLinuxコマンドは reboot です


cdandのREADME.mdを下書くよー


README_ja.md

English

📁 cdand

Build Status

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

カレントディレクトリにしか効果の及ばないコマンド(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

    • Windows
    • macOS
    • Linux

Download binaries

go get

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

 

Features

Usage

$ cdand subdir/subsubdir ls -alF

drwxrwxr-x.  2 kako-jun kako-jun 4096  Apr  2 04:20 ./
drwxr-xr-x. 10 kako-jun kako-jun 4096  Apr  2 04:20 ../
-rw-rw-r--.  1 kako-jun kako-jun    0  Apr  2 04:20 my_secrets.txt

 

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

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での補完が効くため、違和感なく高速に打てます

$ cdand .. git pull

親方向に使っても便利

 

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/cdand/cdand-core"

cdand.Exec("subdir/subsubdir", "ls", "-alF")

Contributing

Pull Requestを歓迎します

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

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

 

Authors

kako-jun

🍋 Lemonade stand

下のリンクから、Amazonギフト券(Eメールタイプ)を送ってください

「受取人」欄には kako.hydrajin@gmail.com と入力してください

♥️ Donate

  • 「メッセージ」欄を使って、感想を伝えることもできます
  • 送り主が誰かは分かりません
  • ¥15 から送れます

 

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.)

📁 cdand

Build Status

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

カレントディレクトリにしか効果の及ばないコマンド(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

    • Windows
    • macOS
    • Linux

Download binaries

go get

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

 

Features

Usage

$ cdand subdir/subsubdir ls -alF

drwxrwxr-x.  2 kako-jun kako-jun 4096  Apr  2 04:20 ./
drwxr-xr-x. 10 kako-jun kako-jun 4096  Apr  2 04:20 ../
-rw-rw-r--.  1 kako-jun kako-jun    0  Apr  2 04:20 my_secrets.txt

 

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

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での補完が効くため、違和感なく高速に打てます

$ cdand .. git pull

親方向に使っても便利

 

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/cdand/cdand-core"

cdand.Exec("subdir/subsubdir", "ls", "-alF")

Contributing

We're always looking for new contributing finding bugs, fixing issues, or writing some docs.

Pull Requestを歓迎します

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

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

 

Authors

kako-jun

🍋 Lemonade stand

Please open below, and enter kako.hydrajin@gmail.com into 'To' box.

♥️ Donate

  • Tell me your impressions in 'Message' box.
  • The sender is hidden.
  • From $1

 

License

This project is licensed under the MIT License.

See the LICENSE file for details.

Acknowledgments

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