155 lines
4.7 KiB
Bash
155 lines
4.7 KiB
Bash
# Oklomsy's .bashrc file
|
|
# Includes snippets from the following sites:
|
|
# https://gitlab.com/FallFur/config-files-bashrc-vimrc/-/blob/master/.bashrc
|
|
# https://gitlab.com/dwarmstrong/dotfiles/blob/master/.bashrc
|
|
# https://gitlab.com/only_vip/mxtest-dope-dots/-/blob/master/.bashrc
|
|
# http://bashrcgenerator.com/
|
|
|
|
# If not running interactively, don't do anything
|
|
case $- in
|
|
*i*) ;;
|
|
*) return;;
|
|
esac
|
|
# Colour codes
|
|
red='\[\e[0;31m\]'
|
|
RED='\[\e[1;31m\]'
|
|
blue='\[\e[0;34m\]'
|
|
BLUE='\[\e[1;34m\]'
|
|
cyan='\[\e[0;36m\]'
|
|
CYAN='\[\e[1;36m\]'
|
|
green='\[\e[0;32m\]'
|
|
GREEN='\[\e[1;32m\]'
|
|
yellow='\[\e[0;33m\]'
|
|
YELLOW='\[\e[1;33m\]'
|
|
PURPLE='\[\e[1;35m\]'
|
|
purple='\[\e[0;35m\]'
|
|
nc='\[\e[0m\]'
|
|
WHITE="\\[\\e[1;37m\\]"
|
|
RESET="\\[\\e[0m\\]"
|
|
|
|
# (Un)mount usb devices
|
|
mu() { sudo mountusb -m $1 ; }
|
|
umu() { sudo mountusb -u $1 ; }
|
|
# LUKS-encrypted usb device
|
|
muc() { sudo cryptset -o $1 && sudo mountusb -m $1 ; }
|
|
umuc() { sudo mountusb -u $1 && sudo cryptset -c $1 ; }
|
|
|
|
|
|
# don't put duplicate lines or lines starting with space in the history.
|
|
# See bash(1) for more options
|
|
HISTCONTROL=ignoreboth:ignoredups:erasedups
|
|
|
|
# Unlimited history
|
|
HISTSIZE=
|
|
HISTFILESIZE=
|
|
|
|
# Change the history file location because certain bash sessions truncate
|
|
# ~/.bash_history upon close
|
|
HISTFILE=~/.bash_unlimited_history
|
|
|
|
# After each command, append to the history file and reread it
|
|
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
|
|
|
|
# Append to the history file, don't overwrite it.
|
|
shopt -s histappend
|
|
|
|
# Set colours
|
|
eval `dircolors`
|
|
|
|
# check the window size after each command and, if necessary,
|
|
# update the values of LINES and COLUMNS.
|
|
shopt -s checkwinsize
|
|
|
|
### Useful aliases
|
|
|
|
alias aaa="sudo apt update && apt list --upgradable && sudo apt full-upgrade && sudo apt-get autoclean && sudo apt autoremove"
|
|
alias shutdown="/usr/sbin/shutdown now"
|
|
alias suspend="systemctl suspend"
|
|
alias reboot="/usr/sbin/shutdown -r now"
|
|
alias hibernate="systemctl hibernate"
|
|
alias ls="exa"
|
|
alias x="exit"
|
|
alias cat="bat"
|
|
|
|
# enable programmable completion features (you don't need to enable
|
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
|
# sources /etc/bash.bashrc).
|
|
if ! shopt -oq posix; then
|
|
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
|
|
fi
|
|
|
|
|
|
# set variable identifying the chroot you work in.
|
|
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
|
debian_chroot=$(cat /etc/debian_chroot)
|
|
fi
|
|
|
|
# uncomment for a colored prompt, if the terminal has the capability; turned
|
|
# off by default to not distract the user: the focus in a terminal window
|
|
# should be on the output of commands, not on the prompt
|
|
force_color_prompt=yes
|
|
|
|
if [ -n "$force_color_prompt" ]; then
|
|
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
# We have color support; assume it's compliant with Ecma-48
|
|
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
|
# a case would tend to support setf rather than setaf.)
|
|
color_prompt=yes
|
|
else
|
|
color_prompt=
|
|
fi
|
|
fi
|
|
|
|
if [ "$color_prompt" = yes ]; then
|
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
|
else
|
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
fi
|
|
unset color_prompt force_color_prompt
|
|
|
|
# color GCC warning and errors
|
|
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
|
|
|
# Separate aliases file... I don't need it now but maybe later.
|
|
if [ -f ~/.bash_aliases ]; then
|
|
. ~/.bash_aliases
|
|
fi
|
|
|
|
# Add sbin directories to PATH. This is useful on systems that have sudo
|
|
echo $PATH | grep -Eq "(^|:)/sbin(:|)" || PATH=$PATH:/sbin
|
|
echo $PATH | grep -Eq "(^|:)/usr/sbin(:|)" || PATH=$PATH:/usr/sbin
|
|
|
|
|
|
# Archive extraction (Usage: ex <file>)
|
|
ex ()
|
|
{
|
|
if [ -f $1 ] ; then
|
|
case $1 in
|
|
*.tar.bz2) tar xjf $1 ;;
|
|
*.tar.gz) tar xzf $1 ;;
|
|
*.bz2) bunzip2 $1 ;;
|
|
*.rar) unrar x $1 ;;
|
|
*.gz) gunzip $1 ;;
|
|
*.tar) tar xf $1 ;;
|
|
*.tbz2) tar xjf $1 ;;
|
|
*.tgz) tar xzf $1 ;;
|
|
*.zip) unzip $1 ;;
|
|
*.Z) uncompress $1;;
|
|
*.7z) 7z x $1 ;;
|
|
*.deb) ar x $1 ;;
|
|
*.tar.xz) tar xf $1 ;;
|
|
*.tar.zst) unzstd $1 ;;
|
|
*) echo "'$1' cannot be extracted via ex()" ;;
|
|
esac
|
|
else
|
|
echo "'$1' is not a valid file"
|
|
fi
|
|
}
|
|
|
|
|
|
export PS1="\[\033[38;5;13m\]\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;14m\]\H\[$(tput sgr0)\]:\[$(tput sgr0)\]\[\033[38;5;10m\][\w]\[$(tput sgr0)\]:\[$(tput sgr0)\]\[\033[38;5;11m\]\\$\[$(tput sgr0)\] "
|