95 lines
2.4 KiB
Bash
95 lines
2.4 KiB
Bash
# shellcheck shell=bash
|
|
# shellcheck disable=SC1090,SC1091
|
|
#
|
|
# ~/.bashrc
|
|
# sourced upon launch of an interactive shell, which isn't a login shell has been executed
|
|
#
|
|
|
|
# If not running interactively, don't do anything
|
|
[[ $- != *i* ]] && return
|
|
[[ -z "${PS1-}" ]] && return
|
|
|
|
# wrapper for lazily loading __git_ps1 whenever it is actually needed
|
|
_lazy_git_ps1() {
|
|
if [[ -z $__GIT_PROMPT_SOURCED ]]; then
|
|
source /usr/share/bash-completion/completions/git &>/dev/null
|
|
source /usr/share/git/completion/git-prompt.sh &>/dev/null
|
|
if [ -d .git ] || git worktree list &>/dev/null; then
|
|
export __GIT_PROMPT_SOURCED=1
|
|
__git_ps1 "$@"
|
|
fi
|
|
else
|
|
__git_ps1 "$@"
|
|
fi
|
|
}
|
|
|
|
# lazy loading of ssh agents
|
|
_lazy_ssh() {
|
|
if [[ -z $SSH_AUTH_SOCK ]]; then
|
|
eval "$(ssh-agent -s)" &>/dev/null
|
|
ssh-add "$HOME/.ssh/github" &>/dev/null
|
|
ssh-add "$HOME/.ssh/admin@homeserver" &>/dev/null
|
|
fi
|
|
}
|
|
# aliases so the function is called beforehand
|
|
alias ssh='_lazy_ssh; ssh'
|
|
alias sudo='_lazy_ssh; sudo'
|
|
|
|
# alias to colourize make output
|
|
_make() {
|
|
make "$@" 2> >(sed -E \
|
|
-e "s/^([Mm]akefile:[0-9]+:.*)/\x1b[33m\1\x1b[0m/" \
|
|
-e "s/^.*error.*$/\x1b[31m&\x1b[0m/I" >&2)
|
|
}
|
|
|
|
# set PS1
|
|
PS1=
|
|
PS1="$PS1"'\[\033[01;35m\]\u@\h' # user@host
|
|
PS1="$PS1"'\[\033[00m\]:' # separator
|
|
PS1="$PS1"'\[\033[01;34m\]\w' # working directory
|
|
PS1="$PS1"'\[\033[01;93m\]$(_lazy_git_ps1)' # github branch
|
|
PS1="$PS1"'\[\033[00m\]\$ ' # shell sign
|
|
|
|
# history settings
|
|
HISTCONTROL=ignoreboth # don't put duplicate lines or lines starting with space in the history.
|
|
HISTSIZE=1000
|
|
HISTFILESIZE=2000
|
|
|
|
# vcpkg shit
|
|
source /home/user/.local/share/vcpkg/scripts/vcpkg_completion.bash &>/dev/null
|
|
|
|
# check the window size after each command (and if necessary, the values of LINES and COLUMNS)
|
|
shopt -s checkwinsize
|
|
|
|
#
|
|
# aliases
|
|
#
|
|
|
|
# aliases for colour
|
|
alias dir='dir --color=auto'
|
|
alias vdir='vdir --color=auto'
|
|
alias ls='eza -Abhg --colour=auto'
|
|
alias grep='rg'
|
|
alias diff='diff --color'
|
|
alias ip='ip -c'
|
|
|
|
# application aliases
|
|
alias ncdu='ncdu --color=dark -t 16'
|
|
alias hyfetch='hyfetch --ascii-file $XDG_CONFIG_HOME/hyfetch-ascii --config-file $XDG_CONFIG_HOME/hyfetch.json'
|
|
alias bat='bat --wrap never --tabs 4 --theme gruvbox-dark'
|
|
alias make='_make -j'
|
|
|
|
# aliases to avoid mistakes
|
|
alias cp='cp -i'
|
|
alias mv='mv -i'
|
|
#alias rm='rm -i'
|
|
|
|
alias :qa='exit'
|
|
alias qa='exit'
|
|
alias :q='exit'
|
|
alias q='exit'
|
|
alias py3='python3'
|
|
|
|
# cute lil hyfetch :3
|
|
[[ $TERM == "xterm-kitty" ]] && hyfetch
|