shell: update shrc to be POSIX sh compatible
This commit is contained in:
parent
a583e4e60d
commit
36015b8d4c
1 changed files with 23 additions and 12 deletions
|
@ -1,12 +1,15 @@
|
||||||
# Blakely's basic shell setup file
|
#!/bin/sh
|
||||||
|
# Blakely's basic shell configuration file
|
||||||
|
|
||||||
# This file is compatible with basic `sh`, and can
|
# This file is compatible with basic `sh`, and can
|
||||||
# be sourced in all `sh`-compatible shells to get
|
# be sourced in all `sh`-compatible shells to get
|
||||||
# the basic parts of the local `sh` configuration.
|
# the basic parts of the local `sh` configuration.
|
||||||
|
|
||||||
### Pre-setup >>>
|
# This file doesn't need a shebang at the top, but it has one
|
||||||
# shellcheck disable=SC1090,SC2296,SC1091,SC2154,SC2015
|
# so shellcheck knows this file has to be compatible with POSIX sh
|
||||||
|
|
||||||
|
### Pre-setup >>>
|
||||||
|
# shellcheck disable=SC1090
|
||||||
# Helper function to source files.
|
# Helper function to source files.
|
||||||
# Usage:
|
# Usage:
|
||||||
# careful_source "file" \
|
# careful_source "file" \
|
||||||
|
@ -19,7 +22,7 @@ careful_source() {
|
||||||
${5:-source} "$1"
|
${5:-source} "$1"
|
||||||
else
|
else
|
||||||
if test -n "${2+foo}"; then
|
if test -n "${2+foo}"; then
|
||||||
echo -e "$2" >&2
|
printf "%s\n" "$2" >&2
|
||||||
echo "Line number: $3" >&2
|
echo "Line number: $3" >&2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -33,7 +36,7 @@ error() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# change cursor to a beam by default
|
# change cursor to a beam by default
|
||||||
echo -ne '\e[5 q'
|
printf '\e[5 q'
|
||||||
|
|
||||||
### <<<
|
### <<<
|
||||||
### Generic shell configuration >>>
|
### Generic shell configuration >>>
|
||||||
|
@ -58,18 +61,19 @@ ${SKIP_LOCAL_ALIASES:-false} || careful_source "$SHELL_CONFIG_DIR/local/aliases"
|
||||||
|
|
||||||
# <<<
|
# <<<
|
||||||
### Functions >>>
|
### Functions >>>
|
||||||
# Organization: functions that are really short should be put here, otherwise
|
# Organization: functions should be put in their own files, located in
|
||||||
# they should be put in a file located in $SHELL_CONFIG_DIR/functions. If they
|
# $SHELL_CONFIG_DIR/functions. If they can be converted into a script, they
|
||||||
# can be converted into a script, they should be.
|
# should be.
|
||||||
#
|
#
|
||||||
# To make a "function in a file" that fits with my personal spec, simply make a
|
# To make a "function in a file" that fits with my personal spec, simply make a
|
||||||
# file, name it what the function is called, and put the function inside of it
|
# file, name it what the function is called, and put the function inside of it
|
||||||
# just like you would if you were writing it here.
|
# just like you would if you were writing it here. Make sure to describe what
|
||||||
|
# the function does at the top, and say what dependencies it has (if any).
|
||||||
|
|
||||||
# load all functions that are stored in files
|
# Function to load all functions that are stored in files
|
||||||
fnupdate() {
|
fnupdate() {
|
||||||
for FN in "$SHELL_CONFIG_DIR"/functions/*;do
|
for FN in "$SHELL_CONFIG_DIR"/functions/*;do
|
||||||
source "$FN"
|
. "$FN"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
${SKIP_FUNCTIONS:-false} || fnupdate
|
${SKIP_FUNCTIONS:-false} || fnupdate
|
||||||
|
@ -77,13 +81,20 @@ ${SKIP_FUNCTIONS:-false} || fnupdate
|
||||||
# <<<
|
# <<<
|
||||||
### Options >>>
|
### Options >>>
|
||||||
set -o vi
|
set -o vi
|
||||||
|
|
||||||
# <<<
|
# <<<
|
||||||
|
|
||||||
|
# <<<
|
||||||
|
### Load the local shrc >>>
|
||||||
|
${SKIP_LOCAL_ENV:-false} || careful_source "$SHELL_CONFIG_DIR/local/shrc" \
|
||||||
|
|
||||||
# <<<
|
# <<<
|
||||||
### Apply breaking changes with the update script >>>
|
### Apply breaking changes with the update script >>>
|
||||||
${SKIP_UPDATES:-false} || careful_source "$SHELL_CONFIG_DIR/updates" \
|
${SKIP_UPDATES:-false} || careful_source "$SHELL_CONFIG_DIR/updates" \
|
||||||
"Error: failed to run update script" $LINENO -x "command"
|
"Error: failed to run update script" $LINENO -x "command"
|
||||||
|
|
||||||
### <<<
|
### <<<
|
||||||
# terminal colorscheme
|
# terminal colorscheme
|
||||||
careful_source "$SHELL_CONFIG_DIR/colors.sh"
|
careful_source "$SHELL_CONFIG_DIR/colors.sh"
|
||||||
|
|
||||||
# vim:fdm=marker:fmr=>>>,<<<:et:ft=bash:sw=3:ts=3
|
# vim:fdm=marker:fmr=>>>,<<<:et:ft=sh:sw=3:ts=3
|
||||||
|
|
Loading…
Add table
Reference in a new issue