LoginSignup
4
1

More than 5 years have passed since last update.

mkdirした後にcdしてください、自動で。

Posted at

mkdirしたら当然cdしたいじゃないですか。

だからコマンドにします

$ vi ~/.bashrc
# 追記
alias mkdircd='echo -n "Input directory name that you want to create: ";read DIRNAME;echo -n "You will create ${DIRNAME}. OK? [y/n] ";read YESNO;if [ ${YESNO} == "y" ]; then  mkdir -p ${DIRNAME}; cd ${DIRNAME};fi'

適用します

$ source ~/.bashrc

完成したコマンドがコチラです

$ pwd
/home/vagrant
$ mkdircd
Input directory name that you want to create: test_dir/test
You will create test_dir/test. OK? [y/n] y
$ pwd
/home/vagrant/test_dir/test
4
1
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
4
1