/cdand

a CLI command that makes it possible to execute every commands in your target directory without `cd`

Primary LanguageGoMIT LicenseMIT

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

📁 cdand

Build Status

cdand is a simple CLI command.

It can launch every commands(e.g. git, yarn) in your target directory without cd.

It's written in Go, so it will work on many operating systems.

Description

Demo

demo

VS.

There are many commands that expect you already changed the current directory before launch.

For example, pwd.

$ pwd

/media/removable/SD Card/current

$ pwd subdir/subsubdir

/media/removable/SD Card/current

By using cdand, you can type simply.

$ cdand subdir/subsubdir pwd

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

If you don't use cdand, there is no way to get expected results without changing the current directory.

And one more command will be required to restore the current directory.

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

By adding cdand to PATH, you can say good-bye to 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

"Why is cdand useful?" Here are the examples.

Examples

e.g. No need to call cd before executing Git commands.
$ cdand your/git/repository git status
e.g. No need to call cd before executing Node commands.
$ cdand your/node/project yarn

The point is, you don't need to care the difference between options of each command.

e.g.

  • -C option of git
  • -prefix, -cwd options of node

They are hard to remember, aren't they?

How is the following?

$ (cd subdir/subsubdir; ls)

It's a cool way for who likes typing many brackets.

After you typed cd, if you saw a troublesome future, let's append and.

After that, use TAB key to autocomplete the target directory name.

$ cdand ../sister_project npm install

It's also helpful to keep indoors(subdirectory).

e.g. appendix

cdand can be called recursively.

$ cdand subdir cdand .. cdand subdir cdand .. ls

Ummmm...are there any merits? (Probably nothing.)

Unsupported

Coloring on stdout will be disabled.

e.g. ls -G

For incomplete commands, you may get unexpected results.
  • vim can launch, but not shown in terminal.
  • less can launch, but cannnot paging.
  • The stdout from interactive command is shown at the same time.
The target of pipe and redirect is cdand itself.

For example, in case you type as below

$ cdand subdir cat my_secrets.txt | grep treasure

At first,

$ cdand subdir cat my_secrets.txt

runs.

Next,

$ grep treasure

runs for the first result.

In pipe case, the above order may not be a problem.

But in redirect case, a problem occurs.

$ cdand subdir cat my_secrets.txt > my_will.txt

my_will.txt isn't created in subdir but in the current directory.

If you want to get it in subdir, you have to create a script as below.

cat my_secrets.txt > my_will.txt

And put the above script in subdir.

Lastly,

$ cdand subdir foo.sh

But it probably has no benefit... 😭

Coding

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

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

Contributing

I'm always looking for new contributing.

  • Adding features
  • Overwriting with better code
  • Finding (and fixing) bugs
  • Improving translation

Authors

kako-jun

🍋 Lemonade stand

Your donation turns into my cat's food.

Please open the following link, 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