From c965ff22bcd3dc09edb70a71005c41bf49912cbf Mon Sep 17 00:00:00 2001 From: Quinn Date: Fri, 30 May 2025 15:06:32 +0200 Subject: [PATCH] modify .bashrc and alike --- .bash_logout | 2 ++ .bash_profile | 31 ++++++++++++++++++++++++++++--- .bashrc | 18 ++++-------------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/.bash_logout b/.bash_logout index 0e4e4f1..3e2159f 100644 --- a/.bash_logout +++ b/.bash_logout @@ -1,3 +1,5 @@ +# shellcheck shell=bash # # ~/.bash_logout +# sourced when an interactive login shell exits, or a non-interactive login shell executes `exit` # diff --git a/.bash_profile b/.bash_profile index 2ae4155..542869f 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,8 +1,33 @@ -#!/bin/bash +# shellcheck shell=bash +# shellcheck disable=1091 # # ~/.bash_profile +# sourced upon new login shells # -[[ -d ~/.local/bin ]] && PATH="$PATH:$HOME/.local/bin" # add path variable -[[ -x ~/.bashrc ]] && source "$HOME/.bashrc" #execute bashrc +# https://specifications.freedesktop.org/basedir-spec/latest/ +export XDG_CONFIG_HOME="$HOME/.config" # where user configuration files are stored (default: ~/.config) +export XDG_STATE_HOME="$HOME/.local/state" # state data that should persist between (application) restarts, but not important enough to be stored in XDG_DATA_HOME (default: ~/.local/state) +export XDG_DATA_HOME="$HOME/.local/share" # where user data files are stored (default: ~/.local/share) +export PATH="$HOME/bin:$PATH" # add our bin in front of PATH, making it take precedence +if which nvim 1>/dev/null; then + export EDITOR=nvim # use neovim as an editor + export VISUAL=nvim # use neovim for visual-based editors + export MANPAGER='nvim +Man!' # use neovim as a manual pager +fi + +# coloured GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# # export Microsoft's bullshit outta here +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export VCPKG_DISABLE_METRICS=1 +export VCPKG_ROOT="$XDG_DATA_HOME/vcpkg" +export PATH+=":$VCPKG_ROOT" + +# if executing interactively +# execute .bashrc in the current login context +[[ $- != *i* ]] && return +[[ -z ${PS1-} ]] && retrun +[[ -f $HOME/.bashrc ]] && . "$HOME/.bashrc" diff --git a/.bashrc b/.bashrc index c9724e4..c595822 100644 --- a/.bashrc +++ b/.bashrc @@ -1,7 +1,8 @@ -#!/usr/bin/env 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 @@ -11,9 +12,9 @@ # 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 + if [ -d .git ] || git worktree list &>/dev/null; then export __GIT_PROMPT_SOURCED=1 __git_ps1 "$@" fi @@ -44,7 +45,7 @@ _make() { # set PS1 PS1= PS1="$PS1"'\[\033[01;35m\]\u@\h' # user@host -PS1="$PS1"'\[\033[00m\]:' # seperator +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 @@ -54,18 +55,7 @@ HISTCONTROL=ignoreboth # don't put duplicate lines or lines starting with space HISTSIZE=1000 HISTFILESIZE=2000 -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 -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)