dotfiles/.bashrc

110 lines
3.1 KiB
Bash
Raw Normal View History

2014-06-22 16:16:14 +00:00
# If not running interactively, don't do anything more
[ -z "$PS1" ] && return
# Download .compile-python.sh https://git.afpy.org/mdk/compile-python/raw/branch/main/compile-python.sh
# Download .python-prompt.sh https://git.afpy.org/mdk/python-prompt/raw/branch/main/python-prompt.sh
2014-06-22 16:16:14 +00:00
DEBEMAIL=julien
DEBEMAIL=$DEBEMAIL@
DEBEMAIL=${DEBEMAIL}palard.fr
DEBFULLNAME="Julien Palard"
shopt -s cdspell
shopt -s dirspell
shopt -s autocd
shopt -s globstar
2014-06-22 16:16:14 +00:00
shopt -s nocaseglob
2023-12-03 08:31:23 +00:00
umask 022
2024-01-02 08:43:44 +00:00
CDPATH="~/src/"
2023-12-03 08:31:23 +00:00
2014-06-22 16:16:14 +00:00
# http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html
export LESS_TERMCAP_mb=$'\E[01;31m' # debut de blink
export LESS_TERMCAP_md=$'\E[01;31m' # debut de gras
export LESS_TERMCAP_me=$'\E[0m' # fin
export LESS_TERMCAP_so=$'\E[01;44;33m' # début de la ligne d'état
export LESS_TERMCAP_se=$'\E[0m' # fin
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
2023-04-17 10:04:33 +00:00
export HISTFILESIZE=50000
export HISTSIZE=50000
2023-01-20 12:26:49 +00:00
export PIP_REQUIRE_VIRTUALENV=1
2023-05-24 09:35:04 +00:00
# needs: apt install lesspipe source-highlight
2023-12-03 08:31:23 +00:00
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" # see lesspipe(1)
2023-05-24 09:35:04 +00:00
export LESS=' -R '
2023-12-03 08:31:23 +00:00
export PYTHONDEVMODE=y
2014-06-22 16:16:14 +00:00
2023-12-03 08:31:23 +00:00
eval "`dircolors`"
2017-08-30 08:05:14 +00:00
2017-04-29 09:28:30 +00:00
alias ls='ls --color=auto'
2014-06-22 16:16:14 +00:00
alias fingerprint='find /etc/ssh -name "*.pub" -exec ssh-keygen -l -f {} \;'
2021-10-05 02:19:20 +00:00
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'
2014-06-22 16:16:14 +00:00
2024-01-16 09:04:13 +00:00
while read -r _ _ dest src # costs 9ms
2018-08-12 09:56:25 +00:00
do
if [[ (! -f "$HOME/$dest") || $(( RANDOM % 100 )) == 0 ]]
then
wget -q -O "$HOME/$dest" "$src"
fi
if [[ "$dest" == *".sh" ]]
then
2023-12-22 18:19:49 +00:00
. "$HOME/$dest"
fi
2023-12-22 18:19:49 +00:00
done < <(grep '^# Download ' $HOME/.bashrc)
unset dest src
2014-06-22 16:16:14 +00:00
2024-01-16 09:04:13 +00:00
. /etc/bash_completion # costs 6ms
2024-01-05 12:38:14 +00:00
if [[ "$TERM" != 'dumb' ]]
then
_TITLE="\[\e]0;\H \W\a\]"
else
_TITLE=''
fi
2023-12-03 08:19:59 +00:00
2024-01-16 09:04:13 +00:00
_PREV_FAIL="\`PREV_FAIL=\$?; if [ \$PREV_FAIL != 0 ]; then echo \[\e[31m\]\$PREV_FAIL \[\e[0m\]; fi\`"
2023-12-03 08:00:54 +00:00
git_prompt()
{
# Wrapper around __git_ps1
# to not show it when the repo is my dotfiles.
2023-12-03 08:19:59 +00:00
if [[ "$(git rev-parse --show-toplevel 2>/dev/null)" != "$HOME" ]]
2023-12-03 08:00:54 +00:00
then
__git_ps1 "$1"
fi
}
2024-01-16 09:04:13 +00:00
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_COLOR=$'\E[1;34m'
USERNAME_COLOR=$'\E[1;35m'
PY_PS1='$(python_prompt " ${PY_BLUE_FG}🭮${PY_BLUE_BG}${PY_YELLOW_FG} %s \e[0m${PY_BLUE_FG}🭬\e[0m")'
GIT_PS1='$(git_prompt " ${GIT_RED_FG}🭮${GIT_RED_BG}\e[97m %s \e[0m${GIT_RED_FG}🭬\e[0m")'
2022-04-23 14:20:57 +00:00
PS1="${_TITLE}${_PREV_FAIL}${USERNAME_COLOR}\u\e[0m@${HOSTNAME_COLOR}\H\e[0m:\e[32m\w\e[0m${PY_PS1}${GIT_PS1}\n\$ "
if hash direnv &>/dev/null; then
eval "$(direnv hook bash)"
fi
2021-11-06 09:26:03 +00:00
e()
{
emacsclient --no-wait "$@"
}
2022-09-02 08:39:22 +00:00
venv()
{
# Simple helper to use direnv to create Python venvs.
#
# See https://github.com/pappasam/jedi-language-server/issues/199#issuecomment-1836880575
# for more context.
printf "VIRTUAL_ENV=.venv\nlayout python3\n" > .envrc
2023-01-20 12:48:24 +00:00
direnv allow .
2022-09-02 08:39:22 +00:00
}