LoginSignup
0
0

More than 1 year has passed since last update.

エイリアスの設定方法 Mac

Posted at

エイリアスの設定方法 Mac

エイリアスを利用して、長いコマンドを短くする。

打つのがだるい、間違える、何回も利用するコマンドや、そもそも長くて覚えられないものにおすすめ。

やり方

macのホームディレクトリにある.zshrcをいじる。

.zshrcの最後に

alias e='echo hello!'

とかを.zshrc内に書き込んでやると、コマンドラインで$ eとするだけでhello!が出力される。

引数を取りたい場合、(){}の中におくことで、$1とかで受け取ることができる。

下の例は競プロの便利ツールであるonline-judge-toolsのテスト実行を簡略化しているもの。

競プロで焦っている中で $ oj t -c "cargo run --bin a” とか打たないといけないものが、
$ t 実行名 だけの入力で良くなる!

alias t='(){oj t -c "cargo run --bin $1"}'
0
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
0
0