LoginSignup
5
5

More than 5 years have passed since last update.

Bash/Zshで、個人的に有用だと思っているエイリアス

Last updated at Posted at 2016-09-28

記事にするのがはばかられるくらい小ネタだが、前から設定しておけば良かったと思ったので

列の合計値

alias sum="awk '{a+=\$1}END{print a}'"

# 使い方
% seq 1 10
1
2
3
4
5
6
7
8
9
10

% seq 1 10 | sum
55

平均があれば合計も欲しいよね

alias ave="awk '{a+=\$1}END{print a/NR}'"
# 使い方

% seq 1 10 | ave
5.5

クリップボード

alias cl='xsel -ib'
alias clp='xsel -ob'

Windows用の苦肉の策

to_dos(){
    iconv -f utf8 -t sjis | perl -pe 's/\n/\r\n/' < /dev/stdin
}

# 使い方
% echo あ | to_dos              
Ƃ͉

その他

alias now='date +%Y%m%d_%H%M%S'
alias glook='cd $(ghq root)/$(ghq list | peco)'
alias ycal='cal `date +%Y`'
5
5
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
5
5