From 2b5c036e7b5ff45e2eed26dd7ce499c6eaf7bf2f Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Fri, 3 May 2019 16:05:40 +0100 Subject: [PATCH] Make bash files posix compliant Ensure TMPDIR is set for every shell! --- bash/.bash_profile | 61 ++++++---------------------------------------- bash/.bashrc | 30 ++++------------------- bash/.profile | 52 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 78 deletions(-) create mode 100644 bash/.profile diff --git a/bash/.bash_profile b/bash/.bash_profile index a10989b..da0b8fb 100644 --- a/bash/.bash_profile +++ b/bash/.bash_profile @@ -1,55 +1,10 @@ -export EDITOR="vim" -export PATH="/home/max/.local/bin:${PATH}" -export TMPDIR="/home/max/.local/tmp" - -if [ -n "$BASH_VERSION" ]; then - # include .bashrc if it exists - if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" - fi -fi - -if [ -f /etc/bash_completion ]; then - . /etc/bash_completion -fi - -export PATH="$HOME/.cargo/bin:$PATH" - -if test -z "${XDG_RUNTIME_DIR}"; then - export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir - if ! test -d "${XDG_RUNTIME_DIR}"; then - mkdir "${XDG_RUNTIME_DIR}" - chmod 0700 "${XDG_RUNTIME_DIR}" - fi -fi - -export QT_QPA_PLATFORM=wayland-egl - -if [ -f ~/.config/sway/config.base ]; then - cat ~/.config/sway/config.base ~/.config/sway/config.${HOSTNAME} > ~/.config/sway/config +if [ -r ~/.profile ]; then + . ~/.profile; fi -if [ -f ~/.Xresources ]; then - cat ~/.Xresources > ~/.Xdefaults - if [ -f ~/.Xresources.$HOSTNAME ]; then - cat ~/.Xresources.$HOSTNAME >> ~/.Xdefaults - fi -fi - -if [ -f ~/.config/termite/config.base ]; then - cat ~/.config/termite/config.base ~/.config/termite/config.${HOSTNAME} > \ - ~/.config/termite/config -fi - - -if [ $HOSTNAME = "magnesium" ]; then - export XKB_DEFAULT_LAYOUT=us - export XKB_DEFAULT_VARIANT=colemak - export XKB_DEFAULT_OPTIONS=ctrl:nocaps -fi - -if [ $HOSTNAME = "platinum" ]; then - export XKB_DEFAULT_LAYOUT=gb - export XKB_DEFAULT_VARIANT=colemak - export XKB_DEFAULT_OPTIONS=ctrl:nocaps -fi +case "$-" in *i*) + if [ -r ~/.bashrc ]; then + . ~/.bashrc + fi + ;; +esac diff --git a/bash/.bashrc b/bash/.bashrc index d9e59b2..262240a 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -2,12 +2,6 @@ # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - # don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth @@ -17,34 +11,16 @@ shopt -s histappend # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 -HISTFILESIZE=2000 +HISTFILESIZE=20000 # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize -# make less more friendly for non-text input files, see lesspipe(1) -if [ -x /usr/bin/lesspipe ]; then - export LESSOPEN="|lesspipe %s" -elif [ -x /usr/bin/lesspipe.sh ]; then - export LESSOPEN="|lesspipe %s" -fi - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - - -# colored GCC warnings and errors -export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - - if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi -eval `dircolors ~/.dir_colors` # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile @@ -136,3 +112,7 @@ fi export GPG_TTY=($tty) gpg-connect-agent updatestartuptty /bye > /dev/null + +export EDITOR="vim" +export TMPDIR="/home/max/.local/tmp" +eval `dircolors ~/.dir_colors` diff --git a/bash/.profile b/bash/.profile new file mode 100644 index 0000000..ac900b6 --- /dev/null +++ b/bash/.profile @@ -0,0 +1,52 @@ +export PATH="${HOME}/.local/bin:${HOME}/.cargo/bin:${PATH}" + +# Make XDG_RUNTIME_DIR, required for some sessions +if test -z "${XDG_RUNTIME_DIR}"; then + export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir + if ! test -d "${XDG_RUNTIME_DIR}"; then + mkdir "${XDG_RUNTIME_DIR}" + chmod 0700 "${XDG_RUNTIME_DIR}" + fi +fi + +export QT_QPA_PLATFORM=wayland-egl + +if [ -f ~/.config/sway/config.base ]; then + cat ~/.config/sway/config.base ~/.config/sway/config.${HOSTNAME} > ~/.config/sway/config +fi + +if [ -f ~/.Xresources ]; then + cat ~/.Xresources > ~/.Xdefaults + if [ -f ~/.Xresources.$HOSTNAME ]; then + cat ~/.Xresources.$HOSTNAME >> ~/.Xdefaults + fi +fi + +if [ -f ~/.config/termite/config.base ]; then + cat ~/.config/termite/config.base ~/.config/termite/config.${HOSTNAME} > \ + ~/.config/termite/config +fi + + +if [ $HOSTNAME = "magnesium" ]; then + export XKB_DEFAULT_LAYOUT=us + export XKB_DEFAULT_VARIANT=colemak + export XKB_DEFAULT_OPTIONS=ctrl:nocaps +fi + +if [ $HOSTNAME = "platinum" ]; then + export XKB_DEFAULT_LAYOUT=gb + export XKB_DEFAULT_VARIANT=colemak + export XKB_DEFAULT_OPTIONS=ctrl:nocaps +fi + +# make less more friendly for non-text input files, see lesspipe(1) +if [ -x /usr/bin/lesspipe ]; then + export LESSOPEN="|lesspipe %s" +elif [ -x /usr/bin/lesspipe.sh ]; then + export LESSOPEN="|lesspipe %s" +fi + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + -- 2.45.2