From 8b7223933b8e599186c57638d7c6430234ba8f52 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 09:58:41 +1200 Subject: Remove unnecessary checks from plenv/pyenv/rbenv --- plenv/shrc.d/plenv.sh | 1 - pyenv/shrc.d/pyenv.sh | 1 - rbenv/shrc.d/rbenv.sh | 1 - 3 files changed, 3 deletions(-) diff --git a/plenv/shrc.d/plenv.sh b/plenv/shrc.d/plenv.sh index bb52ffe2..938bcbf6 100644 --- a/plenv/shrc.d/plenv.sh +++ b/plenv/shrc.d/plenv.sh @@ -1,5 +1,4 @@ # POSIX-compatible version of the plenv Bash shell wrapper -[ -d "$HOME"/.plenv ] || return plenv() { case $1 in rehash) diff --git a/pyenv/shrc.d/pyenv.sh b/pyenv/shrc.d/pyenv.sh index 0a946164..60ed8ac7 100644 --- a/pyenv/shrc.d/pyenv.sh +++ b/pyenv/shrc.d/pyenv.sh @@ -1,5 +1,4 @@ # POSIX-compatible version of the pyenv Bash shell wrapper -[ -d "$HOME"/.pyenv ] || return pyenv() { case $1 in rehash) diff --git a/rbenv/shrc.d/rbenv.sh b/rbenv/shrc.d/rbenv.sh index ed9ddd03..14403680 100644 --- a/rbenv/shrc.d/rbenv.sh +++ b/rbenv/shrc.d/rbenv.sh @@ -1,5 +1,4 @@ # POSIX-compatible version of the rbenv Bash shell wrapper -[ -d "$HOME"/.rbenv ] || return rbenv() { case $1 in rehash) -- cgit v1.2.3 From 238b8e7589dac76b805f79b3f5563fbd64d463b4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 09:59:10 +1200 Subject: Remove misleading comment --- sh/shrc.d/pd.sh | 2 -- 1 file changed, 2 deletions(-) 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 -- cgit v1.2.3 From 790231af98bfe3fabf3684eeb1b503e710ef915f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 09:59:22 +1200 Subject: Move x() shortcut to X11 directory and target --- Makefile | 3 ++- check/x.sh | 2 +- lint/x.sh | 2 +- sh/shrc.d/x.sh | 7 ------- x/shrc.d/x.sh | 7 +++++++ 5 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 sh/shrc.d/x.sh create mode 100644 x/shrc.d/x.sh diff --git a/Makefile b/Makefile index f5f24446..9ec536db 100644 --- a/Makefile +++ b/Makefile @@ -678,7 +678,7 @@ install-wget: install-sh mkdir -p -- $(XDG_CACHE_HOME)/wget $(XDG_CONFIG_HOME)/wget cp -p -- wget/wgetrc $(XDG_CONFIG_HOME)/wget/wgetrc -install-x: x/xsession check-x install-logrotate +install-x: x/xsession check-x install-logrotate install-sh mkdir -p -- \ $(HOME)/.xsession.d \ $(HOME)/.Xresources.d \ @@ -688,6 +688,7 @@ install-x: x/xsession check-x install-logrotate cp -p -- x/Xresources $(HOME)/.Xresources cp -p -- x/Xresources.d/* $(HOME)/.Xresources.d cp -p -- x/logrotate/config.d/* $(XDG_CONFIG_HOME)/logrotate/config.d + cp -p -- x/shrc.d/*.sh $(HOME)/.shrc.d install-yt-dlp install-youtube-dl: mkdir -p -- $(XDG_CONFIG_HOME)/yt-dlp diff --git a/check/x.sh b/check/x.sh index d2ec1435..b3ed21ef 100644 --- a/check/x.sh +++ b/check/x.sh @@ -1 +1 @@ -sh -n -- x/xprofile x/xsession +sh -n -- x/xprofile x/xsession x/shrc.d/*.sh diff --git a/lint/x.sh b/lint/x.sh index 070d0567..25fdf58d 100644 --- a/lint/x.sh +++ b/lint/x.sh @@ -1 +1 @@ -shellcheck -e SC1090 -e SC1091 -s sh -- x/xprofile x/xsession +shellcheck -e SC1090 -e SC1091 -s sh -- x/xprofile x/xsession x/shrc.d/*.sh 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 "$@" -} diff --git a/x/shrc.d/x.sh b/x/shrc.d/x.sh new file mode 100644 index 00000000..ed921c68 --- /dev/null +++ b/x/shrc.d/x.sh @@ -0,0 +1,7 @@ +# 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 "$@" +} -- cgit v1.2.3 From 9c3f0f26a74bb77e8ba3522beb0635e24e6549b3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 10:04:03 +1200 Subject: Tidy up comments for POSIX interactive scripts --- sh/shrc.d/rd.sh | 1 + sh/shrc.d/sd.sh | 1 + sh/shrc.d/which.sh | 2 ++ 3 files changed, 4 insertions(+) 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/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`: +# which() { printf >&2 'Whichcraft detected! Did you mean: command -v %s\n' "$*" return 2 -- cgit v1.2.3 From fa7c81108e8fb0c7e0c6c24fb5213956339cd69c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 10:59:25 +1200 Subject: Spruce up X config a bit, remove Thunar daemon Better to let dbus activate it, I think. --- Makefile | 4 ---- parcellite/xsession.d/redshift.sh | 2 +- redshift/xsession.d/redshift.sh | 2 +- sxhkd/xsession.d/sxhkd.sh | 5 ++--- thunar/xsession.d/thunar.sh | 2 -- urxvt/xsession.d/urxvt.sh | 2 +- 6 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 thunar/xsession.d/thunar.sh diff --git a/Makefile b/Makefile index 9ec536db..921e9ed6 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,6 @@ install-sxhkd \ install-systemd \ install-terminfo \ - install-thunar \ install-tidy \ install-tmux \ install-urxvt \ @@ -618,9 +617,6 @@ install-terminfo: tic terminfo/screen.ti tic terminfo/screen-256color.ti -install-thunar: install-x - cp -p -- thunar/xsession.d/* $(HOME)/.xsession.d - install-tidy: install-sh cp -p -- tidy/profile.d/*.sh $(HOME)/.profile.d mkdir -p -- $(XDG_CONFIG_HOME)/tidy diff --git a/parcellite/xsession.d/redshift.sh b/parcellite/xsession.d/redshift.sh index 25241ab3..39fb6c4e 100644 --- a/parcellite/xsession.d/redshift.sh +++ b/parcellite/xsession.d/redshift.sh @@ -1,2 +1,2 @@ -# Start parcellite(1) +# Start X clipboard manager parcellite & diff --git a/redshift/xsession.d/redshift.sh b/redshift/xsession.d/redshift.sh index 929f564e..503877dc 100644 --- a/redshift/xsession.d/redshift.sh +++ b/redshift/xsession.d/redshift.sh @@ -1,2 +1,2 @@ -# Start redshift(1) +# Start X color temperature manager redshift & diff --git a/sxhkd/xsession.d/sxhkd.sh b/sxhkd/xsession.d/sxhkd.sh index d52396c9..ca0e27e3 100644 --- a/sxhkd/xsession.d/sxhkd.sh +++ b/sxhkd/xsession.d/sxhkd.sh @@ -1,3 +1,2 @@ -# Start sxhkd(1) -SXHKD_SHELL=$(command -pv sh) \ - sxhkd & +# Start X hotkey daemon +sxhkd & diff --git a/thunar/xsession.d/thunar.sh b/thunar/xsession.d/thunar.sh deleted file mode 100644 index 9d35a3ce..00000000 --- a/thunar/xsession.d/thunar.sh +++ /dev/null @@ -1,2 +0,0 @@ -# Start Thunar's daemon mode -thunar --daemon & diff --git a/urxvt/xsession.d/urxvt.sh b/urxvt/xsession.d/urxvt.sh index 03b0efd5..766c2939 100644 --- a/urxvt/xsession.d/urxvt.sh +++ b/urxvt/xsession.d/urxvt.sh @@ -1,2 +1,2 @@ -# Run urxvtd(1) in the background +# Start X terminator emulator daemon urxvtd --fork --opendisplay -- cgit v1.2.3 From 055f840d297a7a879c2b75f5024dbaf5aba8c71b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 11:04:28 +1200 Subject: Re-order a couple of PATH variables --- plenv/profile.d/plenv.sh | 4 ++-- pyenv/profile.d/pyenv.sh | 4 ++-- rbenv/profile.d/rbenv.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plenv/profile.d/plenv.sh b/plenv/profile.d/plenv.sh index 36d6289b..5bfc2d24 100644 --- a/plenv/profile.d/plenv.sh +++ b/plenv/profile.d/plenv.sh @@ -1,2 +1,2 @@ -# Add plenv shims and bindir to PATH -PATH=$HOME/.plenv/shims:$HOME/.plenv/bin:$PATH +# Add plenv bindir and shims to PATH +PATH=$HOME/.plenv/bin:$HOME/.plenv/shims:$PATH diff --git a/pyenv/profile.d/pyenv.sh b/pyenv/profile.d/pyenv.sh index 3ad73c68..ea2455fb 100644 --- a/pyenv/profile.d/pyenv.sh +++ b/pyenv/profile.d/pyenv.sh @@ -1,2 +1,2 @@ -# Add pyenv shims and bindir to PATH -PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH +# Add pyenv bindir and shims to PATH +PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH diff --git a/rbenv/profile.d/rbenv.sh b/rbenv/profile.d/rbenv.sh index 522ff247..5295584c 100644 --- a/rbenv/profile.d/rbenv.sh +++ b/rbenv/profile.d/rbenv.sh @@ -1,2 +1,2 @@ -# Add rbenv shims and bindir to PATH -PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH +# Add rbenv bindir and shims to PATH +PATH=$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH -- cgit v1.2.3 From 46c68a119beec1a157682dcf6d4368f382267652 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 11:27:01 +1200 Subject: Remove now-unneeded tmux environment management I suspect these are no longer needed. --- tmux/tmux.conf | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index ca4e7172..e7f088bd 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -1,15 +1,3 @@ -# Strip out a lot of machine and X11 dependent crap from the initial -# environment -set-environment -gru DISPLAY -set-environment -gru SSH_CLIENT -set-environment -gru SSH_CONNECTION -set-environment -gru SSH_TTY -set-environment -gru WINDOWID - -# Otherwise, use the environment we had when we started; don't touch it during -# a session unless I specifically ask -set-option -g update-environment 'COLORFGBG COLORTERM' - # Setting this makes each new pane a non-login shell, which suits me better set-option -g default-command "exec $SHELL" -- cgit v1.2.3 From f7bff15bee0ef4ec3180474e5ddbe266ec90753d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 30 Jul 2022 00:53:17 +1200 Subject: Use long GDB option --- sh/shrc.d/gdb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 "$@" } -- cgit v1.2.3 From 092ec85c19f3c7809df522f58004a87dbec476d3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 4 Aug 2022 13:57:28 +1200 Subject: Support SSH many-Host lines and config subfiles --- README.md | 2 +- bash/bash_completion.d/_ssh_config_hosts.bash | 29 ++++++++++++++++----------- bin/sls.sh | 3 ++- bin/slsf.awk | 29 ++++++++++++++++++++++----- man/man1/sls.1df | 8 ++++---- man/man1/slsf.1df | 8 ++++---- man/man7/dotfiles.7df | 4 ++-- vim/filetype.vim | 15 +++++++++----- 8 files changed, 64 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index d8156671..e59cb5e0 100644 --- a/README.md +++ b/README.md @@ -417,7 +417,7 @@ interactive shells. These scripts are installed by the `install-bin` target: - Three SSH-related scripts: - - `sls(1df)` prints hostnames read from a `ssh_config(5)` file. It uses + - `sls(1df)` prints hostnames read from `ssh_config(5)` files. It uses `slsf(1df)` to read each one. - `sra(1df)` runs a command on multiple hosts read from `sls(1df)` and prints output. diff --git a/bash/bash_completion.d/_ssh_config_hosts.bash b/bash/bash_completion.d/_ssh_config_hosts.bash index 0959f52b..16265e8a 100644 --- a/bash/bash_completion.d/_ssh_config_hosts.bash +++ b/bash/bash_completion.d/_ssh_config_hosts.bash @@ -3,23 +3,28 @@ _ssh_config_hosts() { # Iterate through SSH client config paths local config - for config in "$HOME"/.ssh/config /etc/ssh/ssh_config ; do + for config in /etc/ssh/ssh_config.d/*.conf /etc/ssh/ssh_config \ + "$HOME"/.ssh/config.d/*.conf "$HOME"/.ssh/config ; do [[ -e $config ]] || continue - # Read 'Host' options and their first value from file - local option value ci - while read -r option value _ ; do + # Read 'Host' options and their patterns from file + local option value patterns pattern ci + while read -r option value ; do [[ $option == Host ]] || continue + read -a patterns -r \ + < <(printf '%s\n' "$value") # Check host value - case $value in - # No empties - '') ;; - # No wildcards - *'*'*) ;; - # Found a match; print it - "$2"*) COMPREPLY[ci++]=$value ;; - esac + for pattern in "${patterns[@]}" ; do + case $pattern in + # No empties + '') ;; + # No wildcards + *'*'*) ;; + # Found a match; print it + "$2"*) COMPREPLY[ci++]=$pattern ;; + esac + done done < "$config" done diff --git a/bin/sls.sh b/bin/sls.sh index 55c1dfc7..9741144a 100644 --- a/bin/sls.sh +++ b/bin/sls.sh @@ -3,7 +3,8 @@ # If we weren't given a file explicitly, we'll try to read both /etc/ssh_config # and ~/.ssh_config in that order if they exist if [ "$#" -eq 0 ] ; then - for cfg in /etc/ssh_config "$HOME"/.ssh/config ; do + for cfg in /etc/ssh_config.d/*.conf /etc/ssh_config \ + "$HOME"/.ssh/config.d/*.conf "$HOME"/.ssh/config ; do [ -e "$cfg" ] || continue set -- "$@" "$cfg" done diff --git a/bin/slsf.awk b/bin/slsf.awk index 3d5c190f..87127a2c 100644 --- a/bin/slsf.awk +++ b/bin/slsf.awk @@ -1,9 +1,28 @@ -# Print the first non-glob "Host" name from each line of ssh_config(5) files +# Print all the hosts from ssh_config(1) files # Manage the processing flag (starts set in each file) -FNR == 1 || /### sls/ { sls = 1 } +BEGIN { sls = 1 } +FNR { sls = 1 } +/### sls/ { sls = 1 } /### nosls/ { sls = 0 } -# If processing flag set, directive is "Host", and hostname has no wildcards, -# then print it -sls && $1 == "Host" && $2 !~ /\*/ { print $2 } +# Skip if we're ignoring hosts +!sls { next } +# Skip if this isn't a host line +$1 != "Host" { next } + +# Add all the patterns after the keyword that don't have wildcards +{ + for (i = 2; i <= NF; i++) { + if ($i !~ /[?*]/) { + hosts[$i]++ + } + } +} + +# Print the complete list of hosts, sorted +END { + for (host in hosts) { + print host | "sort" + } +} diff --git a/man/man1/sls.1df b/man/man1/sls.1df index 83c13201..dde8e622 100644 --- a/man/man1/sls.1df +++ b/man/man1/sls.1df @@ -1,4 +1,4 @@ -.TH SLS 1df "May 2014" "Manual page for sls" +.TH SLS 1df "August 2022" "Manual page for sls" .SH NAME .B sls \- list the first hostname on each line of an ssh_config(5) file @@ -10,9 +10,9 @@ ssh_config_alt1 ssh_config_alt2 .SH DESCRIPTION .B sls runs slsf(1df) on the given set of ssh_config(5) files to print the first -non-wildcard hostname on each "Host" line, defaulting to /etc/ssh/ssh_config -and ~/.ssh/config if they exist. Suitable for use in batch scripts like -sra(1df). +non-wildcard hostname on each "Host" line, defaulting to +/etc/ssh/ssh_config.d/*.conf, /etc/ssh/ssh_config, ~/.ssh/config.d/*.conf, and +~/.ssh/config if they exist. Suitable for use in batch scripts like sra(1df). .SH SEE ALSO slsf(1df), sra(1df), sta(1df), ssh(1), ssh_config(5) .SH AUTHOR diff --git a/man/man1/slsf.1df b/man/man1/slsf.1df index 31453dca..6d59ba3d 100644 --- a/man/man1/slsf.1df +++ b/man/man1/slsf.1df @@ -1,4 +1,4 @@ -.TH SLSF 1df "July 2016" "Manual page for slsf" +.TH SLSF 1df "August 2022" "Manual page for slsf" .SH NAME .B slsf \- list the first hostname on each line of ssh_config(5) files @@ -10,9 +10,9 @@ cat ~/.ssh_config | .br .SH DESCRIPTION .B slsf -iterates through the ssh_config(5) files given as its input and prints the -first name given on each "Host" line, as long as it contains no wildcards. -Most users will probably want the sls(1df) frontend. +iterates through the ssh_config(5) files given as its input and prints a unique +list of the patterns given on each "Host" line containing no wildcards. Most +users will probably want the sls(1df) frontend instead. .P Within the file, a comment "### nosls" on its own line will exclude all following output unless an "### sls" comment is read to resume it again: diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index 8c766c05..cae361a2 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -573,8 +573,8 @@ These scripts are installed by the \f[C]install-bin\f[R] target: Three SSH-related scripts: .RS 2 .IP \[bu] 2 -\f[C]sls(1df)\f[R] prints hostnames read from a \f[C]ssh_config(5)\f[R] -file. +\f[C]sls(1df)\f[R] prints hostnames read from \f[C]ssh_config(5)\f[R] +files. It uses \f[C]slsf(1df)\f[R] to read each one. .IP \[bu] 2 \f[C]sra(1df)\f[R] runs a command on multiple hosts read from diff --git a/vim/filetype.vim b/vim/filetype.vim index 01cc0f3a..c616babd 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -434,18 +434,23 @@ augroup filetypedetect \ ?*.sql \ setfiletype sql " OpenSSH configuration + "" client autocmd BufNewFile,BufRead - \ ssh_config,*/.ssh/config + \ ssh_config + \,*/ssh_config.d/*.conf + \,*/.ssh/config, + \,*/.ssh/config.d/*.conf \ setfiletype sshconfig + "" server + autocmd BufNewFile,BufRead + \ sshd_config + \,*/sshd_config.d/*.conf + \ setfiletype sshdconfig " sudoers(5) autocmd BufNewFile,BufRead \ sudoers \,sudoers.tmp \ setfiletype sudoers - " OpenSSH server configuration - autocmd BufNewFile,BufRead - \ sshd_config - \ setfiletype sshdconfig " Subversion commit autocmd BufNewFile,BufRead \ svn-commit*.tmp -- cgit v1.2.3 From a9a37cdf7789c169ed814668d61be262d8df7085 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 4 Aug 2022 13:57:51 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index d3aad803..5968a541 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v12.14.0 -Thu, 28 Jul 2022 21:16:58 +0000 +tejr dotfiles v12.15.0 +Thu, 04 Aug 2022 01:57:51 +0000 -- cgit v1.2.3