-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.bashrc
More file actions
185 lines (150 loc) · 4.7 KB
/
Copy path.bashrc
File metadata and controls
185 lines (150 loc) · 4.7 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
185
#!/usr/bin/env bash
#
# ~/.bashrc
#
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Load environment modules
# if ! type module >/dev/null 2>&1 && [[ -f /usr/share/modules/init/bash ]]
# then
# source /usr/share/modules/init/bash
# fi
# Prepend to PATH (reverse order)
for p in "$HOME/.local/bin" "$HOME/.cargo/bin" "$HOME/bin"
do
if [[ -d "$p" ]]
then
PATH=":${PATH}:"
PATH="${PATH//:$p:/:}"
PATH="${PATH#:}"
PATH="${PATH%:}"
export PATH="$p:$PATH"
fi
done
unset p
export PS1='\s-\v\$ ' # bash default prompt
# User specific aliases and functions
if [[ -d ~/.bashrc.d ]]; then
for rc in ~/.bashrc.d/*; do
if [[ -f "$rc" ]]; then
. "$rc"
fi
done
fi
unset rc
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# emacs tramp
if [[ "$TERM" == "dumb" || "$TERM" == "tramp" ]]
then
export PS1='$ '
return
fi
[[ -f ~/bin/shenvtools/shenvtools.sh ]] && . ~/bin/shenvtools/shenvtools.sh
# 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
# append history to the HISTFILE
shopt -s histappend
# '**' matches zero or more directories and subdirectories
shopt -s globstar
# save all multiple-lines command to allow easy re-editing of multi-line commands
shopt -s cmdhist
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Don't show '.' and '..' when using '.*' globbing
# export GLOBIGNORE=".:..:*/.:*/.."
# shopt -u dotglob # Because non-empty GLOBIGNORE enables dotglob
# add commands to the history file each time you hit enter
PROMPT_COMMAND+=("history -a")
# 'ignorespace' ignore commands that start with spaces
# 'ignoredups' ignore duplicates
# 'ignoreboth' both
HISTCONTROL=ignoreboth
# history size
HISTSIZE=10000
HISTFILESIZE=10000
export EDITOR='emacs'
export PAGER='less'
export BROWSER='firefox'
# `bash -x` "prompt" https://wiki.bash-hackers.org/scripting/debuggingtips
export PS4='+$$+${BASH_SOURCE:-?}:${LINENO:-?}+${FUNCNAME[0]:-?}+ '
# less config
export LESS_TERMCAP_mb=$'\e[01;31m' # begin blinking (?)
export LESS_TERMCAP_md=$'\e[01;34m' # begin bold (titles)
export LESS_TERMCAP_me=$'\e[0m' # end mode
export LESS_TERMCAP_so=$'\e[01;37m' # begin standout-mode (search)
#export LESS_TERMCAP_so=$'\E[7m' # begin standout-mode (search)
export LESS_TERMCAP_se=$'\e[0m' # end standout-mode
export LESS_TERMCAP_us=$'\e[01;36m' # begin underline (words)
export LESS_TERMCAP_ue=$'\e[0m' # end underline
export LESSBINFMT='*u<%02X>'
export LESS='-qRiSM -j5 -z-4'
export MANPAGER='less -J'
# for systemd (journalctl...)
export SYSTEMD_LESS="$LESS -F"
# enable sysstat (sar) colors
export S_COLORS=true
# ripgrep rg
export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/config
# CMake always generate a compile_commands.json
export CMAKE_EXPORT_COMPILE_COMMANDS=1
alias grep='grep --color=auto'
alias less='less --quiet'
alias cat='cat -v'
alias ls='ls -h --color=auto'
alias l='ls -l'
alias la='ls -la'
alias lt='l -rt'
alias rcp='cp -r'
alias md='mkdir -p'
alias rd='rmdir'
alias c='clear'
alias e='exit'
alias t='urxvt & ; disown'
alias cdr='cd "$(git rev-parse --show-toplevel)"'
alias gdiff='pipes2files git d --no-index'
alias gdiffw='pipes2files git dw --no-index'
alias lesss='less -+S'
alias topu='top -u "$(id -nu)"'
# Safe xargs
alias xargss='xargs -d \\n -r'
if ! command -v fd >& /dev/null && command -v fdfind >& /dev/null; then
alias fd='fdfind'
fi
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias a='echo -ne "\a"'
# See ~/.omz/systemd.zsh
alias sd='sudo systemctl'
alias sdu='systemctl --user'
take() {
mkdir -p "$1" && cd "$1"
}
if [[ -z "${_did_shell_depth:-}" ]]
then
_did_shell_depth=1
export _shell_depth="$((${_shell_depth:-0} + 1))"
fi
my_prompt_command() {
_MY_PROMPT_STATUS=$?
}
PROMPT_COMMAND+=("my_prompt_command")
export PS1='\[\033[1;30;40m\]\[\033[1;30m\]$_shell_depth \[\033[1;34m\]\u${SSH_CONNECTION:+\[\033[1;32m\]@\H} \[\033[1;34m\]\W\[\033[1;31m\]$([[ $_MY_PROMPT_STATUS -eq 0 ]] || echo " $_MY_PROMPT_STATUS") \[\033[1;37m\]\$\[\033[0;0;0m\] '
export ORIG_PS1="$PS1"
if false # true
then
function _my_starship_precmd(){
printf "\a" # alert
}
starship_precmd_user_func="_my_starship_precmd"
export _STARSHIP_ENV_VAR=$(if ((_shell_depth > 1)); then echo $_shell_depth ; fi)
eval "$(starship init bash)"
fi