-
Notifications
You must be signed in to change notification settings - Fork 1
/
.functions.zsh
57 lines (51 loc) · 1.04 KB
/
.functions.zsh
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
# Open file in EDITOR
function e() {
if [ "$1" = "" ]
then
exec $EDITOR .
else
exec $EDITOR "$1"
fi
}
# Switch projects
function p() {
proj=$(ls ~/Projects | fzf --query="$1")
if [[ -n "$proj" ]]; then
cd ~/Projects/$proj
clear
fi
}
# Tail development log
function log(){
tail -f -n 100 log/development.log
}
# Detect empty enter, execute git status if in git dir
magic-enter () {
if [[ -z $BUFFER ]]; then
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo -ne '\n'
git status -s
else
lsa
fi
zle accept-line
else
zle accept-line
fi
}
zle -N magic-enter
bindkey "^M" magic-enter
f() {
eval $(([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
}
fe() {
local file
file=$(fzf --query="$1" --select-1 --exit-0)
[ -n "$file" ] && ${EDITOR:-vim} "$file"
}
go() {
local branches branch
branches=$(git branch -vv) &&
branch=$(echo "$branches" | fzf +m) &&
git checkout $(echo "$branch" | awk '{print $1}' | sed "s/.* //")
}