diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-03-19 11:32:07 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2021-08-14 11:59:34 +0200 |
commit | c2e51bc0d1b14fcd5d8b29cf3c87d8f18666231f (patch) | |
tree | bc556a8b12561d223af1a3135e384c1c819bc6f3 | |
parent | d67fee9a0bb6f907533d5d3c7e573c34cdb21bef (diff) |
Add possible terminal with no history reference
-rw-r--r-- | .config/shell/env | 17 | ||||
-rw-r--r-- | .config/sxhkd/sxhkdrc | 5 | ||||
-rwxr-xr-x | .local/bin/term | 82 |
3 files changed, 100 insertions, 4 deletions
diff --git a/.config/shell/env b/.config/shell/env index b04d6b9..0edfb6a 100644 --- a/.config/shell/env +++ b/.config/shell/env @@ -15,9 +15,20 @@ export ALTERNATE_EDITOR="ed" export WWW_HOME=https://duckduckgo.com/ # set history -export HISTFILE=~/.local/var/shell/histfile && mkdir -p -- "$(dirname "${HISTFILE}")" -export HISTSIZE=10000 -export SAVEHIST=10000 +if [ -z "$TERM_NO_HISTORY" ] +then + [ "$SHELL_DEBUG" ] && printf "Setting shell history" + + export HISTFILE=~/.local/var/shell/histfile && mkdir -p -- "$(dirname "$HISTFILE")" + export HISTSIZE=10000 + export SAVEHIST=10000 +else + [ "$SHELL_DEBUG" ] && printf "Unsetting shell history" + + unset HISTFILE + unset HISTSIZE + unset SAVEHIST +fi # set dmenu rice export DMENU_OPTS='-i -fn "Liberation Mono:pixelsize=13" -nb "#000" -nf "#fff" -sb "#4c679a" -l 15 -dim 0.5 -o 0.9' diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 6af774f..a4b565a 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -1,6 +1,9 @@ # spawn applications super + Return - termite + term + +super + alt + Return + term -c super + e dmenu_run diff --git a/.local/bin/term b/.local/bin/term new file mode 100755 index 0000000..aabea8e --- /dev/null +++ b/.local/bin/term @@ -0,0 +1,82 @@ +#!/bin/sh + +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU Affero General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. + +# A list of possible terminal emulators, sorted by preference +TERMINALS=" + termite + st + urxvt + rxvt + xterm +" + +main() +{ + # Handle opts + while getopts ":hc" opt + do + case "$opt" in + c) OPT_NO_HIST=1 ;; + h) usage && exit 0 ;; + *) + printf "Invalid option passed: %s\n" "$OPTARG" >&2 + ;; + esac + done + + shift $(( OPTIND - 1 )) + + # Unset history related environment variables if requested + if [ "$OPT_NO_HIST" ] + then + unset HISTFILE + unset HISTSIZE + unset SAVEHIST + + export TERM_NO_HISTORY=1 + fi + + # Check the list of possible terminal emulators, and exec the first one + # that's available + for terminal in $TERMINALS + do + command -v "$terminal" > /dev/null || continue + + exec "$terminal" "$@" + done + + # No usable terminal found, print error + printf "No suitable terminal emulator found. The following were tried:\n" + + for terminal in $TERMINALS + do + printf "\t%s\n" "$terminal" + done + + exit 127 +} + +usage() +{ + cat <<EOF +Usage: + ${0##*/} -h + +Nondescript + +Options: + -h Show this help text and exit. + -c Unset HISTFILE before starting the terminal. +EOF +} + +main "$@" |