-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
70 lines (59 loc) · 1.75 KB
/
bashrc
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
# set alias
alias v='nvim'
alias l='ls -ltr'
alias la='ls -a'
alias ll='ls -l'
alias g='git'
alias gs='git status -sb'
alias gch='git checkout'
alias gd='git diff'
alias gl="git log --graph --pretty=format:'%Cblue%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias ga='git add'
alias gc='git commit'
alias d='docker'
alias dc='docker compose'
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
[ -f "${HOME}/bash-completion" ] && source "${HOME}/bash-completion"
# cd dir by fzf
fd() {
local dir
dir=$(find ${1:-.} -path '*/\.*' -prune \
-o -type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
}
# git checkout by fzf
fch() {
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/[^/]*/##")
}
# git remote checkout by fzf
fchr() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
# docker exec bash by fzf
dbash() {
local name
name=$(docker ps --format "{{.Names}}" | fzf-tmux)
docker exec -it $name bash
}
# cd git repository by fzf
fghq() {
local repo
repo=$(ghq list | fzf-tmux)
cd $(ghq root)/$repo
}
# prompt settings
source ~/dotfiles/git-prompt.sh
PS1_USER="\[\e[1;39;46m\] \h "
PS1_DIR="\[\e[1;39;44m\] \W "
PS1_GIT='\[\e[1;39;46m\]$(__git_ps1 " %s ")'
PS1_BLUE="\[\e[0;34;49m\] $ "
PS1_WHITE="\[\e[0;39;49m\]"
export PS1=$PS1_USER$PS1_DIR$PS1_GIT$PS1_BLUE$PS1_WHITE