LoginSignup
67
63

More than 5 years have passed since last update.

よく設定されていないalias8選!

Last updated at Posted at 2016-01-25

概要

前回のよく設定されているaliasの続編として今回よく設定されていないんだけど、便利なaliasを紹介していきます。選定基準はGithubから「alias」で検索をかけ独断と偏見で選んでいます。
※今回Macでのaliasを想定しています

alias一覧

1. alias hs='history | grep '

そういえばこれまで過去入力したコマンドを調べる時に、history | grep ◯◯はかなりの回数実行してきましたが、これを設定しておけば楽ですね。。早くに設定しておけばよかった。

$ hs git
  590  git push origin master
  596  git add .
  597  git commit -m "test"
  597  git push origin master
  608  git shortlog -n -s

2. alias ql="qlmanage -p 2>/dev/null"

ファイル名を引数としてMacのquick lookでそのファイルを確認でます。いちいちFinderを起動しなくても、ターミナル上から起動できるので作業効率がアップします。

3. alias mute='/usr/bin/osascript -e "set volume 0"'

ボリュームをmuteにします。Macであれば、専用のキーを押せばいいんですがw
何か他のコマンドと組み合わせた時に、威力を発揮するかもですね。

4. alias reload='source ~/.bashrc'

bashrcの設定を変更した際にreloadとうつと反映されるようになります。

5. alias pwp='pwd|pbcopy'

カレントディレクトリのパスをクリップボードにコピーします。

6. alias imgdim='sips -g pixelHeight -g pixelWidth $1'

macの固有のコマンドのsipsを使って指定した画像ファイルの縦横サイズを調べます。

$ imgdim 画像ファイル名
  pixelHeight: 56
  pixelWidth: 309

7. alias gip="curl -s checkip.dyndns.org | sed -e 's/.Current IP Address: //' -e 's/<.$//'"

GIPの確認が行えます。

8. alias clock='while :; do printf "%s\r" "$(date +%T)"; sleep 1 ; done'

現在の時間を表示して、1秒間隔で更新します。

まとめ

今回出てきたものをまとめますと下記になります。よければコピーしてご利用ください。

alias hs='history | grep '
alias ql="qlmanage -p 2>/dev/null"
alias mute='/usr/bin/osascript -e "set volume 0"'
alias reload='source ~/.bashrc'
alias pwp='pwd|pbcopy'
alias imgdim='sips -g pixelHeight -g pixelWidth $1'
alias gip="curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'"
alias clock='while :; do printf "%s\r" "$(date +%T)"; sleep 1 ; done'
67
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
67
63