-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpeco.fish
44 lines (37 loc) · 1.24 KB
/
peco.fish
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
function gho --description "open remote github repository interactively"
open https://(ghq list | peco --layout=bottom-up)
end
function ltcp --description "list listening TCP ports"
sudo lsof -nP -iTCP -sTCP:LISTEN | peco
end
function pk --description "pkill a process interactively"
ps aux | peco | awk '{ print $2 }' | xargs kill
end
function ppk --description "kill -9 a process interactively"
ps aux | peco | awk '{ print $2 }' | xargs kill -KILL
end
function pp --description "grep a process interactively"
ps aux | peco | awk '{ print $2 }'
end
function _peco_change_directory
if [ (count $argv) ]
peco --layout=bottom-up --query "$argv " | perl -pe 's/([ ()])/\\\\$1/g' | read foo
else
peco --layout=bottom-up | perl -pe 's/([ ()])/\\\\$1/g' | read foo
end
if [ $foo ]
builtin cd $foo
commandline -r ''
commandline -f repaint
else
commandline ''
end
end
function peco_change_repo --description "Change working repository"
begin
ghq list -p
ls -ad * | perl -pe "s#^#$PWD/#" | grep -v \.git
ls -ad $HOME/projects/* | grep -v \.git
end | sed -e 's/\/$//' | awk '!a[$0]++' | _peco_change_directory $argv
end
bind \co peco_change_repo