From 29b72c8994ffcc31d885e3d73d479b3bf66f7994 Mon Sep 17 00:00:00 2001 From: Quinn Date: Wed, 7 May 2025 13:33:41 +0200 Subject: [PATCH] improve bashrc layout and performance --- .bashrc | 81 ++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/.bashrc b/.bashrc index cf12331..1dda6b6 100644 --- a/.bashrc +++ b/.bashrc @@ -7,28 +7,49 @@ [[ $- != *i* ]] && return [[ -z "${PS1-}" ]] && return -# check the window size after each command (and if necessary, the values of LINES and COLUMNS) -shopt -s checkwinsize +# set PS1 +PS1= +PS1="$PS1"'\[\033[01;35m\]\u@\h' # user@host +PS1="$PS1"'\[\033[00m\]:' # seperator +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 -source /usr/share/bash-completion/completions/git -source /usr/share/git/completion/git-prompt.sh - -PS1= -PS1="$PS1"'\[\033[01;35m\]\u@\h' # user@host -PS1="$PS1"'\[\033[00m\]:' # seperator -PS1="$PS1"'\[\033[01;34m\]\w' # working directory -PS1="$PS1"'\[\033[01;93m\]$(__git_ps1)' # github branch -PS1="$PS1"'\[\033[00m\]\$ ' # shell sign - -export EDITOR=nvim - +export MANPAGER='nvim +Man!' # use neovim as a manual pager export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' # coloured GCC warnings and errors -eval "$(_AUTO_CPUFREQ_COMPLETE=bash_source auto-cpufreq)" +export EDITOR=nvim # use neovim as an editor +export VISUAL=nvim # use neovim for visual-based editors + +# export Microsoft's bullshit outta here +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export VCPKG_DISABLE_METRICS=1 + +# vcpkg shit +export VCPKG_ROOT=$HOME/.local/share/vcpkg +export PATH=$VCPKG_ROOT:$PATH +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 + +# wrapper for lazily loading __git_ps1 whenever it is actually needed +_lazy_git_ps1() { + if [[ -z $__GIT_PROMPT_SOURCED ]]; then + if [[ -d .git || $(git rev-parse --is-inside-work-tree 2>/dev/null) == true ]]; then + source /usr/share/bash-completion/completions/git &>/dev/null + source /usr/share/git/completion/git-prompt.sh &>/dev/null + export __GIT_PROMPT_SOURCED=1 + __git_ps1 "$@" + fi + else + __git_ps1 "$@" + fi +} # # aliases @@ -56,34 +77,6 @@ alias mv='mv -i' alias :qa='exit' alias :q='exit' alias py3='python3' -alias hgit='git --git-dir=$HOME/.home-conf.git --work-tree=$HOME' - -__git_complete hgit __git_main - -# vcpkg shit -export VCPKG_ROOT=$HOME/.local/share/vcpkg -export PATH=$VCPKG_ROOT:$PATH -source /home/user/.local/share/vcpkg/scripts/vcpkg_completion.bash - -# opt out of Microsoft's telemetry bullshit -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export VCPKG_DISABLE_METRICS=1 - -# customise less -# Have less display colours -# from: https://wiki.archlinux.org/index.php/Color_output_in_console#man -export LESS_TERMCAP_mb=$'\e[1;31m' # begin bold -export LESS_TERMCAP_md=$'\e[1;33m' # begin blink -export LESS_TERMCAP_so=$'\e[01;44;37m' # begin reverse video -export LESS_TERMCAP_us=$'\e[01;37m' # begin underline -export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink -export LESS_TERMCAP_se=$'\e[0m' # reset reverse video -export LESS_TERMCAP_ue=$'\e[0m' # reset underline - -# customise man pager to use the correct parameters -export MANPAGER='less -s -M +Gg' # cute lil hyfetch :3 -if [[ $TERM == "xterm-kitty" ]]; then - hyfetch -fi +[[ $TERM == "xterm-kitty" ]] && hyfetch