view bashrc @ 151:d0aef31d4122

Speed up compilation but stop Python making bytecode! * Set compilation flags for parallel compilation * Set a Python variable so that hg-prompt doesn't keep writing `~/__pycache__/` files
author IBBoard <dev@ibboard.co.uk>
date Tue, 11 Jan 2022 20:47:06 +0000
parents 39abe6b6233f
children 99a7805cb924
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"

#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
	. /etc/bash_completion.d/git-prompt.sh
	VCS_EXTRA=$(__git_ps1 "%s")

	if [[ "x$VCS_EXTRA" == "x" ]]; then
		VCS_EXTRA=$(hg prompt "{branch}{ {status|modified}}" 2>/dev/null)
		HG_EXTRA=$(hg prompt "{-{incoming|count}}{+{outgoing|count}}" 2>/dev/null)
		if [[ "x$HG_EXTRA" != "x" ]]; then
			VCS_EXTRA="${VCS_EXTRA} u${HG_EXTRA}"
		elif [[ "x$VCS_EXTRA" != "x" ]]; then
			VCS_EXTRA="${VCS_EXTRA} u="
		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='\[\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\] '

# 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
}