dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit c713e130a1e5ff461abbd07d3723b10ad5e03098 (patch)
parent 215efe1d04bacae66857cd125978870b590201ef
Author: Alex Karle <alex@alexkarle.com>
Date:   Tue, 23 Feb 2021 00:00:18 -0500

[ba]sh: Cleanup and simplify

The reality of how I use my configs is that any machine not used
for full time programming (a.k.a. work) ends up using just a
stripped down .shrc (no error message in prompt, no colors in ls(1),
a single line prompt...).

I've been running this stripped down .shrc as my default config on
my personal laptop and server for around a month or two now, and I
consider it the "/etc/skel" of my dotfiles. On a server where I won't
be needing a fancy setup, I want just something simple and reliable.
.shrc is that!

Diffstat:
D.aliases | 18------------------
M.bash_profile | 2+-
M.bashrc | 29++++++++++++++++++++++-------
M.shrc | 40++++++++++++++++------------------------
4 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/.aliases b/.aliases @@ -1,18 +0,0 @@ -#!/bin/sh -# Aliases for all shells - -# Detect which `ls` flavor is in use -if ls --color > /dev/null 2>&1; then # GNU `ls` - colorflag="--color" -elif ls -G > /dev/null 2>&1; then # macOS `ls` - colorflag="-G" -fi - -# ls aliases -alias ls='ls ${colorflag}' -alias l='ls -lAh ${colorflag}' -alias ll='ls -lh ${colorflag}' - -# Lightweight funcs -aw() { w3m "https://wiki.archlinux.org/index.php?search=$1"; } -ddg() { w3m "https://duckduckgo.com/lite?q=$1"; } diff --git a/.bash_profile b/.bash_profile @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# sourced by login shells (not interactive shells) +# sourced by non-interactive login shells # Example: # - ssh to Linux --> run bash_profile on login # - open new tmux window --> run bashrc diff --git a/.bashrc b/.bashrc @@ -5,7 +5,21 @@ # If not running interactively, don't do anything [[ $- != *i* ]] && return -# Settings +# Functions +include() { [ -r "$1" ] && source "$1"; } +aw() { w3m "https://wiki.archlinux.org/index.php?search=$1"; } +ddg() { w3m "https://duckduckgo.com/lite?q=$1"; } +last_err() { + err="$?" + if [ $err -ne "0" ]; then + echo "($err) " + fi +} + +# Load ~/.shrc from $ENV (similar to sh(1)'s init) +include "$ENV" + +# Settings / Shell Variables stty -ixon # Disable XON/XOFF to allow forward search w CTRL-S shopt -s checkwinsize # check win size after each cmd, update if needed shopt -s histappend # append to the history file, don't overwrite it @@ -15,13 +29,11 @@ HISTIGNORE=fg:pwd:ls # Don't store common commands in history HISTCONTROL=ignoreboth # Don't store duped / whitespace-led commands in history PROMPT_COMMAND="history -a" # Record history after each command -# Includes -include() { [ -r "$1" ] && source "$1"; } -include "$HOME/.shrc" # Common shell configuration -include "$HOME/etc/console_theme.sh" # Virtual Console colors (if TERM == "linux") -include "$HOME/.bashrc.local" # System specific settings +if [ -n "$PRETTY_COLORS" ]; then + if command -v colorls >/dev/null; then + alias ls=colorls + fi -if [ -n "$USE_FANCY_PROMPT" ]; then parse_git_dirty() { if [ -z "$BASH_PROMPT_NO_GSTATUS" ]; then [ "$(git status --porcelain=v1 2> /dev/null)" ] && echo "*" @@ -49,3 +61,6 @@ if [ -n "$USE_FANCY_PROMPT" ]; then PS2="$YELLOW> $RESET" fi fi + +# Include .local version last as override mechanism +include "$HOME/.bashrc.local" diff --git a/.shrc b/.shrc @@ -1,29 +1,21 @@ #!/bin/sh -# ~/.shrc -- a config for all POSIX shells -[ -z "$PS1" ] && return # Exit early if non-interactive +# ~/.shrc -- a base config for all POSIX shells +# "the /etc/skel to my .bashrc" -# 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 -PAGER='less' # less is more -PERL5LIB=$HOME/perl5/lib/perl5 # default cpanminus location -MANPATH=":$HOME/share/man" -export PATH EDITOR VISUAL PAGER PERL5LIB MANPATH - -# Shell vars +# Shell vars (non-exported) +PS1='\u@\h:\w \$ ' HISTFILE=${HISTFILE:="$HOME/.sh_histo"} # Don't override bash_history +HISTSIZE=10000 -# Prompt -last_err() { - err="$?" - if [ $err -ne "0" ]; then - echo "($err) " - fi -} -PS1='$(last_err)\u@\h:\w \$ ' +# Exports +export PATH="$HOME/bin:$PATH" # Put ~/bin on the for personal scripts +export EDITOR=vi # vi(1) starts faster than vim(1) +export VISUAL=vi # Some programs give priority to this +export PAGER=less # less is more +export PERL5LIB="$HOME/perl5/lib/perl5" # default cpanminus location +export MANPATH=":$HOME/share/man" -# Includes -include() { if [ -r "$1" ]; then . "$1"; fi } -include "$HOME/.aliases" -include "$HOME/.shrc.local" +# Aliases +alias l='ls -1AhF' +alias ll='ls -lAhF' +alias g='git'