-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
148 lines (133 loc) · 3.41 KB
/
.bashrc
File metadata and controls
148 lines (133 loc) · 3.41 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
export HISTCONTROL=ignoredups:ignorespace
export HISTFILESIZE=
export HISTSIZE=
export HISTFILE=~/.bash_eternal_history
shopt -s checkwinsize
shopt -s histappend
# functions
try_source() {
[[ -f "$1" ]] && source "$1"
}
path_insert() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
fi
}
# paths
path_insert ${HOME}/bin
path_insert ${HOME}/.local/bin
# aliases
alias ls='ls --color=auto -N'
if [[ -x $(command -v eza) ]]; then
alias l='eza -lbg --time-style=long-iso'
alias ll='eza -lbga --time-style=long-iso'
else
alias l='ls -lF --time-style=long-iso'
alias ll='ls -alF --time-style=long-iso'
fi
if [[ -x $(command -v nvim) ]]; then
export EDITOR=nvim
alias vim='nvim -p'
alias vimdiff='nvim -d'
else
export EDITOR=vim
alias vim='vim -p'
fi
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias zgrep='zgrep --color=auto'
alias pcregrep='pcregrep --color=auto'
try_source ~/.bash_aliases
# z
if [[ -x $(command -v zoxide) ]]; then
eval "$(zoxide init bash)"
fi
# direnv
if [[ -x $(command -v direnv) ]]; then
eval "$(direnv hook bash)"
fi
# fzf
try_source ~/.fzf.bash
try_source ~/.local/fzf-extras/fzf-extras.sh
export FZF_DEFAULT_OPTS="--exact --no-mouse"
export FZF_DEFAULT_COMMAND='fd --type f'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd --type d'
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS \
--highlight-line \
--info=inline-right \
--ansi \
--border=none \
--color=bg+:#283457 \
--color=bg:#16161e \
--color=border:#27a1b9 \
--color=fg:#c0caf5 \
--color=gutter:#16161e \
--color=header:#ff9e64 \
--color=hl+:#2ac3de \
--color=hl:#2ac3de \
--color=info:#545c7e \
--color=marker:#ff007c \
--color=pointer:#ff007c \
--color=prompt:#2ac3de \
--color=query:#c0caf5:regular \
--color=scrollbar:#27a1b9 \
--color=separator:#ff9e64 \
--color=spinner:#ff007c \
"
# yazi
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
IFS= read -r -d '' cwd < "$tmp"
[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
rm -f -- "$tmp"
}
# git
try_source /usr/share/git/git-prompt.sh # Arch
try_source /usr/lib/git-core/git-sh-prompt # Ubuntu
try_source /usr/share/git-core/contrib/completion/git-prompt.sh # Fedora
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto"
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\]:\w\n\$\[\033[00m\]$(__git_ps1) '
function auto_commit() {
local interval=${1:-300}
while true; do
if [[ -n "$(git status --porcelain)" ]]; then
git add -A
git commit -m "auto-save"
fi
sleep "$interval"
done
}
# python
export PYTHONUNBUFFERED=True
export PYTHONDONTWRITEBYTECODE=True
export PIP_DISABLE_PIP_VERSION_CHECK=1
function venv() {
VENV_DIR="${1:-.venv}"
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
source "$VENV_DIR/Scripts/activate"
else
source "$VENV_DIR/bin/activate"
fi
}
# go
export GOPATH=$HOME/go
path_insert ${GOPATH}/bin
# misc
export LESS="-R"
export MOSH_PREDICTION_DISPLAY=always
export QT_LOGGING_RULES='*=false'
export ANSIBLE_FORCE_COLOR=1
export GPG_TTY=$(tty)
try_source /usr/share/bash-completion/bash_completion # Ubuntu compat
# local
try_source ~/.bashrc.local