-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc_custom.sh
73 lines (66 loc) · 2.21 KB
/
.bashrc_custom.sh
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
# go development
# export PATH=$PATH:/usr/local/go/bin
# export GOPATH=/Users/mzahor/src/go
# export PATH=$PATH:$GOPATH/bin
# python development
# VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
# export WORKON_HOME=$HOME/.virtualenvs
# export PROJECT_HOME=$HOME/src
# source /usr/local/bin/virtualenvwrapper.sh
# git stuff
function make_pullrequest {
if [ -z "$1" ]; then
printf "specify branchname"
return 1;
fi
BR=`git rev-parse --abbrev-ref HEAD`
git diff HEAD..origin/master
read -n1 -r -p "Press 'y' to continue... " key;
if [ "$key" = 'y' ]; then
git co -b "$1" && git push -u origin "$1" && git co "$BR";
fi
# git br -d $1 #delete after successful request
}
# fbr - checkout git branch (including remote branches)
fbr() {
local branches branch
branches=$(git branch --all | grep -v HEAD) &&
branch=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
# fshow - git commit browser
fshow() {
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort \
--bind "ctrl-m:execute:
(grep -o '[a-f0-9]\{7\}' | head -1 |
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
{}
FZF-EOF"
}
# fshow - git commit browser
fshow() {
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" |
fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort \
--bind "ctrl-m:execute:
(grep -o '[a-f0-9]\{7\}' | head -1 |
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
{}
FZF-EOF"
}
# fcs - get git commit sha
# example usage: git rebase -i `fcs`
fcs() {
local commits commit
commits=$(git log --color=always --pretty=oneline --abbrev-commit --reverse) &&
commit=$(echo "$commits" | fzf --tac +s +m -e --ansi --reverse) &&
echo -n $(echo "$commit" | sed "s/ .*//")
}
alias pr=make_pullrequest
alias gpo="git push -u origin \`git rev-parse --abbrev-ref HEAD\`"
alias g=git
alias ni="npm i"
alias s="npm start"