87
63

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mkdirとcdを同時に

Last updated at Posted at 2014-04-16
$ mkdir -p xxx/yyy; cd xxx/yyy

って面倒だなと思いながらやってましたが、やっぱり面倒だなと。
調べてみるといくつか方法がありました。

2つ目の方を使うことにしました。

$ vi .bash_profile
function mkdircd () { mkdir -p "$@" && eval cd ""$$#""; }



$ mkdircd xxx/yyy


---

\$_ を使うだけでも便利ですね。ていうか、\$_なんてのがあるんですね。

$ mkdir -p xxx/yyy; cd $_



参考にしたサイト

mkdirとcdを同時に実行したい時
> 
http://blog.tstylestudio.com/2013/06/26/mkdir%E3%81%A8cd%E3%82%92%E5%90%8C%E6%99%82%E3%81%AB%E5%AE%9F%E8%A1%8C%E3%81%97%E3%81%9F%E3%81%84%E6%99%82/

>```
mkdir XXX && cd $_

$ ~/bin/mkcd.sh
#!/bin/sh
mkdir $1 && cd $_
$ chmod u+x ~/bin/mkcd.sh
alias mkcd='source ~/bin/mkcd.sh'



Hack 3. 1つのコマンドで mkdir と cd を実行する
> http://d.hatena.ne.jp/bobchin/20090401/1238557613

> ```
$ vi .bash_profile
function mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
87
63
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
87
63

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?