view bashrc @ 168:381896bd9e0d default tip

Reduce hinting from full to slight This seems to improve rendering in Thunderbird and Firefox UI while not impacting native GTK apps.
author IBBoard <dev@ibboard.co.uk>
date Tue, 12 Nov 2024 18:37:17 +0000
parents d6bf7ed9024c
children
line wrap: on
line source

if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Use bash-completion, if available
if [ -f /etc/bash_completion ]; then
	. /etc/bash_completion
fi

# Use a sane editor
export EDITOR=/usr/bin/nano

# Set 256-colour terminal support
export TERM="screen-256color"

# Default aliases that some distros (Ubuntu) don't do
alias la='ls -la'
alias ll='ls -l'
#Import aliases
test -s ~/.alias && . ~/.alias || true

# Add sbins to path to make life easier (e.g. /sbin/ifconfig)
# Also add our hidden bin directory
export PATH=~/.local/bin:/sbin:/usr/sbin:/usr/local/sbin:$PATH

#Disable man page number prompts - where there's more than one, we normally want the default (user command) version
export MAN_POSIXLY_CORRECT=1

#Disable less history, because do I really search the same things enough to use it across sessions?
export LESSHISTFILE=-

export XDG_CACHE_HOME="$HOME/.cache"

if [ "$PS1" != "" -a "${STARTED_TMUX:-x}" = x -a "${SSH_TTY:-x}" != x ]
then
        STARTED_TMUX=1; export STARTED_TMUX
        sleep 1
        ( (tmux has-session -t remote && tmux attach-session -t remote) || (tmux new-session -s remote) ) && exit 0
        echo "tmux failed to start"
fi

export GTK_IM_MODULE=ibus
export LS_OPTIONS="$LS_OPTIONS -p"

# Speed up compilation and take all the cores! (probably)
export MAKEFLAGS=-j$(lscpu|grep "^CPU(s):"|head -n1|awk '{print $2}')

export PYTHONDONTWRITEBYTECODE=true

function vcs_status {
	GIT_PS1_SHOWDIRTYSTATE=1
	GIT_PS1_SHOWUPSTREAM=verbose
	if [[ -f /etc/bash_completion.d/git-prompt.sh ]]; then
		. /etc/bash_completion.d/git-prompt.sh
	else
		. /usr/share/bash-completion/completions/git-prompt.sh
	fi
	VCS_EXTRA=$(__git_ps1 "%s")

	if [[ "x$VCS_EXTRA" == "x" ]]; then
		if ! command -v rhg &> /dev/null; then
			VCS_EXTRA=$(hg prompt "{branch}{ {status|modified}}{ u{inout}}" 2>/dev/null)
		else
			# If we have rhg then bypass hgprompt for a faster experience on slow machines

			# 24h cache - I normally work on my own, so upstream shouldn't change frequently
			# and we still have hgprompt installed for wrapping commits to update outgoing
			HG_CACHE_TIMEOUT=86400
			HG_ROOT=$(rhg root 2>/dev/null)
			if [[ "x$HG_ROOT" != "x" ]]; then
				HG_BRANCH=$(<"${HG_ROOT}"/.hg/branch)
				HG_MODIFIED=$([ "$(rhg status -marud 2>&1 | grep -v ": Permission denied (os error 13)" | head -c1)" ] && echo " *")
				HG_INCOMING_PATH="${HG_ROOT}"/.hg/prompt/cache/incoming
				HG_OUTGOING_PATH="${HG_ROOT}"/.hg/prompt/cache/outgoing
				if [[ ! -d "${HG_ROOT}"/.hg/prompt/cache/ ]]; then
					mkdir -p "${HG_ROOT}"/.hg/prompt/cache/
				fi
				if [[ ! -f "${HG_INCOMING_PATH}" || $(($(date +%s) - $(date -r "${HG_INCOMING_PATH}" +%s 2>/dev/null || echo 0) )) -gt $HG_CACHE_TIMEOUT ]]; then
					hg incoming --quiet --config ui.interactive=False > "$HG_INCOMING_PATH" 2>/dev/null
					hg outgoing --quiet --config ui.interactive=False > "$HG_OUTGOING_PATH" 2>/dev/null
				fi
				HG_IN=$([ -f "${HG_INCOMING_PATH}" ] && wc -l < "$HG_INCOMING_PATH" 2>/dev/null || echo 0)
				HG_OUT=$([ -f "${HG_OUTGOING_PATH}" ] && wc -l < "$HG_OUTGOING_PATH" 2>/dev/null || echo 0)
				if [[ $HG_IN = "0" && $HG_OUT = "0" ]]; then
					HG_INOUT=" u="
				else
					HG_INOUT=" u"
					if [[ $HG_OUT != "0" ]]; then
						HG_INOUT="${HG_INOUT}+${HG_OUT}"
					fi
					if [[ $HG_IN != "0" ]]; then

						HG_INOUT="${HG_INOUT}-${HG_IN}"
					fi
				fi
				VCS_EXTRA="${HG_BRANCH}${HG_MODIFIED}${HG_INOUT}"
			fi
		fi
	fi
	if [[ "x$VCS_EXTRA" != "x" ]]; then
		echo -n " ($VCS_EXTRA)"
	fi
}

# Limit long paths
PROMPT_DIRTRIM=2
# Bold the command prompt and standardise on SUSE format
# With colour!
export PS1_VCS='\[\033[01;38;5;34m\]\u\[\033[01;38;5;28m\]@\[\033[01;38;5;34m\]\h\[\033[39m\]:\[\033[01;38;5;26m\]\w$(test "$PWD" != / && echo -n /)\[\033[39m\]\[\033[01;38;5;247m\]$(vcs_status)\[\033[39m\]>\[\033[00m\] '
export PS1_NOVCS='\[\033[01;38;5;34m\]\u\[\033[01;38;5;28m\]@\[\033[01;38;5;34m\]\h\[\033[39m\]:\[\033[01;38;5;26m\]\w$(test "$PWD" != / && echo -n /)\[\033[39m\]\[\033[01;38;5;247m\]\[\033[39m\]>\[\033[00m\] '
export PS1=$PS1_VCS

# Fix "less" highlighting
export LESS_TERMCAP_so=$'\033[30;48;5;247m'
export LESS_TERMCAP_se=$'\033[0m'

export GOPATH="$HOME/.golang"

# Possible fix for Steam - https://github.com/ValveSoftware/steam-for-linux/issues/5000#issuecomment-305937612
#export STEAM_RUNTIME_PREFER_HOST_LIBRARIES=0

# Set a hidden R package directory
export R_LIBS_USER=~/.R/
# And stop it asking us to save the workspace
alias R='R --no-save'

conda_activate() {
    __conda_setup="$(~/.anaconda3/bin/conda 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f ~"/.anaconda3/etc/profile.d/conda.sh" ]; then
            . ~"/.anaconda3/etc/profile.d/conda.sh"
        else
            export PATH=~"/.anaconda3/bin:$PATH"
        fi
    fi
    unset __conda_setup

    if [ $# -eq 1 ]; then
    	if [ "x$1" == "x." ]; then
    		_conda_env=$(basename $(readlink -f .))
    	else
    		_conda_env=$1
    	fi
    	conda activate $_conda_env
    fi
    unset _conda_env
}