-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
43 lines (38 loc) · 1.19 KB
/
.bash_aliases
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
alias ls='ls --color=auto'
alias g='git'
alias b='git b'
function peco-select-history() {
local tac
which gtac &> /dev/null && tac="gtac" || \
which tac &> /dev/null && tac="tac" || \
tac="tail -r"
READLINE_LINE=$(HISTTIMEFORMAT= history | $tac | sed -e 's/^\s*[0-9]\+\s\+//' | awk '!a[$0]++' | peco --query "$READLINE_LINE")
READLINE_POINT=${#READLINE_LINE}
}
bind -x '"\C-r": peco-select-history'
function peco-ghq-cd() {
local selected_file=$(ghq list --full-path | peco --query "$LBUFFER")
if [ -n "$selected_file" ]; then
if [ -t 1 ]; then
echo ${selected_file}
cd ${selected_file}
fi
fi
}
alias gl=peco-ghq-cd
function peco-git-add() {
local selected=$(git status -s | peco | awk '{print $2}')
if [ -n "$selected" ]; then
selected=$(tr '\n' ' ' <<< "$selected")
git add $selected
fi
}
alias gadd=peco-git-add
function peco-git-checkout () {
local selected_branch=$(git branch --list --no-color | colrm 1 2 | peco)
if [ -n "$selected_branch" ]; then
selected=$(tr '\n' ' ' <<< "$selected_branch")
git checkout $selected
fi
}
alias gco=peco-git-checkout