commit 18553dbab299d5a6309dee09a41c8709a82cf3e3
parent 393ceaa578f834e56e78c44d89021f023d337441
Author: Daniel Moch <daniel@danielmoch.com>
Date: Tue, 2 Jan 2018 20:47:41 -0500
Shell rcfile breakout
I don't have Bash available to me on every system I use, so it's time to
break out Bourne shell initializations from Bash-specific ones. All of
the Bourne initializations are move to .shrc, while Bash initializations
remain in .bashrc.
Diffstat:
M | .bashrc | | | 121 | ++++--------------------------------------------------------------------------- |
A | .profile | | | 8 | ++++++++ |
A | .shrc | | | 79 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 92 insertions(+), 116 deletions(-)
diff --git a/.bashrc b/.bashrc
@@ -1,66 +1,11 @@
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
-if [[ -f $HOME/.bashrc.local ]]
-then
- source $HOME/.bashrc.local
-fi
+[ -r $HOME/.shrc ] && source $HOME/.shrc
+[ -r $HOME/.bashrc.local ] && source $HOME/.bashrc.local
-export EDITOR=vim
export HISTCONTOL=erasedups
-# Keep the go folder hidden
-if command -v go > /dev/null 2>&1
-then
- export GOPATH=$HOME/.go
-fi
-
-# Turn on ls colors
-if command -v dircolors > /dev/null 2>&1
-then
- if [ -n "$SOURCE_DIRCOLORS" ]
- then
- eval $(dircolors $HOME/.dir_colors)
- alias ls='ls --color=auto'
- fi
-else
- export CLICOLOR=1
- export LSCOLORS=ExFxBxDxCxegedabagacad
-fi
-
-# Colorize others if they exist
-COLORIZE_CMDS="pacman grep egrep fgrep"
-for cmd in $COLORIZE_CMDS
-do
- if command -v $cmd > /dev/null 2>&1
- then
- alias $cmd="$cmd --color=auto"
- fi
-done
-
-# Configure GPG and start the agent if it isn't already running
-if command -v gpg-connect-agent > /dev/null 2>&1
-then
- gpg-connect-agent /bye > /dev/null 2>&1
-fi
-
-# Configure GPG as an SSH key provider
-export GPG_TTY=$(tty)
-gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1
-unset SSH_AGENT_PID
-
-# Assume SSH agent is forwarded if we're in an SSH session
-if [[ -z "$SSH_TTY" ]]
-then
- if [[ -S $HOME/.gnupg/S.gpg-agent.ssh ]]
- then
- export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh
- elif [[ -S /run/user/$UID/gnupg/S.gpg-agent.ssh ]]
- then
- export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
- fi
-fi
-
# Git command line configuration
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
@@ -69,23 +14,6 @@ source $HOME/.config/bash/git-prompt.sh
# Customize the prompt
export PS1='\[\033[34m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[m\]\W\[\033[31m\]$(__git_ps1 " (%s)")\[\033[m\]\$ '
-# Append our default paths
-__appendpath () {
- if [[ -d "$1" ]]
- then
- case ":$PATH:" in
- *:"$1":*)
- ;;
- *)
- PATH="$PATH:$1"
- esac
- fi
-}
-
-__appendpath "$HOME/.go/bin"
-__appendpath "$HOME/.cargo/bin"
-__appendpath "$HOME/.local/bin"
-
# Configure Homebrew
if command -v brew > /dev/null 2>&1
then
@@ -106,54 +34,15 @@ fi
#
# NOTE: Might want to check that this isn't already sourced elsewhere
# (e.g. /etc/profile).
-if [[ -n "$BASH_COMPLETION" ]] && [[ -r $BASH_COMPLETION ]]
-then
- source $BASH_COMPLETION
-fi
+[ -r "$BASH_COMPLETION" ] && source $BASH_COMPLETION
unset BASH_COMPLETION
-# Handy Tmux aliases
-if command -v tmux > /dev/null 2>&1
-then
- alias tas=tmux\ attach-session\ -t
- alias tns=tmux\ new-session\ -s
- alias tls=tmux\ list-sessions
-fi
-
-if [[ $OSTYPE == "darwin"* ]]
+if [ "$OSTYPE" == "darwin"* ]
then
alias jackd="jackd -d coreaudio > /dev/null 2>&1 &"
fi
-ix()
-{
- local opts
- local OPTIND
- [ -f "$HOME/.netrc" ] && opts='-n'
- while getopts ":hd:i:n:" x; do
- case $x in
- h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;;
- d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;;
- i) opts="$opts -X PUT"; local id="$OPTARG";;
- n) opts="$opts -F read:1=$OPTARG";;
- esac
- done
- shift $(($OPTIND - 1))
- [ -t 0 ] &&
- {
- local filename="$1"
- shift
- [ "$filename" ] &&
- {
- curl $opts -F f:1=@"$filename" $* ix.io/$id
- return
- }
- echo "^C to cancel, ^D to send."
- }
- curl $opts -F f:1='<-' $* ix.io/$id
-}
-
-if command -v archey3 > /dev/null 2>&1 && [[ -z "$TMUX" ]]
+if command -v archey3 > /dev/null 2>&1 && [ -z "$TMUX" ]
then
archey3
fi
diff --git a/.profile b/.profile
@@ -0,0 +1,8 @@
+#
+# ~/.profile
+#
+if [ -r "$HOME/.shrc" ]
+then
+ . $HOME/.shrc
+ export ENV=$HOME/.shrc
+fi
diff --git a/.shrc b/.shrc
@@ -0,0 +1,79 @@
+#
+# ~/.shrc
+#
+# vim: ft=sh
+[ -r $HOME/.shrc.local ] && . $HOME/.shrc.local
+EDITOR=vim
+VISUAL=$EDITOR
+export EDITOR VISUAL
+
+# Keep the go folder hidden
+if which go > /dev/null 2>&1
+then
+ export GOPATH=$HOME/.go
+fi
+
+# Turn on ls colors
+if which dircolors > /dev/null 2>&1
+then
+ if [ -n "$SOURCE_DIRCOLORS" ]
+ then
+ eval `dircolors $HOME/.dir_colors`
+ alias ls='ls --color=auto'
+ unset SOURCE_DIRCOLORS
+ fi
+else
+ export CLICOLOR=1
+ export LSCOLORS=ExFxBxDxCxegedabagacad
+fi
+
+# Colorize others if they exist
+COLORIZE_CMDS="pacman grep egrep fgrep"
+for cmd in $COLORIZE_CMDS
+do
+ if which $cmd > /dev/null 2>&1
+ then
+ alias $cmd="$cmd --color=auto"
+ fi
+done
+
+# Configure GPG and start the agent if it isn't already running
+if which gpg-connect-agent > /dev/null 2>&1
+then
+ export GPG_TTY=`tty`
+ gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1
+
+ # Configure GPG as an SSH key provider
+ # Assume SSH agent is forwarded if we're in an SSH session
+ if [ -z "$SSH_TTY" ] && which gpgconf > /dev/null 2>&1
+ then
+ unset SSH_AGENT_PID
+ export SSH_AUTH_SOCK=`gpgconf --list-dirs agent-ssh-socket`
+ fi
+fi
+
+# Append our default paths
+__appendpath ()
+{
+ if [ -d "$1" ]
+ then
+ case ":$PATH:" in
+ *:"$1":*)
+ ;;
+ *)
+ PATH="$PATH:$1"
+ esac
+ fi
+}
+
+__appendpath "$HOME/.go/bin"
+__appendpath "$HOME/.cargo/bin"
+__appendpath "$HOME/.local/bin"
+
+# Handy Tmux aliases
+if which tmux > /dev/null 2>&1
+then
+ alias tas=tmux\ attach-session\ -t
+ alias tns=tmux\ new-session\ -s
+ alias tls=tmux\ list-sessions
+fi