From e292eb508413b9174684a8e75c93474a7f5351ee Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 23 Aug 2021 23:07:31 -0500 Subject: Initial --- Makefile | 10 ++++++ bash/aliases.bash | 26 ++++++++++++++ bash/blesh.bash.disable | 1 + bash/dircolors.bash | 1 + bash/functions.bash | 11 ++++++ bash/guix.bash | 3 ++ bash/history.bash | 35 +++++++++++++++++++ bash/man.bash | 9 +++++ bash/please.bash | 14 ++++++++ bash/prompt.bash | 25 ++++++++++++++ bootstrap/bash_logout | 6 ++++ bootstrap/bash_profile | 4 +++ bootstrap/bashrc | 41 ++++++++++++++++++++++ bootstrap/profile | 17 ++++++++++ git/attributes | 3 ++ git/config | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ git/ignore | 3 ++ profile/defaults.sh | 4 +++ profile/etc.sh | 10 ++++++ profile/infopath.sh | 1 + profile/less.sh | 3 ++ profile/luarocks.sh | 4 +++ profile/manpath.sh | 9 +++++ profile/path.sh | 30 +++++++++++++++++ profile/xdg.sh | 27 +++++++++++++++ readline/inputrc | 22 ++++++++++++ user-dirs.dirs | 15 +++++++++ 27 files changed, 424 insertions(+) create mode 100644 Makefile create mode 100644 bash/aliases.bash create mode 100644 bash/blesh.bash.disable create mode 100644 bash/dircolors.bash create mode 100644 bash/functions.bash create mode 100644 bash/guix.bash create mode 100644 bash/history.bash create mode 100644 bash/man.bash create mode 100644 bash/please.bash create mode 100644 bash/prompt.bash create mode 100644 bootstrap/bash_logout create mode 100644 bootstrap/bash_profile create mode 100644 bootstrap/bashrc create mode 100644 bootstrap/profile create mode 100644 git/attributes create mode 100644 git/config create mode 100644 git/ignore create mode 100644 profile/defaults.sh create mode 100644 profile/etc.sh create mode 100644 profile/infopath.sh create mode 100644 profile/less.sh create mode 100644 profile/luarocks.sh create mode 100644 profile/manpath.sh create mode 100644 profile/path.sh create mode 100644 profile/xdg.sh create mode 100644 readline/inputrc create mode 100644 user-dirs.dirs diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..712877b --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +# ~/etc/ Makefile + +BOOTSTRAPS:=$(wildcard bootstrap/*) +BOOTSTRAPS_OUT:=$(foreach b,$(BOOTSTRAPS),$(patsubst bootstrap/%,~/.%,$(b))) + +.PHONY: bootstrap +bootstrap: $(BOOTSTRAPS_OUT) + +~/.%: bootstrap/% + ln -sf etc/$< $@ diff --git a/bash/aliases.bash b/bash/aliases.bash new file mode 100644 index 0000000..f2d6776 --- /dev/null +++ b/bash/aliases.bash @@ -0,0 +1,26 @@ +# Bash aliases + +# sudo +sudo_cmds=( + shutdown + reboot + halt + mount + umount + visudo +) +for cmd in "${sudo_cmds[@]}"; do + alias $cmd="sudo $cmd" +done + +# LS +alias ls='ls -F --color=auto' +alias ll='ls -l' +# tree +alias tree='tree -F' + +# make locally +alias lake='make PREFIX=~/usr' + +# bash meta +alias rebash='source ~/.bash_profile' diff --git a/bash/blesh.bash.disable b/bash/blesh.bash.disable new file mode 100644 index 0000000..9fc617b --- /dev/null +++ b/bash/blesh.bash.disable @@ -0,0 +1 @@ +source "$XDG_DATA_HOME/blesh/ble.sh" diff --git a/bash/dircolors.bash b/bash/dircolors.bash new file mode 100644 index 0000000..597ee95 --- /dev/null +++ b/bash/dircolors.bash @@ -0,0 +1 @@ +eval $(dircolors --sh "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors") diff --git a/bash/functions.bash b/bash/functions.bash new file mode 100644 index 0000000..058e0f9 --- /dev/null +++ b/bash/functions.bash @@ -0,0 +1,11 @@ +memq() { # memq ITEM ARRAY + # Test whether an ITEM is a member of ARRAY. + # Pass ARRAY as ${ARRAY[@]}. + local e needle="$1"; shift + for e; do + [[ "$e" == "$needle" ]] && { + return 0 + } + done + return 1 +} diff --git a/bash/guix.bash b/bash/guix.bash new file mode 100644 index 0000000..127afef --- /dev/null +++ b/bash/guix.bash @@ -0,0 +1,3 @@ +export GUIX_PROFILE="$HOME/.config/guix/current" + +. "$GUIX_PROFILE/etc/profile" diff --git a/bash/history.bash b/bash/history.bash new file mode 100644 index 0000000..95edf9d --- /dev/null +++ b/bash/history.bash @@ -0,0 +1,35 @@ +# Bash history settings +# I don't export any variables in this file because history settings +# really only apply in an interactive session. + +# XDG compliance +HISTFILE="$XDG_DATA_HOME/bash/history" +mkdir -p "$XDG_DATA_HOME/bash" + +# Don't truncate history +HISTFILESIZE=-1 # numeric values less than zero => don't truncate +HISTSIZE=100000 # ideally, I wouldn't truncate at all, but after a while shell +# startup might be affected. + +# Append the history to HISTFILE. +shopt -s histappend + +# History editing with readline +shopt -s histreedit # allow re-editing of a failed history substitution +shopt -s histverify # verify a history expansion before running it + +# Save command invocation time to HISTFILE, and format it thusly +HISTTIMEFORMAT="%F %T " + +# Erase all duplicates before saving the current line +HISTCONTROL=erasedups +# Don't save some commands to history +# "'HISTIGNORE' subsumes the function of 'HISTCONTROL'. A pattern of +# '&' is identical to 'ignoredups', and a pattern of '[ ]*' is +# identical to 'ignorespace'." -- info (bash)Bash Variables +HISTIGNORE='&:[ ]*' +# Other commands to ignore +HISTIGNORE="$HISTIGNORE:ls:exit:cd" + +# Automatically append to HISTFILE on every command +PROMPT_COMMAND="history -a; ${PROMPT_COMMAND:-:}" diff --git a/bash/man.bash b/bash/man.bash new file mode 100644 index 0000000..4927952 --- /dev/null +++ b/bash/man.bash @@ -0,0 +1,9 @@ +export MANWIDTH=80 + +# on smaller terminals, use their width +# (cf. https://wiki.archlinux.org/index.php/Man_page#Page_width) +man() { + local width=$(tput cols) + [ $width -gt $MANWIDTH ] && width=$MANWIDTH + env MANWIDTH=$width man "$@" +} diff --git a/bash/please.bash b/bash/please.bash new file mode 100644 index 0000000..179ed17 --- /dev/null +++ b/bash/please.bash @@ -0,0 +1,14 @@ +# PLEASE +# if run without arguments, run the last command with 'sudo' (aka sudo !!) +# if run WITH arguments, alias as sudo + +please() { + history -d -1 + if [ -z "$1" ]; then + #set -- $(HISTTIMEFORMAT=$'\t' history 2 | sed 's/^.*\t//;q') + set -- $(fc -lnr | sed 1q) + fi + echo >&2 sudo "$@" + history -s sudo "$@" + "${DEBUG:-false}" || sudo "$@" +} diff --git a/bash/prompt.bash b/bash/prompt.bash new file mode 100644 index 0000000..c61266b --- /dev/null +++ b/bash/prompt.bash @@ -0,0 +1,25 @@ +# bash prompt + +PS1= + +# user, host, and cwd +PROMPT_DIRTRIM=3 # how many dirs above current to print (rest are '...') +PS1+='\[\e[36m\]\u@\h \w' + +# git bit +source /usr/share/git/git-prompt.sh && + PS1+='\[\e[35m\]$(__git_ps1)' + +# newline +PS1+='\[\e[0m\]\n' + +# exit code (only if error) +__prompt_exit_code() { + local ec=$? + (( $ec > 0 )) && + printf "$ec" +} +PS1+='\[\e[31m\]$(__prompt_exit_code)\[\e[0m\]' + +# delimiter +PS1+='; ' diff --git a/bootstrap/bash_logout b/bootstrap/bash_logout new file mode 100644 index 0000000..d6c9b7a --- /dev/null +++ b/bootstrap/bash_logout @@ -0,0 +1,6 @@ +# bash_logout +# vim:ft=sh + +if [[ -r "$XDG_CONFIG_HOME"/bash/logout ]]; then + source "$XDG_CONFIG_HOME"/bash/logout +fi diff --git a/bootstrap/bash_profile b/bootstrap/bash_profile new file mode 100644 index 0000000..4439ca7 --- /dev/null +++ b/bootstrap/bash_profile @@ -0,0 +1,4 @@ +# bash_profile + +[[ -f ~/.profile ]] && source ~/.profile +[[ -f ~/.bashrc ]] && source ~/.bashrc diff --git a/bootstrap/bashrc b/bootstrap/bashrc new file mode 100644 index 0000000..4966e75 --- /dev/null +++ b/bootstrap/bashrc @@ -0,0 +1,41 @@ +# bashrc + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +BASH_SOURCE_FIRST=( + aliases + functions +) + +BASH_SOURCE_LAST=( + blesh +) + +for f in "${BASH_SOURCE_FIRST[@]}"; do + file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash" + [[ -r "$file" ]] && source "$file" # || echo >&2 "no '$file' found" +done + +for file in "$XDG_CONFIG_HOME"/bash/*.bash; do + file_base="${file##*/}" + memq "${file_base%.bash}" "${BASH_SOURCE_FIRST[@]}" && { + # echo >&2 "'$file' in BASH_SOURCE_FIRST, skipping" + continue + } + memq "${file_base%.bash}" "${BASH_SOURCE_LAST[@]}" && { + # echo >&2 "'$file' in BASH_SOURCE_LAST, skipping" + continue + } + [[ -r "$file" ]] && { + # echo >&2 "Sourcing '$file'" + source "$file" + } + unset file_base +done + +for f in "${BASH_SOURCE_LAST[@]}"; do + file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash" + [[ -r "$file" ]] && source "$file" # || echo >&2 "no '$file' found" + true +done diff --git a/bootstrap/profile b/bootstrap/profile new file mode 100644 index 0000000..4cb459d --- /dev/null +++ b/bootstrap/profile @@ -0,0 +1,17 @@ +# profile +# vim:ft=sh + +# XDG directories +export XDG_CONFIG_HOME="$HOME/etc" +export XDG_CACHE_HOME="$HOME/var/cache" +export XDG_DATA_HOME="$HOME/usr/share" + +export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" +export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}" + +# source files in $XDG_CONFIG_HOME/profile +if [ -d "$XDG_CONFIG_HOME/profile" ]; then + for file in "$XDG_CONFIG_HOME"/profile/*.sh; do + [ -r "$file" ] && . "$file" + done +fi diff --git a/git/attributes b/git/attributes new file mode 100644 index 0000000..a5516e5 --- /dev/null +++ b/git/attributes @@ -0,0 +1,3 @@ +*.lisp diff=lisp +*.el diff=lisp +*.org diff=org diff --git a/git/config b/git/config new file mode 100644 index 0000000..cad9e12 --- /dev/null +++ b/git/config @@ -0,0 +1,90 @@ +[user] + email = acdw@acdw.net + name = Case Duckworth + +[init] + defaultBranch = main + +[push] + default = simple + +[pull] + rebase = false + +[core] + editor = vim + precomposeunicode = true + pager = less + autocrlf = false + eol = lf + +[merge] + conflictstyle = diff3 + tool = vimdiff + +[alias] + # Easier locations + root = rev-parse --show-toplevel + current-branch = rev-parse --abbrev-ref HEAD + # Easier listing and info + branches = branch -a + tags = tag -l + stashes = stash list + remotes = remote -v + staged = diff --cached + graph = log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset: %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order + precommit = diff --cached --diff-algorithm=minimal -w + # Easier actions + discard = checkout -- + uncommit = reset --soft HEAD^ + unstage = reset HEAD -- + amend = commit --amend + pushall = !git remote | xargs -L1 git push --all + # Shortened commonalities + st = status -bs + ac = !git add . && git commit -m + +# diffing +[diff "lisp"] + xfuncname = "^(\\(.*)$" +[diff "org"] + xfuncname = "^(\\*+.*)$" + +; [credential] +; helper = /home/case/.local/bin/pass-git-helper +; useHttpPath = true + +[bash] + showUntrackedFiles = true + showDirtyState = true + +[sendemail] + smtpserver = smtp.fastmail.com + smtpuser = acdw@fastmail.com + smtpencryption = tls + smtpserverport = 465 + +# Better urls +[url "https://github.com/"] + insteadOf = "gh:" +[url "git@github.com:"] + pushInsteadOf = "gh:" +[github] + user = duckwork + +[url "https://gitlab.com/"] + insteadOf = "gl:" +[url "git@gitlab.com:"] + pushInsteadOf = "gl:" +[gitlab] + user = acdw + +[url "https://git.sr.ht/"] + insteadOf = "sr:" +[url "git@git.sr.ht:"] + pushInsteadOf = "sr:" + +[url "https://tildegit.org/"] + insteadOf = "tg:" +[url "git@tildegit.org:"] + pushInsteadOf = "tg:" diff --git a/git/ignore b/git/ignore new file mode 100644 index 0000000..6a4c747 --- /dev/null +++ b/git/ignore @@ -0,0 +1,3 @@ +*.sw? +*~ +.DS\_Store diff --git a/profile/defaults.sh b/profile/defaults.sh new file mode 100644 index 0000000..8facc97 --- /dev/null +++ b/profile/defaults.sh @@ -0,0 +1,4 @@ +# Default programs + +export EDITOR="$(which vim)" # TODO: change to emacs +export VISUAL="$EDITOR" diff --git a/profile/etc.sh b/profile/etc.sh new file mode 100644 index 0000000..5458f02 --- /dev/null +++ b/profile/etc.sh @@ -0,0 +1,10 @@ +# etc. settings + +export GUILE_INSTALL_LOCALE=0 +export TZ=America/Chicago + +#export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" +#export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" +#export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" +#export SVDIR="$HOME/.local/service" +#export INFOPATH="$INFOPATH:/usr/share/info" diff --git a/profile/infopath.sh b/profile/infopath.sh new file mode 100644 index 0000000..ad1ec3f --- /dev/null +++ b/profile/infopath.sh @@ -0,0 +1 @@ +export INFOPATH="/usr/share/info:${XDG_DATA_HOME:-$HOME/.local/share}/info" diff --git a/profile/less.sh b/profile/less.sh new file mode 100644 index 0000000..19a73ce --- /dev/null +++ b/profile/less.sh @@ -0,0 +1,3 @@ +# less settings + +export LESS="--mouse --RAW-CONTROL-CHARS" diff --git a/profile/luarocks.sh b/profile/luarocks.sh new file mode 100644 index 0000000..315c0b7 --- /dev/null +++ b/profile/luarocks.sh @@ -0,0 +1,4 @@ +# add luarocks stuff to $PATH + +command -v luarocks >/dev/null 2>&1 && + eval $(luarocks path) diff --git a/profile/manpath.sh b/profile/manpath.sh new file mode 100644 index 0000000..def1963 --- /dev/null +++ b/profile/manpath.sh @@ -0,0 +1,9 @@ +# $MANPATH shouldn't be too extra complicated (as opposed to $PATH), +# so I'm not going to include a whole other function. AT SOME POINT, +# I suppose I should generalize that function to set /any/ path-type +# variable, not just $PATH. +# $MANPATH ends with `:' so that manpath(1) will prepend it to its +# special thing. + +MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man:" +export MANPATH diff --git a/profile/path.sh b/profile/path.sh new file mode 100644 index 0000000..56bdc39 --- /dev/null +++ b/profile/path.sh @@ -0,0 +1,30 @@ +# PATH + +# add a path to PATH, but only if it's not already there +path_add() { # path_add [-a] PATH... + # -a appends (default is prepend) + APPEND=false + if [ "x$1" = "x-a" ]; then + APPEND=true + shift + fi + + for p; do + case ":$PATH:" in + *:"$p":*) ;; + *) + if $APPEND; then + PATH="$PATH:$p" + else + PATH="$p:$PATH" + fi + ;; + esac + done + + unset APPEND +} + +path_add "$HOME/bin" "$HOME/usr/bin" + +command -v luarocks >/dev/null 2>&1 && path_add "$HOME/.luarocks/bin" diff --git a/profile/xdg.sh b/profile/xdg.sh new file mode 100644 index 0000000..caa1a9a --- /dev/null +++ b/profile/xdg.sh @@ -0,0 +1,27 @@ +# XDG compliance (miscellaneous) + +# If an XDG-complaint variable makes more sense somewhere else, it'll be +# moved there (e.g., HISTFILE is in history.bash). So variables might +# move /out/ of this directory, but they probably won't move /in/. + +# Readline +export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc + +# Less +export LESSKEY="$XDG_CONFIG_HOME"/less/lesskey +export LESSHISTFILE="$XDG_CACHE_HOME"/less/history +mkdir -p "$XDG_CACHE_HOME"/less + +# Vim +export VIMINIT="let \$MYVIMRC=\"$XDG_CONFIG_HOME/vim/vimrc\" | source \$MYVIMRC" + +# Weechat +export WEECHAT_HOME="$XDG_CONFIG_HOME/weechat" + +# Lynx +export LYNX_CFG="$XDG_CONFIG_HOME/lynx/lynx.cfg" + +# Xorg +export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" +export XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" +export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" diff --git a/readline/inputrc b/readline/inputrc new file mode 100644 index 0000000..424e7d9 --- /dev/null +++ b/readline/inputrc @@ -0,0 +1,22 @@ +# inputrc + +# Include the system inputrc +$include /etc/inputrc + +# Search based on what I've already typed +"\C-p":history-search-backward +"\C-n":history-search-forward + +# Show completions using LS_COLORS +set colored-stats On +# Ignore case in completions +set completion-ignore-case On +# Show ... if common prefix is longer than 3 characters +set completion-prefix-display-length 3 +# Show symlinked directories with a slash +set mark-symlinked-directories On +# Show completions immediately +set show-all-if-ambiguous On +set show-all-if-unmodified On +# Show types (like ls -F) +set visible-stats On diff --git a/user-dirs.dirs b/user-dirs.dirs new file mode 100644 index 0000000..8c03e11 --- /dev/null +++ b/user-dirs.dirs @@ -0,0 +1,15 @@ +# This file is written by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. +# +XDG_DESKTOP_DIR="$HOME/var/desk" +XDG_DOCUMENTS_DIR="$HOME/var/doc" +XDG_DOWNLOAD_DIR="$HOME/var/download" +XDG_MUSIC_DIR="$HOME/var/music" +XDG_PICTURES_DIR="$HOME/var/img" +XDG_PUBLICSHARE_DIR="$HOME/var/public" +XDG_TEMPLATES_DIR="$HOME/var/tmpl" +XDG_VIDEOS_DIR="$HOME/var/video" -- cgit 1.4.1-21-gabe81