Unclutter .bashrc

This commit is contained in:
Julien Palard 2023-12-03 09:31:23 +01:00
parent c92ad51c2a
commit bfc7749430
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
3 changed files with 33 additions and 43 deletions

66
.bashrc
View File

@ -12,7 +12,10 @@ shopt -s autocd
shopt -s globstar
shopt -s nocaseglob
umask 022
CDPATH="~/clones/"
if [ -n "$DISPLAY" ]
then
xset b off
@ -28,46 +31,34 @@ export LESS_TERMCAP_us=$'\E[01;32m' # début de souligné
export LESS_TERMCAP_ue=$'\E[0m' # fin
export DEBEMAIL DEBFULLNAME
export EDITOR=emacs
export HISTCONTROL=ignoredups
export HISTFILESIZE=50000
export HISTSIZE=50000
export PIP_REQUIRE_VIRTUALENV=1
umask 022
eval "`dircolors`"
HOSTNAME_SUM=$(cksum <(hostname) | cut -d' ' -f1)
HOSTNAME_BOLD=$(( ($HOSTNAME_SUM + 1) % 2))
HOSTNAME_HUE=$(( ($HOSTNAME_SUM + 3) % 6 + 31))
USERNAME_SUM=$(($(cksum <(whoami) | cut -d' ' -f1) + 5)) # + 5 so root gots red.
USERNAME_BOLD=$(( ($USERNAME_SUM + 1) % 2))
USERNAME_HUE=$(( ($USERNAME_SUM + 2) % 6 + 31))
HOSTNAME_COLOR=$'\E'"[$HOSTNAME_BOLD;${HOSTNAME_HUE}m"
USERNAME_COLOR=$'\E'"[$USERNAME_BOLD;${USERNAME_HUE}m"
# make less more friendly for non-text input files, see lesspipe(1)
# needs: apt install lesspipe source-highlight
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" # see lesspipe(1)
export LESS=' -R '
export PYTHONDEVMODE=y
eval "`dircolors`"
alias ls='ls --color=auto'
alias fingerprint='find /etc/ssh -name "*.pub" -exec ssh-keygen -l -f {} \;'
alias rekey='ssh-add -e /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so >/dev/null 2>&1; ssh-add -s /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so'
export PYTHONDEVMODE=y
if ! [[ -f "$HOME/.git-prompt.sh" ]]
then
wget -q -O "$HOME/.git-prompt.sh" https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
fi
for extra in /etc/bash_completion ~/.bash_aliases ~/.my_bashrc ~/.git-prompt.sh ~/clones/mdk/compile-python/compile-python.sh ~/clones/mdk/python-prompt/python-prompt.sh
if ! [[ -f "$HOME/.fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf" ]]
then
mkdir -p ~/.fonts/dejavu/
wget -qO "$HOME/.fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf" "https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20Nerd%20Font%20Complete%20Mono.ttf"
fi
for extra in /etc/bash_completion ~/.git-prompt.sh ~/clones/mdk/compile-python/compile-python.sh ~/clones/mdk/python-prompt/python-prompt.sh
do
if [[ -f "$extra" ]]
then
@ -83,18 +74,22 @@ else
fi
_PREV_FAIL="\`PREV_FAIL=\$?; if [ \$PREV_FAIL != 0 ]; then echo \[\e[31m\]\$PREV_FAIL \[\e[0m\]; fi\`"
if ! [[ -f ~/.fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf ]]
then
mkdir -p ~/.fonts/dejavu/
wget -qO ~/.fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20Nerd%20Font%20Complete%20Mono.ttf
fi
GIT_RED_FG='\e[38;2;244;77;39m'
GIT_RED_BG='\e[48;2;244;77;39m'
PY_BLUE_FG='\e[38;2;53;112;160m'
PY_BLUE_BG='\e[48;2;53;112;160m'
PY_YELLOW_FG='\e[38;2;255;222;87m'
HOSTNAME_SUM=$(cksum <(hostname) | cut -d' ' -f1)
HOSTNAME_BOLD=$(( ($HOSTNAME_SUM + 1) % 2))
HOSTNAME_HUE=$(( ($HOSTNAME_SUM + 3) % 6 + 31))
USERNAME_SUM=$(($(cksum <(whoami) | cut -d' ' -f1) + 5)) # + 5 so root gots red.
USERNAME_BOLD=$(( ($USERNAME_SUM + 1) % 2))
USERNAME_HUE=$(( ($USERNAME_SUM + 2) % 6 + 31))
HOSTNAME_COLOR=$'\E'"[$HOSTNAME_BOLD;${HOSTNAME_HUE}m"
USERNAME_COLOR=$'\E'"[$USERNAME_BOLD;${USERNAME_HUE}m"
git_prompt()
{
@ -112,21 +107,6 @@ PS1="${_TITLE}${_PREV_FAIL}${USERNAME_COLOR}\u\e[0m@${HOSTNAME_COLOR}\H\e[0m:\e[
eval "$(direnv hook bash)"
# Removes *~ and #*# files in curent folder, for a depth limited to 3 folders.
clean()
{
find -maxdepth 4 \
\( -name '*~' -o -name '#*#' -o -name .tox -o -name .mypy_cache \) \
-print0 | xargs -0 rm -vfr
}
code-block()
{
printf '```%s\n' "$1"
cat
printf '```\n'
}
e()
{
emacsclient --no-wait "$@"

5
.local/bin/clean Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
find -maxdepth 4 \
\( -name '*~' -o -name '#*#' -o -name .tox -o -name .mypy_cache \) \
-print0 | xargs -0 rm -vfr

5
.local/bin/code-block Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
printf '```%s\n' "$1"
cat
printf '```\n'