commit dcf7b494a3bbef426fff27ec69aadb9f333516ae Author: Jordan Bancino Date: Sat Jan 6 09:08:11 2024 -0500 Initial Alpine Linux Dotfiles. After having jumped from Arch to OpenBSD to FreeBSD, now I'm back on Linux and have chosen Alpine. I want to clean up all the cruft that has accumulated over the years. Many programs that were in my dotfiles I no longer use. So, these dotfiles are a drastically simplified view of my old dotfiles, which I have created so I can start fresh. The .profile and .ashrc are meant to be entirely POSIX, so they should work on any shell. diff --git a/.aliases b/.aliases new file mode 100644 index 0000000..3f0e7ca --- /dev/null +++ b/.aliases @@ -0,0 +1,14 @@ +alias cp='cp -v' +alias mv='mv -v' +alias rm='rm -v' +alias ls='ls -lhF' + +alias exit='clear; exit' + +alias arsync="rsync --delete -av" +alias tmux="tmux -2" +alias vi="vim" + +calc() { + perl -e "print($*);" +} diff --git a/.ashrc b/.ashrc new file mode 100644 index 0000000..da00576 --- /dev/null +++ b/.ashrc @@ -0,0 +1,245 @@ +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +is_ssh() { + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] || [ -n "$SSH_TTY" ]; then + return 0 + else + return 1 + fi +} + +# Signal to some programs that vi is the editor that should be launched. +export EDITOR=vim + +# Set shell keybindings to vi +set -o vi + +# +# The dotfile directory; used by sd() +# +export DOTDIR="$HOME/Dotfiles" + +# +# Local user software. Add software to the software directory +# and its bin directory will be automatically loaded when a shell +# is launched. +# +SOFTWARE="$HOME/Software" + +# Add some extra directories to the PATH +PATH="$HOME/bin:$PATH" +export PATH HOME TERM + +# Store the original path because if scansoft is called, it rebuilds +# the path, starting with the original path. +PATH_BAK="$PATH" + +available() { + type $1 > /dev/null 2>&1 + return $? +} + +scansoft() { + PATH="$PATH_BAK" + if [ ! -d "$SOFTWARE" ]; then + mkdir -p "$SOFTWARE" + else + # Sort -n to sort entries numerically (to allow precedence) + for D in `find "$SOFTWARE" -maxdepth 1 -type d | sort -n`; do + if [ -d "$D/bin" ]; then + echo "Include '$(basename $D)'" + export PATH="$D/bin:$PATH" + fi + done + fi +} + +ensoft() { + if [ -z "$1" ]; then + echo "Usage: ensoft " + return + fi + if [ -d "$SOFTWARE/$1" ]; then + if [ -d "$SOFTWARE/$1/_bin" ]; then + echo "Enabling '$1'..." + mv "$SOFTWARE/$1/_bin" "$SOFTWARE/$1/bin" + echo "Enabled. Run 'scansoft' to apply changes." + elif [ -d "$SOFTWARE/$1/bin" ]; then + echo "Already enabled." + else + echo "'$1' exists, but is not a software directory." + fi + else + echo "'$1' does not exist in the software directory." + fi +} + +disoft() { + if [ -z "$1" ]; then + echo "Usage: disoft " + return + fi + if [ -d "$SOFTWARE/$1" ]; then + if [ -d "$SOFTWARE/$1/bin" ]; then + echo "Disabling '$1'..." + mv "$SOFTWARE/$1/bin" "$SOFTWARE/$1/_bin" + echo "Disabled. Run 'scansoft' to apply changes." + elif [ -d "$SOFTWARE/$1/_bin" ]; then + echo "Already disabled." + else + echo "'$1' exists, but is not a software directory." + fi + else + echo "'$1' does not exist in the software directory." + fi +} + +mod_time() { + if [ -n "$1" ] && [ -f "$1" ]; then + case "$(uname)" in + Linux) stat -c %Y "$1";; + *BSD) stat -f %m "$1";; + *) echo "0";; # Force compilation every time. + esac + else + echo "0" + fi +} + +# +# Dotfile Syncing - If changes are made to any of my dotfiles in git, they're +# synced to the home directory. +# + +sd() { + if [ -z "$DOTDIR" ]; then + echo "sd: No dotfile directory specified. Please define \$DOTDIR." + return 1 + fi + + if [ ! -d "$DOTDIR" ]; then + echo "sd: The dotfile directory '$DOTDIR' does not exist." + return 1 + fi + + find "$DOTDIR" -type f -not -path "$DOTDIR/.git/*" \ + -not -name '*.md' -not -name '*.swp' \ + -not -path '*CVS*' -not -name '.#*' \ + | while IFS= read -r listing; do + local="$HOME/$(echo "$listing" | sed "s|$DOTDIR/||g")" + docopy=0 + if [ -f "$local" ]; then + diff -N "$listing" "$local" > /dev/null + docopy=$? + else + docopy=1 + fi + if [ $docopy -eq 1 ]; then + localmtime=$(mod_time "$local" 2> /dev/null) + if [ -z "$localmtime" ]; then + localmtime=0 + fi + listingmtime=$(mod_time "$listing" 2> /dev/null) + if [ -z "$listingmtime" ]; then + listingmtime=0 + fi + if [ $listingmtime -gt $localmtime ]; then + dir=$(dirname "$local") + if [ ! -d "$dir" ]; then + mkdir -p "$dir" + echo "Created directory '$dir'." + fi + cp -v "$listing" "$local" + else + cp -v "$local" "$listing" + fi + fi + done +} + +# +# Shell Prompt +# + +# ANSI Colors - Used for Prompt +ANSI_RESET="\[\033[0m\]" # reset +ANSI_HICOLOR="\[\033[1m\]" # hicolor +ANSI_UNDERLINE="\[\033[4m\]" # underline +ANSI_INVERT="\[\033[7m\]" # inverse background and foreground +ANSI_BLACK="\[\033[30m\]" # foreground black +ANSI_RED="\[\033[31m\]" # foreground red +ANSI_GREEN="\[\033[32m\]" # foreground green +ANSI_YELLOW="\[\033[33m\]" # foreground yellow +ANSI_BLUE="\[\033[34m\]" # foreground blue +ANSI_MAGENTA="\[\033[35m\]" # foreground magenta +ANSI_CYAN="\[\033[36m\]" # foreground cyan +ANSI_FWHT="\[\033[37m\]" # foreground white +ANSI_WHITE="\[\033[40m\]" # background black +ANSI_BG_RED="\[\033[41m\]" # background red +ANSI_BG_GREEN="\[\033[42m\]" # background green +ANSI_BG_YELLOW="\[\033[43m\]" # background yellow +ANSI_BG_BLUE="\[\033[44m\]" # background blue +ANSI_BG_MAGENTA="\[\033[45m\]" # background magenta +ANSI_BG_CYAN="\[\033[46m\]" # background cyan +ANSI_BG_WHITE="\[\033[47m\]" # background white + +trim() { + awk '{print $1}' +} + +generate_prompt() { + LAST_EXIT=$? + + printf "\n%s" "$ANSI_HICOLOR" + printf "%s " "$(date '+%Y-%m-%d %H:%M')" + + if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = "true" ]; then + printf ' %s(%s)' "$ANSI_YELLOW" "$(git rev-parse --abbrev-ref HEAD)" + fi + + printf "%s\n" "$ANSI_RESET" + + printf "%s" "$ANSI_GREEN" + printf "%s" "$USER" + printf "%s" "$ANSI_RESET" + + printf "@" + + printf "%s" "$ANSI_GREEN" + printf "%s" "$(hostname -s)" + printf "%s" "$ANSI_RESET" + + printf ":" + printf "%s" "$ANSI_HICOLOR" + + DIR=$(echo $PWD | sed "s|$HOME|~|g") + + printf "%s" "$DIR" + + printf "%s\n" "$ANSI_RESET" + + if [ "$LAST_EXIT" != "0" ]; then + printf "%s(%s)%s " "$ANSI_RED" "$LAST_EXIT" "$ANSI_RESET" + fi + + if [ "$(whoami)" = "root" ]; then + printf "# " + else + printf "$ " + fi +} + +PS1="\$(generate_prompt)" + +# +# Startup functions - these are executed on every shell start. +# + +# Run scansoft on shell start +scansoft + +if [ -f "$HOME/.aliases" ]; then + . "$HOME/.aliases" +fi + diff --git a/.exrc b/.exrc new file mode 100644 index 0000000..7aa4010 --- /dev/null +++ b/.exrc @@ -0,0 +1,8 @@ +set autoindent +set number +set ruler +set tabstop=4 +set shiftwidth=4 +set showmatch +set exrc + diff --git a/.profile b/.profile new file mode 100644 index 0000000..21de478 --- /dev/null +++ b/.profile @@ -0,0 +1 @@ +export ENV="$HOME/.ashrc" diff --git a/.sqliterc b/.sqliterc new file mode 100644 index 0000000..80e12b9 --- /dev/null +++ b/.sqliterc @@ -0,0 +1,2 @@ +.headers ON +.mode columns diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..1ba9667 --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,2 @@ +set-option -g pane-border-lines simple +set -g default-terminal "screen-256color"