dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit e6093ab45c7891e21f0057ef0c39fb53fbd31a68
parent 1a2a02ebb0d281ce524a1e2c78f0c30bc01babaa
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Tue,  1 Oct 2019 19:05:19 -0400

Modularize sh init files

Diffstat:
M.profile | 91+++++++++++++------------------------------------------------------------------
A.profile.d/brew.sh | 10++++++++++
A.profile.d/browser.sh | 9+++++++++
A.profile.d/cargo.sh | 1+
A.profile.d/editor.sh | 8++++++++
A.profile.d/env.sh | 2++
A.profile.d/go.sh | 6++++++
A.profile.d/gpg.sh | 9+++++++++
A.profile.d/hostname.sh | 2++
A.profile.d/logname.sh | 2++
A.profile.d/my.sh | 1+
A.profile.d/pager.sh | 15+++++++++++++++
A.profile.d/sh.sh | 6++++++
A.profile.d/visual.sh | 2++
M.shrc | 104++++----------------------------------------------------------------------------
A.shrc.d/alias.sh | 15+++++++++++++++
A.shrc.d/gpg.sh | 5+++++
A.shrc.d/motd.sh | 7+++++++
A.shrc.d/num.sh | 3+++
A.shrc.d/proj.sh | 7+++++++
A.shrc.d/ps1.sh | 35+++++++++++++++++++++++++++++++++++
A.shrc.d/ssh.sh | 4++++
22 files changed, 168 insertions(+), 176 deletions(-)

diff --git a/.profile b/.profile @@ -1,93 +1,32 @@ # # ~/.profile # -[ -r "$HOME/.profile.local" ] && . "$HOME/.profile.local" - -if [ "$0" = "sh" -o "$0" = "-sh" ] -then - HOSTNAME=`hostname | cut -d . -f 1`; export HOSTNAME - ENV="$HOME/.shrc"; export ENV -fi - -if type ed > /dev/null 2>&1 -then - EDITOR=ed -else - EDITOR=ex -fi - -VISUAL=vi -PAGER=less -LESS="-FMRqX#10" -export EDITOR VISUAL PAGER LESS - -WWW_HOME=https://danielmoch.com; export WWW_HOME - -if type lesspipe > /dev/null 2>&1 -then - eval `lesspipe` -else - LESSOPEN="|$HOME/.lessfilter %s" - export LESSOPEN -fi - -if type brew > /dev/null 2>&1 -then - HOMEBREW_NO_ANALYTICS=1 - HOMEBREW_NO_INSECURE_REDIRECT=1 - HOMEBREW_CASK_OPTS=--require-sha\ --appdir="$HOME/Applications" - HOMEBREW_NO_AUTO_UPDATE=1 - export HOMEBREW_NO_ANALYTICS HOMEBREW_NO_INSECURE_REDIRECT - export HOMEBREW_CASK_OPTS HOMEBREW_NO_AUTO_UPDATE -fi - -if type go > /dev/null 2>&1 -then - GOPATH="$HOME/.go" - export GOPATH -fi - -QT_AUTO_SCREEN_SCALE_FACTOR=1; export QT_AUTO_SCREEN_SCALE_FACTOR - __addpath () { if [ -d "$1" ] then - case ":$PATH:" in - *:"$1":*) - ;; - *) - if [ -z "$2" ] - then - PATH="$PATH:$1" - else - PATH="$1:$PATH" - fi - esac + case ":$PATH:" in + *:"$1":*) + ;; + *) + if [ -z "$2" ] + then + PATH="$PATH:$1" + else + PATH="$1:$PATH" + fi + esac fi } -__addpath "$HOME/.go/bin" -__addpath "$HOME/.cargo/bin" -if type brew > /dev/null 2>&1 -then - __addpath "`brew --prefix`/bin" "before" -fi -__addpath "$HOME/.local/bin" "before" +for file in .profile.d/*.sh +do + [ -r $file ] && . $file +done unset __addpath export PATH -if [ -z "$SSH_TTY" ] && type gpgconf > /dev/null 2>&1 -then - if [ "`gpgconf --list-dirs agent-ssh-socket | wc -l`" -eq 1 ] - then - unset SSH_AGENT_PID - SSH_AUTH_SOCK=`gpgconf --list-dirs agent-ssh-socket` - export SSH_AUTH_SOCK - fi -fi - if type my-init > /dev/null 2>&1 && [ ! -f "$HOME/._.djmoch" ] then my-init diff --git a/.profile.d/brew.sh b/.profile.d/brew.sh @@ -0,0 +1,10 @@ +if type brew > /dev/null 2>&1 +then + HOMEBREW_NO_ANALYTICS=1 + HOMEBREW_NO_INSECURE_REDIRECT=1 + HOMEBREW_CASK_OPTS=--require-sha\ --appdir="$HOME/Applications" + HOMEBREW_NO_AUTO_UPDATE=1 + export HOMEBREW_NO_ANALYTICS HOMEBREW_NO_INSECURE_REDIRECT + export HOMEBREW_CASK_OPTS HOMEBREW_NO_AUTO_UPDATE + __addpath "`brew --prefix`/bin" "before" +fi diff --git a/.profile.d/browser.sh b/.profile.d/browser.sh @@ -0,0 +1,9 @@ +if type w3m > /dev/null 2>&1 +then + BROWSER=w3m + WWW_HOME=https://www.danielmoch.com; export WWW_HOME +elif type lynx > /dev/null 2>&1 +then + BROWSER=lynx +fi +export BROWSER diff --git a/.profile.d/cargo.sh b/.profile.d/cargo.sh @@ -0,0 +1 @@ +__addpath "$HOME/.cargo/bin" diff --git a/.profile.d/editor.sh b/.profile.d/editor.sh @@ -0,0 +1,8 @@ +if type ed > /dev/null 2>&1 +then + EDITOR=ed +else + EDITOR=ex +fi +FCEDIT=$EDITOR +export EDITOR FCEDIT diff --git a/.profile.d/env.sh b/.profile.d/env.sh @@ -0,0 +1,2 @@ +ENV=.shrc +export ENV diff --git a/.profile.d/go.sh b/.profile.d/go.sh @@ -0,0 +1,6 @@ +if type go > /dev/null 2>&1 +then + GOPATH="$HOME/.go" + export GOPATH + __addpath "$HOME/.go/bin" +fi diff --git a/.profile.d/gpg.sh b/.profile.d/gpg.sh @@ -0,0 +1,9 @@ +if [ -z "$SSH_TTY" ] && type gpgconf > /dev/null 2>&1 +then + if [ "`gpgconf --list-dirs agent-ssh-socket | wc -l`" -eq 1 ] + then + unset SSH_AGENT_PID + SSH_AUTH_SOCK=`gpgconf --list-dirs agent-ssh-socket` + export SSH_AUTH_SOCK + fi +fi diff --git a/.profile.d/hostname.sh b/.profile.d/hostname.sh @@ -0,0 +1,2 @@ +HOSTNAME=$(uname -n|cut -d. -f1) +export HOSTNAME diff --git a/.profile.d/logname.sh b/.profile.d/logname.sh @@ -0,0 +1,2 @@ +LOGNAME=$(logname) +export LOGNAME diff --git a/.profile.d/my.sh b/.profile.d/my.sh @@ -0,0 +1 @@ +__addpath "$HOME/.local/bin" "before" diff --git a/.profile.d/pager.sh b/.profile.d/pager.sh @@ -0,0 +1,15 @@ +if type less > /dev/null 2>&1 +then + PAGER=less + LESS="-FMRqX#10"; export LESS + if type lesspipe > /dev/null 2>&1 + then + eval `lesspipe` + else + LESSOPEN="|$HOME/.lessfilter %s" + export LESSOPEN + fi +else + PAGER=more +fi +export PAGER diff --git a/.profile.d/sh.sh b/.profile.d/sh.sh @@ -0,0 +1,6 @@ +MAIL=$HOME/Mail/dotcom/INBOX +MAILCHECK=1 +HISTSIZE=1000 +HISTFILE="$HOME/.sh_history" +HISTCONTROL=erasedups +export MAIL MAILCHECK HISTSIZE HISTCONTROL HISTFILE diff --git a/.profile.d/visual.sh b/.profile.d/visual.sh @@ -0,0 +1,2 @@ +VISUAL=vi +export VISUAL diff --git a/.shrc b/.shrc @@ -1,105 +1,9 @@ # # ~/.shrc # -# vim: ft=sh -[ -r "$HOME/.shrc.local" ] && . "$HOME/.shrc.local" - -set -o emacs printf "\033]0;$LOGNAME@$HOSTNAME\007" -__ps1() { - last=$? - [ $last -ne 0 ] && echo -n "[$last] " - echo -n $LOGNAME@$HOSTNAME: - if [ "$PWD" = "$HOME" ] - then - echo -n '~' - else - echo -n $(basename $PWD) - fi - - if type git > /dev/null 2>&1 - then - if git rev-parse --show-toplevel > /dev/null 2>&1 - then - gitref=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) - [ $? -ne 0 ] && gitref="GIT: empty" - [ "$gitref" = HEAD ] && gitref=\($(git rev-parse --short HEAD)\) - git diff --no-ext-diff --quiet || status="*" - git diff --no-ext-diff --cached --quiet || status="$status+" - if [ "$(git config --bool sh.showUntrackedFiles)" != "false" ] && - git ls-files --others --exclude-standard --directory \ - --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null - then - status="$status%" - fi - [ -n "$status" ] && gitref="$gitref $status" - echo " ($gitref)" - else - echo - fi - fi -} -PS1='$(__ps1)\$ ' -export PS1 - -ssh() { - $(which ssh) "$@" - printf "\033]0;$LOGNAME@$HOSTNAME\007" -} -num() { - pr -tn "$1" | $PAGER -} -proj() { - if [ -d "$HOME/Documents/src/$1" ] - then - cd "$HOME/Documents/src/$1" - [ -f .env ] && . ./.env - fi -} - -alias ll="ls -l" -alias la="ls -A" -alias lla="ls -lA" -alias tas="tmux attach-session -t" -alias tns="tmux new-session -s" -alias tls="tmux list-sessions" -alias ts="tmux-session" -alias psh="pass show" -alias pc="pass -c" -alias pls="pass ls" -alias feh="feh --auto-rotate --scale-down" -alias rsync="rsync -C --include=.git/" -alias ag="ag -p ~/.cvsignore" -alias pacupdates="cat /run/motd.pacman" -alias psu="ps -U $LOGNAME" - -if [ "$VISUAL" = "vi" ] -then - alias vim="vi" -fi - -case `uname -s` in - *Darwin*) - alias jackd="jackd -d coreaudio > /dev/null 2>&1 &" - ;; -esac - -if echo $LANG | grep UTF-8 > /dev/null 2>&1 -then - alias screen="screen -U" -fi - -if type gpg-connect-agent > /dev/null 2>&1 -then - GPG_TTY=`tty`; export GPG_TTY - gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1 -fi - -if [ ! -f "$HOME/.hushlogin" ] -then - if [ -r /etc/motd -a -n "$DISPLAY" -a -z "$SSH_TTY" ] - then - [ $SHLVL -le 1 ] && cat /etc/motd - fi -fi +for file in .shrc.d/*.sh +do + [ -r $file ] && . $file +done diff --git a/.shrc.d/alias.sh b/.shrc.d/alias.sh @@ -0,0 +1,15 @@ +alias ll="ls -l" +alias la="ls -A" +alias lla="ls -lA" +alias tas="tmux attach-session -t" +alias tns="tmux new-session -s" +alias tls="tmux list-sessions" +alias ts="tmux-session" +alias psh="pass show" +alias pc="pass -c" +alias pls="pass ls" +alias feh="feh --auto-rotate --scale-down" +alias rsync="rsync -C --include=.git/" +alias ag="ag -p ~/.cvsignore" +alias pacupdates="cat /run/motd.pacman" +alias psu="ps -U $LOGNAME" diff --git a/.shrc.d/gpg.sh b/.shrc.d/gpg.sh @@ -0,0 +1,5 @@ +if type gpg-connect-agent > /dev/null 2>&1 +then + GPG_TTY=`tty`; export GPG_TTY + gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1 +fi diff --git a/.shrc.d/motd.sh b/.shrc.d/motd.sh @@ -0,0 +1,7 @@ +if [ ! -f "$HOME/.hushlogin" ] +then + if [ -r /etc/motd -a -n "$DISPLAY" -a -z "$SSH_TTY" ] + then + [ $SHLVL -le 1 ] && cat /etc/motd + fi +fi diff --git a/.shrc.d/num.sh b/.shrc.d/num.sh @@ -0,0 +1,3 @@ +num() { + pr -tn "$1" | $PAGER +} diff --git a/.shrc.d/proj.sh b/.shrc.d/proj.sh @@ -0,0 +1,7 @@ +proj() { + if [ -d "$HOME/Documents/src/$1" ] + then + cd "$HOME/Documents/src/$1" + [ -f .env ] && . ./.env + fi +} diff --git a/.shrc.d/ps1.sh b/.shrc.d/ps1.sh @@ -0,0 +1,35 @@ +__ps1() { + last=$? + [ $last -ne 0 ] && echo -n "[$last] " + echo -n $LOGNAME@$HOSTNAME: + if [ "$PWD" = "$HOME" ] + then + echo -n '~' + else + echo -n $(basename $PWD) + fi + + if type git > /dev/null 2>&1 + then + if git rev-parse --show-toplevel > /dev/null 2>&1 + then + gitref=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) + [ $? -ne 0 ] && gitref="GIT: empty" + [ "$gitref" = HEAD ] && gitref=\($(git rev-parse --short HEAD)\) + git diff --no-ext-diff --quiet || status="*" + git diff --no-ext-diff --cached --quiet || status="$status+" + if [ "$(git config --bool sh.showUntrackedFiles)" != "false" ] && + git ls-files --others --exclude-standard --directory \ + --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null + then + status="$status%" + fi + [ -n "$status" ] && gitref="$gitref $status" + echo " ($gitref)" + else + echo + fi + fi +} +PS1='$(__ps1)\$ ' +export PS1 diff --git a/.shrc.d/ssh.sh b/.shrc.d/ssh.sh @@ -0,0 +1,4 @@ +ssh() { + $(which ssh) "$@" + printf "\033]0;$LOGNAME@$HOSTNAME\007" +}