diff options
Diffstat (limited to 'sh/shrc.d')
-rw-r--r-- | sh/shrc.d/ed.sh | 2 | ||||
-rw-r--r-- | sh/shrc.d/gdb.sh | 2 | ||||
-rw-r--r-- | sh/shrc.d/ls.sh | 14 | ||||
-rw-r--r-- | sh/shrc.d/path.sh | 8 | ||||
-rw-r--r-- | sh/shrc.d/pd.sh | 2 | ||||
-rw-r--r-- | sh/shrc.d/prompt.sh | 7 | ||||
-rw-r--r-- | sh/shrc.d/rd.sh | 1 | ||||
-rw-r--r-- | sh/shrc.d/sd.sh | 1 | ||||
-rw-r--r-- | sh/shrc.d/tor.sh | 33 | ||||
-rw-r--r-- | sh/shrc.d/which.sh | 2 | ||||
-rw-r--r-- | sh/shrc.d/x.sh | 7 |
11 files changed, 51 insertions, 28 deletions
diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh index dc8433f6..0591e18d 100644 --- a/sh/shrc.d/ed.sh +++ b/sh/shrc.d/ed.sh @@ -22,7 +22,7 @@ ed() { # Run in rlwrap(1) if available set -- ed "$@" if command -v rlwrap >/dev/null 2>&1 ; then - set -- rlwrap --history-filename=/dev/null "$@" + set -- rlwrap --history-filename=/dev/null --no-warnings "$@" fi # Run determined command diff --git a/sh/shrc.d/gdb.sh b/sh/shrc.d/gdb.sh index ec9d4137..4fb459cb 100644 --- a/sh/shrc.d/gdb.sh +++ b/sh/shrc.d/gdb.sh @@ -1,4 +1,4 @@ # Don't print the GDB copyright message on every invocation gdb() { - command gdb -q "$@" + command gdb --quiet "$@" } diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 203a734f..6fbfbf61 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -31,22 +31,16 @@ ls() { [ "$(exec 2>/dev/null;tput colors||tput Co||echo 0)" -ge 8 ] ; then set -- --color=auto "$@" fi + ## Force the new entry quoting off + if [ -e "$HOME"/.cache/sh/opt/ls/quoting-style ] ; then + set -- --quoting-style=literal "$@" + fi ## Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred ## (fixed) format if [ -e "$HOME"/.cache/sh/opt/ls/time-style ] ; then set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" fi - # If the operating system is FreeBSD, there are some specific options we - # can add that might mean different things to e.g. GNU ls(1) - case $OS in - FreeBSD) - # -D: Timestamp format - # -G: Use color - set -- -D '%Y-%m-%d %H:%M:%S' -G "$@" - ;; - esac - # Run ls(1) with the concluded arguments command ls "$@" } diff --git a/sh/shrc.d/path.sh b/sh/shrc.d/path.sh index a854e148..812f5f0f 100644 --- a/sh/shrc.d/path.sh +++ b/sh/shrc.d/path.sh @@ -130,7 +130,7 @@ path(): Manage contents of PATH variable USAGE: path [list] - Print the current directories in PATH, one per line (default command) + Print the current directories in PATH, one per line (default) path insert [DIR] Add directory DIR (default $PWD) to the front of PATH path append [DIR] @@ -142,7 +142,7 @@ USAGE: path pop Remove the last directory from PATH path check [DIR] - Return whether directory DIR (default $PWD) is a component of PATH + Return whether directory DIR (default $PWD) is in PATH path help Print this help message EOF @@ -150,7 +150,9 @@ EOF # Command not found *) - printf >&2 'path(): %s: Unknown command (try "help")\n' "$1" + printf >&2 \ + 'path(): %s: Unknown command (try "help")\n' \ + "$1" return 2 ;; esac diff --git a/sh/shrc.d/pd.sh b/sh/shrc.d/pd.sh index 77f6bae9..e99049d3 100644 --- a/sh/shrc.d/pd.sh +++ b/sh/shrc.d/pd.sh @@ -2,8 +2,6 @@ # use when you've got a file path in a variable, or in history, or in Alt+., # and want to quickly move to its containing directory. In the absence of an # argument, this just shifts up a directory, i.e. `cd ..` -# -# Note this is equivalent to `ud 1`. pd() { # Check arguments; default to $PWD diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh index cb32c113..72cf59b6 100644 --- a/sh/shrc.d/prompt.sh +++ b/sh/shrc.d/prompt.sh @@ -11,8 +11,7 @@ PS3='? ' unset PS4 PS4='+ ' -# If we have an SSH_CLIENT or SSH_CONNECTION environment variable, put the -# hostname in PS1 too. -if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] ; then - PS1=$(hostname -s)'$ ' +# Prompt has hostname via SSH outside of screen/tmux +if [ -n "$SSH_CLIENT" ] && [ -z "$STY" ] && [ -z "$TMUX" ] ; then + PS1=$(hostname -s)$PS1 fi diff --git a/sh/shrc.d/rd.sh b/sh/shrc.d/rd.sh index e6d761a6..3e1b4d9c 100644 --- a/sh/shrc.d/rd.sh +++ b/sh/shrc.d/rd.sh @@ -11,6 +11,7 @@ # $ rd usr opt # $ pwd # /opt/bin +# rd() { # Check argument count diff --git a/sh/shrc.d/sd.sh b/sh/shrc.d/sd.sh index 10597832..1fe748c4 100644 --- a/sh/shrc.d/sd.sh +++ b/sh/shrc.d/sd.sh @@ -30,6 +30,7 @@ # /tmp/tmp.ZSunna5Eup/a # # Seems to work for symbolic links. +# sd() { # Check argument count diff --git a/sh/shrc.d/tor.sh b/sh/shrc.d/tor.sh new file mode 100644 index 00000000..e6e31341 --- /dev/null +++ b/sh/shrc.d/tor.sh @@ -0,0 +1,33 @@ +# Manage Torsocks for the current shell +tor() { + + # Check first argument to figure out operation + case $1 in + + # Show whether Torsocks + show|'') + case $LD_PRELOAD: in + (*/libtorsocks.so:*) + printf 'on\n' + ;; + (*) + printf 'off\n' + ;; + esac + ;; + + # Turn Torsocks on or off + on|off) + command -v torsocks >/dev/null 2>&1 || return + . "$(command -v torsocks)" + ;; + + # Command not found + *) + printf >&2 \ + 'tor(): %s: Unknown command (try "help")\n' \ + "$1" + return 2 + ;; + esac +} diff --git a/sh/shrc.d/which.sh b/sh/shrc.d/which.sh index 9d8c899a..528e5048 100644 --- a/sh/shrc.d/which.sh +++ b/sh/shrc.d/which.sh @@ -1,3 +1,5 @@ +# Try to stop me using the non-standard `which`: +# <http://mywiki.wooledge.org/BadUtils#which> which() { printf >&2 'Whichcraft detected! Did you mean: command -v %s\n' "$*" return 2 diff --git a/sh/shrc.d/x.sh b/sh/shrc.d/x.sh deleted file mode 100644 index ed921c68..00000000 --- a/sh/shrc.d/x.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Most systems won't have X, so we'll only define this if we have startx(1) -command -v startx >/dev/null 2>&1 || return - -# Quick one-key command to launch an X session -x() { - exec startx "$@" -} |