-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc
114 lines (90 loc) · 3.58 KB
/
dot_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# vi: ft=bash
# Add bin to path always so that ssh command can exec these directly
#export PATH="$HOME/bin/:$PATH"
# This PATH modificatoin will just append to PATH every time. Try to keep PATH
# changes to login script '~/.profile', not for each bash invocation.
# If not running interactively, don't do anything more
[ -z "$PS1" ] && return
export EDITOR=nvim
# Bind ctrl-a to do the opposite of ctrl-z
bind -x '"\C-a":"fg"'
HISTCONTROL=ignoreboth:erasedups
HISTSIZE=10000
HISTFILESIZE=10000
IGNOREEOF=5 # Shell only exists after the 10th consecutive Ctrl-d
shopt -s histappend # keep bash history on shell exit
shopt -s cmdhist # save multi-line commands in one history entry
shopt -s checkwinsize # check window size after each cmd, update LINES COLUMNS
shopt -s globstar # let "**" expansion match files and 0+ (sub)directories
alias gf='git fetch'
alias gs='git status'
alias gd='git diff'
alias ga='git add -u'
alias woman='MANPAGER="nvim +Man!" man'
alias astronvim='NVIM_APPNAME=astronvim nvim'
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
PS1_chroot="${debian_chroot:+($debian_chroot)}"
if [ "$color_prompt" = yes ]; then
PS1_dir='\[\033[01;34m\]\w\[\033[00m\]'
else
PS1_dir='\w'
fi
unset color_prompt
PS1="$PS1_chroot$PS1_dir"'$(__git_ps1 " (%s)")\$ '
GIT_PS1_SHOWUPSTREAM=verbose
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# Find all lines with "property" followed with a line with "memoize" and
# startup vim with the locations in quickfix list:
# Example: git ls-files -z *.py | twogrep property memoize | nvim -c 'cbuffer!'
twogrep() {
xargs -0 awk '/'"$1"'/ {b=NR+1} NR==b && /'"$2"'/ {print FILENAME "|" FNR "|" $0} '
}
ggblame() {
git grep -n "$@" | while IFS=: read i j k; do git blame -L $j,$j $i; done
}
# Use clang as default c/c++ compiler
export CC=clang
export CXX=clang++
# Distributed c and cached build result
export CCACHE_DIR=/local/ccache
export DISTCC_DIR=/local/distcc
export USE_DISTCC=1
_git_jump() { __gitcomp "diff merge grep ws" "" "$cur"; }
eval "$(direnv hook bash)"
eval "$(zoxide init bash)"
export XDG_DATA_HOME="$HOME/.local/share"
export CHEZMOI_HOME="$XDG_DATA_HOME/chezmoi"
export XDG_CONFIG_HOME="$HOME/.config"
source "$XDG_CONFIG_HOME/wezterm/shell-integration.sh" # This makes my prompt very slow
source "$XDG_CONFIG_HOME/broot/launcher/bash/br"
source "$XDG_CONFIG_HOME/fzf/key-bindings.bash"
source "$XDG_CONFIG_HOME/bash/fzf-bash-completion.sh"
bind -x '"\t": fzf_bash_completion'
#export FZF_DEFAULT_OPTS="--no-mouse $FZF_DEFAULT_OPTS"
[ -e "$HOME/mediatek.bash" ] && source "$HOME/mediatek.bash" || true