1
0

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.

いなたつAdvent Calendar 2019

Day 13

fishでmkcdコマンドを作る

Last updated at Posted at 2019-12-13

はじめに

いなたつアドカレの十三日目の記事です。

fishでmkcdコマンドを作った解説記事です。

じっそー

function mkcd
  set dirname $argv[1]
  mkdir -p $dirname
  eval "cd" $dirname
end

1行目は関数の宣言ですね。
2行目でdirnameという変数にコマンドライン引数の1つめを代入しています。
3行目で変数dirnameに対してまずはmkdirコマンドを実行し
4行目でevalを使ってcdコマンドを同様にdirnameに対して行っています。

注意事項

  • mkdir の -p は複数階層を一度につくるため
  • evalせずにcdをすると、終了後にパスが戻る
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?