Skip to content

Instantly share code, notes, and snippets.

@kjpark
Created January 28, 2024 02:22
Show Gist options
  • Select an option

  • Save kjpark/4b68b69b73c49849e6588956d1192d84 to your computer and use it in GitHub Desktop.

Select an option

Save kjpark/4b68b69b73c49849e6588956d1192d84 to your computer and use it in GitHub Desktop.
mkcd - make and cd into a directory in one go!
mkcd() { mkdir -p "$@" && cd "$@" ; }
@kjpark
Copy link
Author

kjpark commented Jan 28, 2024

mkcd a combination of mkdir and cd

This is linked from my blog post on the subject of making a directory and changing into it with one line.

Installation

Use my redirect URL (easier to remember than finding this gist) and add it to your rc!

curl -L ascode.com/mkcd >> ~/.bashrc

Usage

$ ### using FULL PATH
$ mkcd /path/to/foobar
$ pwd
/path/to/foobar

$  ### using a DIRNAME
$ mkcd babayaga
$ pwd
/path/to/foobar/babayaga

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