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.

bashのaliasの簡潔な設定方法

Last updated at Posted at 2019-10-14

目的

毎回alias追加しようとしたときに忘れるので、簡潔に備忘録としてまとめて書く。
個人的にはclipy使うより2文字ぐらいのaliasでパパッと書くほうが早い気がするのでaliasはよく使ってます。

設定の流れ

1 . vi ~/.bashrcで下記のようにエイリアスを設定して、保存する。

.sh
# alias <設定したいalias>='<元のコマンド>'
alias dc='docker-compose'
alias ch='git checkout'
alias br='git branch'

2 . vi ~/.bash_profile実行後、下記のように設定を追加し、保存する。

.sh
# .bash_profile はターミナル起動時に読み込まれるファイルなので、 .bashrc をここから読み込むように設定しておく
source ~/.bashrc

3. source ~/.bash_profile実行で.bashrcの編集内容を読み込む。

terminalを再起動してもOK

alias追加時は1, 3のみでOK

以上。

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?