-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
184 lines (154 loc) · 4.68 KB
/
.bashrc
File metadata and controls
184 lines (154 loc) · 4.68 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
shopt -s autocd
shopt -s cdspell
shopt -s dirspell
alias nv='nvim'
alias diff='diff --color=auto'
alias ip='ip -color=auto'
export LESS='-R --use-color -Dd+r$Du+b'
alias grep='grep --color=auto'
alias webcam='mpv --demuxer-lavf-o=video_size=1920x1080,input_format=mjpeg av://v4l2:/dev/video0 --profile=low-latency --untimed'
alias xp="xprop | awk '/^WM_CLASS/{sub(/.* =/, \"instance:\"); sub(/,/, \"\nclass:\"); print}/^WM_NAME/{sub(/.* =/, \"title:\"); print}'"
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git pull'
alias gP='git push'
alias nvcfg='(cd ~/.config/nvim && nvim ~/.config/nvim/init.lua)'
alias la='ls -a'
alias ll='ls -la'
alias vifm='vifmrun'
vicd () {
dst="$(command vifm --choose-dir - . "$@")"
if [ -z "$dst" ] ; then
echo 'Directory picking cancelled/failed'
fi
cd "$dst"
}
# ---- Color definitions ----
RESET='\[\e[m\]'
WHITE='\[\e[1;97m\]'
YELLOW='\[\e[0;93m\]'
CYAN='\[\e[0;36m\]'
ORANGE='\[\e[0;33m\]'
BLUE='\[\e[0;34m\]'
RED='\[\e[0;31m\]'
# ---- OSC133 support & command timer ----
# Command start marker (before each command)
PS0+='\e]133;C\e\\'
_CMD_START=""
_CMD_DURATION=""
_PROMPT_NL=""
__ps0_timer() {
_CMD_START=$EPOCHSECONDS
}
PS0+='${_CMD_START:+}$(__ps0_timer)'
__pc_prompt() {
LAST_STATUS=$?
printf '\e]133;D;%s\e\\' "$LAST_STATUS"
# Command duration
_CMD_DURATION=""
if [[ -n $_CMD_START ]]; then
local secs=$(( EPOCHSECONDS - _CMD_START ))
if (( secs >= 5 )); then
if (( secs >= 3600 )); then
_CMD_DURATION="$(( secs / 3600 ))h$(( (secs % 3600) / 60 ))m$(( secs % 60 ))s"
elif (( secs >= 60 )); then
_CMD_DURATION="$(( secs / 60 ))m$(( secs % 60 ))s"
else
_CMD_DURATION="${secs}s"
fi
fi
_CMD_START=""
fi
# Decide if prompt needs a newline before $
_PROMPT_NL=""
local test_prompt="[$(whoami)@$(hostname -s)(${PWD/#$HOME/~})]${_CMD_DURATION:+ [${_CMD_DURATION}]}"
if (( ${#test_prompt} > COLUMNS / 2 )); then
_PROMPT_NL=$'\n'
fi
}
PROMPT_COMMAND=__pc_prompt
GREEN='\[\e[0;32m\]'
# Show repo<branch> in git repos, otherwise normal dir
__prompt_cwd() {
local git_root branch repo_name subdir
git_root=$(git rev-parse --show-toplevel 2>/dev/null) || { printf '%s' "${PWD/#$HOME/~}"; return; }
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
repo_name=$(basename "$git_root")
subdir="${PWD#"$git_root"}"
printf '\001\e[0;35m\002%s\001\e[0;34m\002%s\001\e[1;97m\002<\001\e[0;32m\002%s\001\e[1;97m\002>' "$repo_name" "$subdir" "$branch"
}
# Dynamic PS1 using native variable
PS1="\[\e]133;A\a\]${WHITE}[${YELLOW}\u${CYAN}@${ORANGE}\h${WHITE}(${BLUE}"'$(__prompt_cwd)'"${WHITE})]"\
'${_CMD_DURATION:+'" ${WHITE}[${CYAN}"'${_CMD_DURATION}'"${WHITE}"']}'\
'${_PROMPT_NL}$(if (( LAST_STATUS == 0 )); then echo "'${ORANGE}\$${RESET}'"; else echo "'${RED}\$${RESET}'"; fi)'\
"\[\e]133;B\a\] "
# if command -v rpg-cli &> /dev/null
# then
#
# PS1="\[\e]133;A\a\]${WHITE}[${YELLOW}\u${CYAN}@${ORANGE}\h${WHITE}](${BLUE}\W${WHITE})]\n"\
# '$(CLICOLOR_FORCE=1 rpg-cli stat -q 2>/dev/null | sed -r "s/@.*//" | sed "s/\\x1B\\[0m/\\x1B[0;97m/g" | sed -r "s/(\\x1B\\[[0-9;]{1,6}[mGK])/\\\\[\\1\\\\]/g")'\
# '$(if (( LAST_STATUS == 0 )); then echo "'${ORANGE}\$${RESET}'"; else echo "'${RED}\$${RESET}'"; fi)'\
# "\[\e]133;B\a\] "
#
# alias rpg-battle="rpg-cli cd -f . && rpg-cli battle"
#
# alias rm="rpg-battle && rm"
# alias rmdir="rpg-battle && rmdir"
# alias mkdir="rpg-battle && mkdir"
# alias touch="rpg-battle && touch"
# alias mv="rpg-battle && mv"
# alias cp="rpg-battle && cp"
# alias chown="rpg-battle && chown"
# alias chmod="rpg-battle && chmod"
#
# bcd () {
# builtin cd "$@"
# command ls --color=auto
# if [[ $PWD == ~ ]] ; then
# rpg-cli cd -f ~
# else
# rpg-cli cd -f .
# rpg-cli battle --bribe
# fi
# }
#
# cd () {
# builtin cd "$@"
# command ls --color=auto
# if [[ $PWD == ~ ]] ; then
# rpg-cli cd -f ~
# else
# rpg-cli cd -f .
# rpg-cli battle
# fi
# }
#
# ls () {
# command ls --color=auto "$@"
# if [ $# -eq 0 ] ; then
# rpg-cli cd -f .
# rpg-cli ls
# fi
# }
# fi
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
complete -cf sudo
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.elan/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
systemctl --user import-environment PATH
#case $TERM in
# rxvt|*term|st*)
# PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'
# ;;
#esac
# Set up Node Version Manager
source /usr/share/nvm/init-nvm.sh
bind 'set completion-ignore-case on'