From aa1acef56faaf5530221328799a5a5cb8f2fe178 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Mon, 20 Jan 2020 23:44:18 -0500 Subject: [PATCH] sh: move .profile -> .shrc for proper startup Just like the bash_profile, ~/.profile is only sourced by login shells. We set the ENV env var to ~/.shrc, so that POSIX shells will go on to then source that file (which had the contents of ~/.profile previously). Interactive shells (not login shells) will read $ENV for their startup configuration. --- bash/bashrc | 2 +- sh/profile | 32 ++++---------------------------- sh/shrc | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 29 deletions(-) create mode 100755 sh/shrc diff --git a/bash/bashrc b/bash/bashrc index 8817b25..cc0bd73 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -20,7 +20,7 @@ aw() { w3m "https://wiki.archlinux.org/index.php?search=$1"; } ddg() { w3m "https://duckduckgo.com/lite?q=$1"; } include() { [ -r "$1" ] && source "$1"; } -include "$HOME/.profile" # Common shell configuration +include "$HOME/.shrc" # Common shell configuration include "$HOME/.bash/git-completion.bash" # Git Completion include "$HOME/.console_theme" # Virtual Console colors (if TERM == "linux") include "$HOME/.bashrc.local" # System specific settings diff --git a/sh/profile b/sh/profile index 3230f36..8346c85 100644 --- a/sh/profile +++ b/sh/profile @@ -1,29 +1,5 @@ #!/bin/sh -# ~/.profile -- the sh profile -# To be used as a base for all other shell rc's -[ -z "$PS1" ] && return - -# Crucial exports -PATH=$HOME/bin:$PATH # Put ~/bin on the for personal scripts -EDITOR='vi' # $EDITOR, the most important (personal) of exports -VISUAL='vi' # Some programs give priority to this - -# Build up a somewhat fancy prompt (with SSH and error code indicators!) -if [ -n "$SSH_CLIENT" ]; then - SSH_PROMPT="[$USER@$(hostname)] " -fi - -last_err() { - err="$?" - if [ $err -ne "0" ]; then - echo "[$err] " - fi -} - -PS1='$(last_err)$PWD $SSH_PROMPT -$ ' -PS2="> " - -export PATH EDITOR VISUAL PS1 PS2 SSH_PROMPT - -[ -r "$HOME/.aliases" ] && . "$HOME/.aliases" +# ~/.profile -- dash/sh/ksh profile +# Sourced for login shells -- set $ENV to ~/.shrc +# to use that as the config for this and all new interactive shells +export ENV="$HOME/.shrc" diff --git a/sh/shrc b/sh/shrc new file mode 100755 index 0000000..5c5f77c --- /dev/null +++ b/sh/shrc @@ -0,0 +1,28 @@ +#!/bin/sh +# ~/.shrc -- a config for all POSIX shells +[ -z "$PS1" ] && return # Exit early if non-interactive + +# Crucial exports +PATH=$HOME/bin:$PATH # Put ~/bin on the for personal scripts +EDITOR='vi' # $EDITOR, the most important (personal) of exports +VISUAL='vi' # Some programs give priority to this + +# Build up a somewhat fancy prompt (with SSH and error code indicators!) +if [ -n "$SSH_CLIENT" ]; then + SSH_PROMPT="[$USER@$(hostname)] " +fi + +last_err() { + err="$?" + if [ $err -ne "0" ]; then + echo "[$err] " + fi +} + +PS1='$(last_err)$PWD $SSH_PROMPT +$ ' +PS2="> " + +export PATH EDITOR VISUAL PS1 PS2 SSH_PROMPT + +[ -r "$HOME/.aliases" ] && . "$HOME/.aliases" -- libgit2 0.28.4