dotfiles/.bash_extra

76 lines
2.2 KiB
Bash
Raw Normal View History

#!/bin/bash
source .bash_aliases
source .bash_functions
### tmux auto attach
# Check if the user ID is not 0 (root)
if [ "$EUID" -ne 0 ]; then
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach -t default || tmux new -s default
fi
fi
### keychain
eval "$(keychain -q --eval --timeout 60 --agents ssh,gpg)"
export GPG_TTY=$(tty)
2024-01-25 09:53:09 +01:00
### PATH
# add my scripts to PATH
2024-01-25 10:11:04 +01:00
PATH=$PATH:/home/mg/dotfiles/scripts
2024-01-25 09:53:09 +01:00
### PS1
# Farben
BLUE='\[\e[34m\]'
GREEN='\[\e[32m\]'
RED='\[\e[31m\]'
YELLOW='\[\e[33m\]'
WHITE='\[\e[97m\]'
BLACK='\[\e[30m\]'
RESET='\[\e[0m\]'
ORANGE='\[\e[0;33m\]'
# git-symbole: * unstaged, + staged, $ stashed, % untracked
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWCONFLICTSTATE="yes"
2024-04-17 11:40:07 +02:00
export PS1="\n${BLUE}\u${GREEN}@${ORANGE}\$(cat /etc/hostname) ${GREEN}\$(dirs +0 | sed -E -e "s#/#${RED}/${RESET}${GREEN}#g")${YELLOW}\$(__git_ps1)${RESET}\n> "
# https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly
# alle Farben sind mit \[<wert>\] escaped, sonst kann die shell die länge nicht richtig ausrechnen
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
# https://gist.github.com/justintv/168835
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
# Zeige letzte Exit-Code: https://stackoverflow.com/questions/16715103/bash-prompt-with-the-last-exit-code
### Praktische Dinge
# Deaktiviere FlowControl
# https://unix.stackexchange.com/questions/332791/how-to-permanently-disable-ctrl-s-in-terminal
stty -ixon
# farben fur manpages
# https://opensource.com/article/18/5/bash-tricks
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;33m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;42;30m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;36m'
# bash history bei mehreren Session
shopt -s histappend
# bach History Zeitstempel am Anfang der Zeile
export HISTTIMEFORMAT='[%F_%T] '
# typo bei cd entfernen
shopt -s cdspell
# less mit maus scrollen
export LESS='--mouse --wheel-lines=3 eFRX'
# deaktiviere alias von ll
# weiter unten ist die FUnktion ll definiert die entweder exa oder ls ausführt
unalias ll 2>/dev/null