-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeco.config
109 lines (99 loc) · 2.96 KB
/
peco.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# http://www.pupha.net/archives/2267/
function peco-select-history
set -lx cmd `history -500 | tail -r | peco | cut -d ' ' -f 1`
if [ "$cmd" != "" ]
# r $cmd
echo $cmd
return 0;
end
return -1;
end
alias phist='peco-select-history'
# http://nishikawasasaki.hatenablog.com/entry/2013/10/29/221908
# peco を使って cd 履歴の中からディレクトリを選択
# 過去の訪問回数が多いほど選択候補の上に来る
function peco_cd_history
sort $CD_HISTORY_FILE | uniq -c | sort -r | sed -e 's/^[ ]*[0-9]*[ ]*//' | peco | read -l pecoCDhistory
if [ $pecoCDhistory ]
# commandline 'cd '
# commandline -i $pecoCDhistory
echo 'cd' $pecoCDhistory
cd $pecoCDhistory
echo $pecoCDhistory
commandline -f repaint
else
commandline ''
end
end
alias pcd=peco_cd_history
# https://github.com/oh-my-fish/plugin-peco/blob/master/functions/peco_kill.fish
function peco_kill
ps ax -o pid,time,command | peco --query "$LBUFFER" | awk '{print $1}' | xargs kill
end
alias pkill=peco_kill
# https://github.com/oh-my-fish/plugin-peco/blob/master/functions/peco_select_history.fish
function peco_select_history
if test (count $argv) = 0
set peco_flags --layout=bottom-up
else
set peco_flags --layout=bottom-up --query "$argv"
end
history|peco $peco_flags|read foo
if [ $foo ]
commandline $foo
else
commandline ''
end
end
alias phist=peco_select_history
alias pgco='br_fmt | xargs git checkout'
alias pgcob='pgco -b'
alias pgmg='br_fmt | xargs git merge'
alias pgmgs='pgmg --squash'
alias pgpl='br_fmt | xargs git pull origin'
alias pgps='br_fmt | xargs git push origin'
alias pgbd='br_fmt | xargs git branch -d'
alias pgbD='br_fmt | xargs git branch -D'
alias pgb='git branch -a | peco'
alias pgbd_remote='br_fmt | xargs git push --delete origin'
alias pgrb='br_fmt | xargs git pull --rebase origin'
alias pgl='br_fmt | xargs git log'
alias pglp='pgl -p'
alias pgd='br_fmt | xargs git diff'
alias pls='ls -AaR | peco'
alias pfind='find -L . -name "*" | peco'
alias pps='ps aux | peco'
alias pkill='ps ax | peco | awk "{ print $1 }" | xargs kill'
alias pvi='pfind | xargs VI'
alias popen='pfind | xargs open'
alias pless='pfind | xargs less'
# http://qiita.com/itkrt2y/items/0671d1f48e66f21241e2
# alias pghq='cd $(ghq root)/$(ghq list | peco)'
# # Gitのブランチをpecoで扱えるように整形
function br_fmt
git branch -a | peco | xargs echo | sed -e 's/\*//' | sed -e 's/remotes\/origin\///'
end
function br_fmt_remote
br_fmt | xargs echo | awk '{printf("%s%s\n", "remotes/origin/", $0)}'
end
function pgmg-remote
br_fmt_remote | xargs git merge
end
function pgmgs-remote
br_fmt_remote | xargs git merge --squash
end
function pgl-remote
br_fmt_remote | xargs git log
end
function pglp-remote
br_fmt_remote | xargs git log -p
end
function pglst-remote
br_fmt_remote | xargs git log --stat
end
function pgd-remote
br_fmt_remote | xargs git diff
end
function pgdn-remote
br_fmt_remote | xargs git diff --name-status
end