diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-02-25 01:20:56 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-02-25 01:20:56 +1300 |
commit | 7589660a8ebe4cf29cb07a415e07672a7e1e66fa (patch) | |
tree | d5f17010cfdfdb0ba4c1a1a97d017957d2f108e2 | |
parent | Merge branch 'master' into port/bsd/freebsd (diff) | |
parent | Add basic ex/vi settings (diff) | |
download | dotfiles-7589660a8ebe4cf29cb07a415e07672a7e1e66fa.tar.gz dotfiles-7589660a8ebe4cf29cb07a415e07672a7e1e66fa.zip |
Merge branch 'master' into port/bsd/freebsd
32 files changed, 390 insertions, 150 deletions
diff --git a/ISSUES.markdown b/ISSUES.markdown index 383d7906..42e1524e 100644 --- a/ISSUES.markdown +++ b/ISSUES.markdown @@ -18,3 +18,8 @@ Known issues * I can't find a clean way of detecting a restricted shell for ksh instances to prevent trying to load anything fancy (works for Bash) * Zsh, either! $options[restricted] is "off" within the startup file +* Git completion for "add" is error-prone; probably best just to let it add + plain files +* Would be good to complete the Makefile variables for NAME, EMAIL etc with + educated guesses (`id -u`@`cat /etc/mailname`) etc rather than hardcoding + my own stuff in there @@ -10,6 +10,7 @@ install-curl \ install-dotfiles-man \ install-dunst \ + install-ex \ install-finger \ install-games \ install-games-man \ @@ -165,6 +166,7 @@ install : install-bash \ install-bash-completion \ install-bin \ install-curl \ + install-ex \ install-git \ install-gnupg \ install-less \ @@ -173,143 +175,146 @@ install : install-bash \ install-vim install-abook : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.abook - install -pm 0644 -- abook/abookrc "$(HOME)"/.abook + cp -p -- abook/abookrc "$(HOME)"/.abook install-bash : check-bash install-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config \ "$(HOME)"/.bashrc.d - install -pm 0644 -- bash/bashrc "$(HOME)"/.bashrc - install -pm 0644 -- bash/bashrc.d/* "$(HOME)"/.bashrc.d - install -pm 0644 -- bash/bash_profile "$(HOME)"/.bash_profile - install -pm 0644 -- bash/bash_logout "$(HOME)"/.bash_logout + cp -p -- bash/bashrc "$(HOME)"/.bashrc + cp -p -- bash/bashrc.d/* "$(HOME)"/.bashrc.d + cp -p -- bash/bash_profile "$(HOME)"/.bash_profile + cp -p -- bash/bash_logout "$(HOME)"/.bash_logout install-bash-completion : install-bash - install -m 0755 -d -- "$(HOME)"/.bash_completion.d - install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion - install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d + mkdir -p -- "$(HOME)"/.bash_completion.d + cp -p -- bash/bash_completion "$(HOME)"/.config/bash_completion + cp -p -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d install-bin : $(BINS) install-bin-man - install -m 0755 -d -- "$(HOME)"/.local/bin + mkdir -p -- "$(HOME)"/.local/bin for name in bin/* ; do \ [ -x "$$name" ] || continue ; \ - install -m 0755 -- "$$name" "$(HOME)"/.local/bin ; \ + cp -p -- "$$name" "$(HOME)"/.local/bin ; \ done install-bin-man : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.local/share/man/man1 \ "$(HOME)"/.local/share/man/man8 - install -pm 0644 -- man/man1/*.1df "$(HOME)"/.local/share/man/man1 - install -pm 0644 -- man/man8/*.8df "$(HOME)"/.local/share/man/man8 + cp -p -- man/man1/*.1df "$(HOME)"/.local/share/man/man1 + cp -p -- man/man8/*.8df "$(HOME)"/.local/share/man/man8 install-curl : - install -pm 0644 -- curl/curlrc "$(HOME)"/.curlrc + cp -p -- curl/curlrc "$(HOME)"/.curlrc install-dotfiles-man : man/man7/dotfiles.7df - install -m 0755 -d -- "$(HOME)"/.local/share/man/man7 - install -pm 0644 -- man/man7/*.7df "$(HOME)"/.local/share/man/man7 + mkdir -p -- "$(HOME)"/.local/share/man/man7 + cp -p -- man/man7/*.7df "$(HOME)"/.local/share/man/man7 install-dunst : install-x - install -m 0755 -d -- "$(HOME)"/.config/dunst - install -pm 0644 -- dunst/dunstrc "$(HOME)"/.config/dunst + mkdir -p -- "$(HOME)"/.config/dunst + cp -p -- dunst/dunstrc "$(HOME)"/.config/dunst + +install-ex : + cp -p -- ex/exrc "$(HOME)"/.exrc install-finger : - install -pm 0644 -- finger/plan "$(HOME)"/.plan - install -pm 0644 -- finger/project "$(HOME)"/.project - install -pm 0644 -- finger/pgpkey "$(HOME)"/.pgpkey + cp -p -- finger/plan "$(HOME)"/.plan + cp -p -- finger/project "$(HOME)"/.project + cp -p -- finger/pgpkey "$(HOME)"/.pgpkey install-games : $(GAMES) install-games-man - install -m 0755 -d -- "$(HOME)"/.local/games + mkdir -p -- "$(HOME)"/.local/games for name in games/* ; do \ [ -x "$$name" ] || continue ; \ - install -m 0755 -- "$$name" "$(HOME)"/.local/games ; \ + cp -p -- "$$name" "$(HOME)"/.local/games ; \ done install-games-man : - install -m 0755 -d -- "$(HOME)"/.local/share/man/man6 - install -pm 0644 -- man/man6/*.6df "$(HOME)"/.local/share/man/man6 + mkdir -p -- "$(HOME)"/.local/share/man/man6 + cp -p -- man/man6/*.6df "$(HOME)"/.local/share/man/man6 install-git : git/gitconfig - install -pm 0644 -- git/gitconfig "$(HOME)"/.gitconfig + cp -p -- git/gitconfig "$(HOME)"/.gitconfig install-gnupg : gnupg/gpg.conf - install -m 0700 -d -- \ + mkdir -m 0700 -p -- \ "$(HOME)"/.gnupg \ "$(HOME)"/.gnupg/sks-keyservers.net - install -pm 0600 -- gnupg/*.conf "$(HOME)"/.gnupg - install -pm 0644 -- gnupg/sks-keyservers.net/* \ + cp -p -- gnupg/*.conf "$(HOME)"/.gnupg + cp -p -- gnupg/sks-keyservers.net/* \ "$(HOME)"/.gnupg/sks-keyservers.net install-gtk : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config/gtkrc-3.0 - install -pm 0644 -- gtk/gtkrc-2.0 "$(HOME)"/.gtkrc-2.0 - install -pm 0644 -- gtk/gtkrc-3.0/settings.ini "$(HOME)"/.config/gtkrc-3.0 + cp -p -- gtk/gtkrc-2.0 "$(HOME)"/.gtkrc-2.0 + cp -p -- gtk/gtkrc-3.0/settings.ini "$(HOME)"/.config/gtkrc-3.0 install-i3 : install-x - install -m 0755 -d -- "$(HOME)"/.i3 - install -pm 0644 -- i3/* "$(HOME)"/.i3 + mkdir -p -- "$(HOME)"/.i3 + cp -p -- i3/* "$(HOME)"/.i3 install-less : - install -pm 0644 -- less/lesskey "$(HOME)"/.lesskey + cp -p -- less/lesskey "$(HOME)"/.lesskey command -v lesskey && lesskey install-mutt : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.muttrc.d \ "$(HOME)"/.cache/mutt - install -pm 0644 -- mutt/muttrc "$(HOME)"/.muttrc - install -pm 0755 -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d + cp -p -- mutt/muttrc "$(HOME)"/.muttrc + cp -p -- mutt/muttrc.d/src "$(HOME)"/.muttrc.d install-ncmcpp : - install -m 0755 -d -- "$(HOME)"/.ncmpcpp - install -pm 0644 -- ncmpcpp/config "$(HOME)"/.ncmpcpp/config + mkdir -p -- "$(HOME)"/.ncmpcpp + cp -p -- ncmpcpp/config "$(HOME)"/.ncmpcpp/config install-newsbeuter : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config/newsbeuter \ "$(HOME)"/.local/share/newsbeuter - install -pm 0644 -- newsbeuter/config "$(HOME)"/.config/newsbeuter/config + cp -p -- newsbeuter/config "$(HOME)"/.config/newsbeuter/config install-mysql : - install -pm 0644 -- mysql/my.cnf "$(HOME)"/.my.cnf + cp -p -- mysql/my.cnf "$(HOME)"/.my.cnf install-ksh : check-ksh install-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.shrc.d \ "$(HOME)"/.kshrc.d - install -pm 0644 -- ksh/shrc.d/* "$(HOME)"/.shrc.d - install -pm 0644 -- ksh/kshrc "$(HOME)"/.kshrc - install -pm 0644 -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d + cp -p -- ksh/shrc.d/* "$(HOME)"/.shrc.d + cp -p -- ksh/kshrc "$(HOME)"/.kshrc + cp -p -- ksh/kshrc.d/* "$(HOME)"/.kshrc.d install-perlcritic : - install -pm 0644 -- perlcritic/perlcriticrc "$(HOME)"/.perlcriticrc + cp -p -- perlcritic/perlcriticrc "$(HOME)"/.perlcriticrc install-perltidy : - install -pm 0644 -- perltidy/perltidyrc "$(HOME)"/.perltidyrc + cp -p -- perltidy/perltidyrc "$(HOME)"/.perltidyrc install-psql : - install -pm 0644 -- psql/psqlrc "$(HOME)"/.psqlrc + cp -p -- psql/psqlrc "$(HOME)"/.psqlrc install-readline : - install -pm 0644 -- readline/inputrc "$(HOME)"/.inputrc + cp -p -- readline/inputrc "$(HOME)"/.inputrc install-sh : check-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.profile.d \ "$(HOME)"/.shrc.d - install -pm 0644 -- sh/profile "$(HOME)"/.profile - install -pm 0644 -- sh/profile.d/* "$(HOME)"/.profile.d - install -pm 0644 -- sh/shinit "$(HOME)"/.shinit - install -pm 0644 -- sh/shrc "$(HOME)"/.shrc - install -pm 0644 -- sh/shrc.d/* "$(HOME)"/.shrc.d + cp -p -- sh/profile "$(HOME)"/.profile + cp -p -- sh/profile.d/* "$(HOME)"/.profile.d + cp -p -- sh/shinit "$(HOME)"/.shinit + cp -p -- sh/shrc "$(HOME)"/.shrc + cp -p -- sh/shrc.d/* "$(HOME)"/.shrc.d install-subversion : - install -m 0755 -d -- "$(HOME)"/.subversion - install -pm 0644 -- subversion/config "$(HOME)"/.subversion/config + mkdir -p -- "$(HOME)"/.subversion + cp -p -- subversion/config "$(HOME)"/.subversion/config install-terminfo : for info in terminfo/*.info ; do \ @@ -317,14 +322,14 @@ install-terminfo : done install-tmux : tmux/tmux.conf install-terminfo - install -pm 0644 -- tmux/tmux.conf "$(HOME)"/.tmux.conf + cp -p -- tmux/tmux.conf "$(HOME)"/.tmux.conf install-urxvt : urxvt/ext/select check-urxvt - install -m 0755 -d -- "$(HOME)"/.urxvt/ext + mkdir -p -- "$(HOME)"/.urxvt/ext for name in urxvt/ext/* ; do \ case $$name in \ *.pl) ;; \ - *) install -m 0644 -- "$$name" "$(HOME)"/.urxvt/ext ;; \ + *) cp -p -- "$$name" "$(HOME)"/.urxvt/ext ;; \ esac \ done @@ -336,50 +341,50 @@ install-gvim : install-vim \ install-gvim-config install-vim-config : - install -pm 0644 -- vim/vimrc "$(HOME)"/.vimrc + cp -p -- vim/vimrc "$(HOME)"/.vimrc install-gvim-config : - install -pm 0644 -- vim/gvimrc "$(HOME)"/.gvimrc + cp -p -- vim/gvimrc "$(HOME)"/.gvimrc install-vim-plugins : install-vim-config find vim/after vim/bundle -name .git -prune -o \ - -type d -exec sh -c 'install -m 0755 -d -- \ + -type d -exec sh -c 'mkdir -p -- \ "$(HOME)"/."$$1"' _ {} \; -o \ - -type f -exec sh -c 'install -m 0644 -- \ + -type f -exec sh -c 'cp -p -- \ "$$1" "$(HOME)"/."$$1"' _ {} \; install-vim-pathogen : install-vim-plugins - install -m 0755 -d -- "$(HOME)"/.vim/autoload + mkdir -p -- "$(HOME)"/.vim/autoload rm -f -- "$(HOME)"/.vim/autoload/pathogen.vim ln -s -- ../bundle/pathogen/autoload/pathogen.vim \ "$(HOME)"/.vim/autoload/pathogen.vim install-x : - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.config \ "$(HOME)"/.xinitrc.d \ "$(HOME)"/.Xresources.d - install -pm 0644 -- X/redshift.conf "$(HOME)"/.config/redshift.conf - install -pm 0644 -- X/xbindkeysrc "$(HOME)"/.xbindkeysrc - install -pm 0644 -- X/xinitrc "$(HOME)"/.xinitrc - install -pm 0644 -- X/xinitrc.d/* "$(HOME)"/.xinitrc.d - install -pm 0644 -- X/Xresources "$(HOME)"/.Xresources - install -pm 0644 -- X/Xresources.d/* "$(HOME)"/.Xresources.d + cp -p -- X/redshift.conf "$(HOME)"/.config/redshift.conf + cp -p -- X/xbindkeysrc "$(HOME)"/.xbindkeysrc + cp -p -- X/xinitrc "$(HOME)"/.xinitrc + cp -p -- X/xinitrc.d/* "$(HOME)"/.xinitrc.d + cp -p -- X/Xresources "$(HOME)"/.Xresources + cp -p -- X/Xresources.d/* "$(HOME)"/.Xresources.d install-yash : check-yash install-sh - install -m 0755 -d -- "$(HOME)"/.yashrc.d - install -pm 0644 -- yash/yash_profile "$(HOME)"/.yash_profile - install -pm 0644 -- yash/yashrc "$(HOME)"/.yashrc - install -pm 0644 -- yash/yashrc.d/* "$(HOME)"/.yashrc.d + mkdir -p -- "$(HOME)"/.yashrc.d + cp -p -- yash/yash_profile "$(HOME)"/.yash_profile + cp -p -- yash/yashrc "$(HOME)"/.yashrc + cp -p -- yash/yashrc.d/* "$(HOME)"/.yashrc.d install-zsh : check-zsh install-sh - install -m 0755 -d -- \ + mkdir -p -- \ "$(HOME)"/.profile.d \ "$(HOME)"/.zshrc.d - install -pm 0644 -- zsh/profile.d/* "$(HOME)"/.profile.d - install -pm 0644 -- zsh/zprofile "$(HOME)"/.zprofile - install -pm 0644 -- zsh/zshrc "$(HOME)"/.zshrc - install -pm 0644 -- zsh/zshrc.d/* "$(HOME)"/.zshrc.d + cp -p -- zsh/profile.d/* "$(HOME)"/.profile.d + cp -p -- zsh/zprofile "$(HOME)"/.zprofile + cp -p -- zsh/zshrc "$(HOME)"/.zshrc + cp -p -- zsh/zshrc.d/* "$(HOME)"/.zshrc.d check : check-bash \ check-bin \ @@ -416,11 +421,11 @@ check-zsh : check/zsh lint : check \ - lint-bash \ - lint-bin \ - lint-games \ - lint-ksh \ - lint-sh \ + lint-bash \ + lint-bin \ + lint-games \ + lint-ksh \ + lint-sh \ lint-urxvt \ lint-yash diff --git a/README.markdown b/README.markdown index 586594a4..cd91dd8b 100644 --- a/README.markdown +++ b/README.markdown @@ -15,8 +15,7 @@ Installation $ make -n install $ make install -For the default `all` target, you'll need `bash(1)`, `git(1)`, `install(1)`, -`make(1)`, and `m4(1)`. +For the default `all` target, you'll need `bash(1)`, `make(1)`, and `m4(1)`. The installation `Makefile` will overwrite things standing in the way of its installed files without backing them up, so read the output of `make -n @@ -29,9 +28,9 @@ directory so you can explore: $ env -i HOME="$tmpdir" TERM="$TERM" bash -l The default target will install the core terminal-only files: cURL, Git, GnuPG, -Vim, shell scripts and functions, and shell and terminal setup files. The -remaining dotfiles can be installed with the other targets. Take a look at the -`Makefile` to see what's available. +vi/Vim, shell scripts and functions, and shell setup files. The remaining +dotfiles can be installed with the other targets. Take a look at the `Makefile` +to see what's available. Tools ----- @@ -483,6 +482,8 @@ Installed by the `install-bin` target: * `mkmv(1df)` creates a directory and moves preceding arguments into it. * `motd(1df)` shows the system MOTD. * `onl(1df)` crunches input down to one printable line. +* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s + `s_client` subcommand. * `pa(1df)` prints its arguments, one per line. * `pp(1df)` prints the full path of each argument using `$PWD`. * `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`. @@ -506,7 +507,7 @@ Installed by the `install-bin` target: `scp(1)`'s HOST:PATH format. * `td(1df)` manages a to-do file for you with `$EDITOR` and `git(1)`; I used to use Taskwarrior, but found it too complex and buggy. -* `tm()` runs `tmux(1)` with `attach-session -d` if a session exists, and +* `tm(1df)` runs `tmux(1)` with `attach-session -d` if a session exists, and `new-session` if it doesn't. * `try(1df)` repeats a command up to a given number of times until it succeeds, only printing error output if all three attempts failed. Good for diff --git a/X/Xresources b/X/Xresources index 487c6ab0..d7d7556f 100644 --- a/X/Xresources +++ b/X/Xresources @@ -1,2 +1,3 @@ -#include ".Xresources.d/Xft" #include ".Xresources.d/URxvt" +#include ".Xresources.d/Xft" +#include ".Xresources.d/xterm" diff --git a/X/Xresources.d/xterm b/X/Xresources.d/xterm new file mode 100644 index 00000000..ffa29689 --- /dev/null +++ b/X/Xresources.d/xterm @@ -0,0 +1,9 @@ +! XTerm +xterm*bellIsUrgent : true +xterm*internalBorder : 0 +xterm*colorMode : false +xterm*eightBitInput : false +xterm*faceName : Ubuntu Mono:size=12 +xterm*locale : true +xterm*metaSendsEscape : true +xterm*termName : xterm-mono diff --git a/bash/bash_completion.d/_abook_addresses.bash b/bash/bash_completion.d/_abook_addresses.bash new file mode 100644 index 00000000..8e341172 --- /dev/null +++ b/bash/bash_completion.d/_abook_addresses.bash @@ -0,0 +1,10 @@ +# Email addresses from abook(1) +_abook_addresses() { + while IFS=$'\t' read -r address _ ; do + case $address in + "${COMP_WORDS[COMP_CWORD]}"*) + COMPREPLY[${#COMPREPLY[@]}]=$address + ;; + esac + done < <(abook --mutt-query \@) +} diff --git a/bash/bash_completion.d/chgrp.bash b/bash/bash_completion.d/chgrp.bash new file mode 100644 index 00000000..d047f97f --- /dev/null +++ b/bash/bash_completion.d/chgrp.bash @@ -0,0 +1,20 @@ +# Complete group names for first non-option chgrp(1) argument +_chgrp() { + local i + for ((i = 1; i < COMP_CWORD; i++)) ; do + case ${COMP_WORDS[i]} in + -*) ;; + *) return 1 ;; + esac + done + while read -r group ; do + COMPREPLY[${#COMPREPLY[@]}]=$group + done < <(compgen -A group -- "${COMP_WORDS[COMP_CWORD]}") +} + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _chgrp -o bashdefault -o default chgrp +else + complete -F _chgrp -o default chgrp +fi diff --git a/bash/bash_completion.d/ftp.bash b/bash/bash_completion.d/ftp.bash index e6d292a9..335d711a 100644 --- a/bash/bash_completion.d/ftp.bash +++ b/bash/bash_completion.d/ftp.bash @@ -30,4 +30,10 @@ _ftp() { COMPREPLY[${#COMPREPLY[@]}]=$machine done } -complete -F _ftp -o default ftp + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ftp -o bashdefault -o default ftp +else + complete -F _ftp -o default ftp +fi diff --git a/bash/bash_completion.d/gpg.bash b/bash/bash_completion.d/gpg.bash index fcb48b91..6d4cf345 100644 --- a/bash/bash_completion.d/gpg.bash +++ b/bash/bash_completion.d/gpg.bash @@ -14,4 +14,10 @@ _gpg() { COMPREPLY[${#COMPREPLY[@]}]=$option done < <(gpg --dump-options 2>/dev/null) } -complete -F _gpg -o default gpg + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _gpg -o bashdefault -o default gpg +else + complete -F _gpg -o default gpg +fi diff --git a/bash/bash_completion.d/mail.bash b/bash/bash_completion.d/mail.bash new file mode 100644 index 00000000..4476df12 --- /dev/null +++ b/bash/bash_completion.d/mail.bash @@ -0,0 +1,10 @@ +# Completion for mail(1) with abook(1) email addresses +declare -F _abook_addresses >/dev/null || + source "$HOME"/.bash_completion.d/_abook_addresses.bash + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _abook_addresses -o bashdefault -o default mail +else + complete -F _abook_addresses -o default mail +fi diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index b3314e21..bb01b36a 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -48,4 +48,10 @@ _make() { esac done < "$mf" } -complete -F _make -o default make + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _make -o bashdefault -o default make +else + complete -F _make -o default make +fi diff --git a/bash/bash_completion.d/man.bash b/bash/bash_completion.d/man.bash index f779d203..658b5eb7 100644 --- a/bash/bash_completion.d/man.bash +++ b/bash/bash_completion.d/man.bash @@ -69,4 +69,10 @@ _man() { fi ) } -complete -F _man -o default man + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _man -o bashdefault -o default man +else + complete -F _man -o default man +fi diff --git a/bash/bash_completion.d/mutt.bash b/bash/bash_completion.d/mutt.bash new file mode 100644 index 00000000..d8bcc15d --- /dev/null +++ b/bash/bash_completion.d/mutt.bash @@ -0,0 +1,10 @@ +# Completion for mutt(1) with abook(1) email addresses +declare -F _abook_addresses >/dev/null || + source "$HOME"/.bash_completion.d/_abook_addresses.bash + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _abook_addresses -o bashdefault -o default mutt +else + complete -F _abook_addresses -o default mutt +fi diff --git a/bash/bash_completion.d/mysql.bash b/bash/bash_completion.d/mysql.bash index 9755f033..2886f62e 100644 --- a/bash/bash_completion.d/mysql.bash +++ b/bash/bash_completion.d/mysql.bash @@ -35,4 +35,10 @@ _mysql() { fi ) } -complete -F _mysql -o default mysql + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _mysql -o bashdefault -o default mysql +else + complete -F _mysql -o default mysql +fi diff --git a/bash/bash_completion.d/sftp.bash b/bash/bash_completion.d/sftp.bash index 5d52c739..60044e41 100644 --- a/bash/bash_completion.d/sftp.bash +++ b/bash/bash_completion.d/sftp.bash @@ -1,4 +1,10 @@ # Completion for sftp(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash -complete -F _ssh_config_hosts -o default sftp + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ssh_config_hosts -o bashdefault -o default sftp +else + complete -F _ssh_config_hosts -o default sftp +fi diff --git a/bash/bash_completion.d/source.bash b/bash/bash_completion.d/source.bash index abd468af..de608813 100644 --- a/bash/bash_completion.d/source.bash +++ b/bash/bash_completion.d/source.bash @@ -1,4 +1,4 @@ -# Completion for source(1) with files that look editable +# Completion for `source` with files that look like plain text declare -F _text_filenames >/dev/null || source "$HOME"/.bash_completion.d/_text_filenames.bash complete -F _text_filenames -o filenames source diff --git a/bash/bash_completion.d/ssh-copy-id.bash b/bash/bash_completion.d/ssh-copy-id.bash index daf52751..5e4fe99b 100644 --- a/bash/bash_completion.d/ssh-copy-id.bash +++ b/bash/bash_completion.d/ssh-copy-id.bash @@ -1,4 +1,10 @@ # Completion for ssh-copy-id(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash -complete -F _ssh_config_hosts -o default ssh-copy-id + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ssh_config_hosts -o bashdefault -o default ssh-copy-id +else + complete -F _ssh_config_hosts -o default ssh-copy-id +fi diff --git a/bash/bash_completion.d/ssh.bash b/bash/bash_completion.d/ssh.bash index 03745eaa..c8212614 100644 --- a/bash/bash_completion.d/ssh.bash +++ b/bash/bash_completion.d/ssh.bash @@ -1,4 +1,10 @@ # Completion for ssh(1) with ssh_config(5) hostnames declare -F _ssh_config_hosts >/dev/null || source "$HOME"/.bash_completion.d/_ssh_config_hosts.bash -complete -F _ssh_config_hosts -o default ssh + +# bashdefault requires Bash >=3.0 +if ((BASH_VERSINFO[0] >= 3)) ; then + complete -F _ssh_config_hosts -o bashdefault -o default ssh +else + complete -F _ssh_config_hosts -o default ssh +fi diff --git a/bash/bashrc b/bash/bashrc index 16669adf..166fc501 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -9,9 +9,9 @@ esac # shellcheck disable=SC2128 [ -n "$BASH_VERSINFO" ] && shopt -q restricted_shell && return -# Clear away all aliases; we do this here rather than in $ENV because the ksh -# family of shells relies on aliases to implement certain POSIX utilities like -# fc(1) and type(1) +# Clear away all aliases; we do this here rather than in the $ENV file shared +# between POSIX shells, because ksh relies on aliases to implement certain +# POSIX utilities, like fc(1) and type(1) unalias -a # If ENV is set, source it to get all the POSIX-compatible interactive stuff; @@ -30,61 +30,63 @@ unalias -a # Keep around 32K lines of history in file HISTFILESIZE=$((1 << 15)) -# Ignore duplicate commands and whitespace in history -HISTCONTROL=ignoreboth +# Ignore duplicate commands +HISTCONTROL=ignoredups # Keep the times of the commands in history HISTTIMEFORMAT='%F %T ' -# Use a more compact format for the time builtin's output +# Use a more compact format for the `time` builtin's output TIMEFORMAT='real:%lR user:%lU sys:%lS' -# Autocorrect fudged paths in cd calls +# Correct small errors in directory names given to the `cd` buildtin shopt -s cdspell -# Update the hash table properly +# Check that hashed commands still exist before running them shopt -s checkhash -# Update columns and rows if window size changes +# Update LINES and COLUMNS after each command if necessary shopt -s checkwinsize -# Put multi-line commands onto one line of history +# Put multi-line commands into one history entry shopt -s cmdhist -# Include dotfiles in pattern matching +# Include filenames with leading dots in pattern matching shopt -s dotglob -# Enable advanced pattern matching +# Enable extended globbing: !(foo), ?(bar|baz)... shopt -s extglob -# Append rather than overwrite Bash history +# Append history to $HISTFILE rather than overwriting it shopt -s histappend -# Repeat the line on failed history expansion +# If history expansion fails, reload the command to try again shopt -s histreedit -# Repeat the expanded line on successful history expansion +# Load history expansion result as the next command, don't run them directly shopt -s histverify -# Use Bash's builtin host completion -shopt -s hostcomplete +# Don't assume a word with a @ in it is a hostname +shopt -u hostcomplete # Don't change newlines to semicolons in history shopt -s lithist -# Don't warn me about new mail all the time +# Don't try to tell me when my mail is read shopt -u mailwarn -# Ignore me if I try to complete an empty line +# Don't complete a Tab press on an empty line with every possible command shopt -s no_empty_cmd_completion # Use programmable completion, if available shopt -s progcomp -# Warn me if I try to shift when there's nothing there +# Warn me if I try to shift nonexistent values off an array shopt -s shift_verbose -# Don't use PATH to find files to source +# Don't search $PATH to find files for the `source` builtin shopt -u sourcepath # These options only exist since Bash 4.0-alpha if ((BASH_VERSINFO[0] >= 4)) ; then - # Autocorrect fudged paths during completion + # Correct small errors in directory names during completion shopt -s dirspell - # Enable double-starring paths + # Allow double-star globs to match files and recursive paths shopt -s globstar - # Warn me about stopped jobs when exiting; only if >=4.1 due to bug + # Warn me about stopped jobs when exiting + # Available since 4.0, but only set it if >=4.1 due to bug: # <https://lists.gnu.org/archive/html/bug-bash/2009-02/msg00176.html> ((BASH_VERSINFO[1] >= 1)) && shopt -s checkjobs - # Expand variables in directory completion; only available since 4.3 + # Expand variables in directory completion + # Only available since 4.3 ((BASH_VERSINFO[1] >= 3)) && shopt -s direxpand fi diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index c77f8844..51de24b8 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -1,9 +1,9 @@ -# Various easy completions for Bash builtins; more specific stuff goes in -# ~/.bash_completion.d +# Simple completions for Bash builtins and POSIX utilities; more specific or +# complex stuff goes in ~/.bash_completion.d, for possible dynamic loading # If COMP_WORDBREAKS has a value, strip all colons from it; this allows -# completing filenames correctly, since an unquoted colon is not a syntactic -# character: <http://tiswww.case.edu/php/chet/bash/FAQ> (E13) +# completing filenames correctly, since a colon is not a shell metacharacter: +# <http://tiswww.case.edu/php/chet/bash/FAQ> (E13) [[ -n $COMP_WORDBREAKS ]] && COMP_WORDBREAKS=${COMP_WORDBREAKS//:} # If ~/.hosts exists, use that as the host completion file rather than @@ -22,7 +22,8 @@ complete -A disabled enable complete -A setopt set # Commands -complete -A command alias command complete compopt coproc exec if hash time type until while +complete -A command alias command complete compopt coproc exec if hash time \ + type until while # Directories complete -A directory cd pushd mkdir rmdir diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash index a13fec12..da7ff558 100644 --- a/bash/bashrc.d/keep.bash +++ b/bash/bashrc.d/keep.bash @@ -46,8 +46,8 @@ keep() { # -h given; means show help h) cat <<EOF -${FUNCNAME[0]}: Keep variables and functions in shell permanently by writing them to -named scripts iterated on shell start, in \$BASHKEEP (defaults to +${FUNCNAME[0]}: Keep variables and functions in shell permanently by writing +them to named scripts iterated on shell start, in \$BASHKEEP (defaults to ~/.bashkeep.d). USAGE: diff --git a/bin/osc b/bin/osc new file mode 100755 index 00000000..87f79365 --- /dev/null +++ b/bin/osc @@ -0,0 +1,92 @@ +#!/bin/sh +# Sane and safe OpenSSL s_client(1ssl) connection +self=osc + +# Check we have openssl(1); we need to fail early lest we go setting up FIFOs +# needlessly +if ! command -v openssl >/dev/null 2>&1 ; then + printf >&2 '%s: openssl(1) not found\n' "$self" + exit 1 +fi + +# Hostname is first argument; assume localhost if empty/unset +host=${1:-localhost} +# Service name or port is second argument; assume HTTPS if empty/unset +serv=${2:-https} + +# Start building the command-line string +set -- +## If we have rlwrap, use it, but don't complain if we don't +if command -v rlwrap >/dev/null 2>&1 ; then + set -- "$@" rlwrap +fi +## The actual openssl(1ssl) and subcommand call +set -- "$@" openssl s_client +## No insecure SSL methods +set -- "$@" -no_ssl2 -no_ssl3 +## Don't dump nonsense to terminal, and don't renegotiate on R or quit on Q +set -- "$@" -quiet +## But do cut the connection if I issue ^D, even though I just set -quiet +set -- "$@" -no_ign_eof +## Do verify the certificate chain and don't connect if we can't +set -- "$@" -verify 5 -verify_return_error +## We might add STARTTLS for the supported services: +case $serv in + ftp|21) + set -- "$@" -starttls ftp + ;; + smtp|25) + set -- "$@" -starttls smtp + ;; + pop3|110) + set -- "$@" -starttls pop3 + ;; + imap|143) + set -- "$@" -starttls imap + ;; + xmpp-client|5222) + set -- "$@" -starttls xmpp + ;; +esac +## Send the host parameter as the server name (SNI) +set -- "$@" -servername "$host" +## Finally, add the host and service to connect to +set -- "$@" -connect "$host":"$serv" + +# Do the POSIX dance to kill child processes and clean up temp files even if +# killed by a signal +td='' fil='' +cleanup() { + trap - EXIT "$1" + [ -n "$fil" ] && kill -TERM "$fil" + [ -n "$td" ] && rm -fr -- "$td" + if [ "$1" != EXIT ] ; then + kill -"$1" "$$" + fi +} +for sig in EXIT HUP INT TERM ; do + # shellcheck disable=SC2064 + trap "cleanup $sig" "$sig" +done + +# Create a temporary directory and a FIFO in it +td=$(mktd "$self") || exit +mkfifo -- "$td"/verify-filter || exit + +# Open a read-write file descriptor onto the FIFO +exec 3<>"$td"/verify-filter || exit + +# Start a background filter process on the FIFO to get rid of the leading +# verification output set to stderr; as soon as we find a single line that +# doesn't look like that routine output, print all future lines to stderr as +# normal +awk ' +body{print;next} +/^verify depth is [0-9]+$/{next} +/^depth=[0-9]+ /{next} +/^verify return:[0-9]+$/{next} +{body=1;print} +' <&3 >&2 & fil=$! + +# Start the process with the options we stacked up +"$@" 2>&3 diff --git a/ex/exrc b/ex/exrc new file mode 100644 index 00000000..0c001f36 --- /dev/null +++ b/ex/exrc @@ -0,0 +1,6 @@ +" POSIX ex/vi settings +set autoindent +set report=0 +set shiftwidth=4 +set showmode +set tabstop=4 @@ -18,7 +18,6 @@ set -o trackall # Save history HISTFILE=$HOME/.ksh_history -HISTSIZE=$((1 << 10)) # Load any supplementary scripts for kshrc in "$HOME"/.kshrc.d/*.ksh ; do diff --git a/ksh/shrc.d/ksh.sh b/ksh/shrc.d/ksh.sh index 8e33da7c..6101fc84 100644 --- a/ksh/shrc.d/ksh.sh +++ b/ksh/shrc.d/ksh.sh @@ -28,8 +28,5 @@ if [ -z "$KSH_VERSION" ] ; then KSH_VERSION=${.sh.version} fi -# If KSH_ENV isn't already set, set it -[ -n "$KSH_ENV" ] || KSH_ENV=$HOME/.kshrc - # If ENV_EXT isn't already set, set it -[ -n "$ENV_EXT" ] || ENV_EXT=$KSH_ENV +[ -n "$ENV_EXT" ] || ENV_EXT=$HOME/.kshrc diff --git a/man/man1/osc.1df b/man/man1/osc.1df new file mode 100644 index 00000000..9fb61dde --- /dev/null +++ b/man/man1/osc.1df @@ -0,0 +1,22 @@ +.TH OSC 1df "February 2017" "Manual page for osc" +.SH NAME +.B osc +\- netcat-like wrapper for openssl s_client +.SH SYNOPSIS +.B osc [HOST [SERVICE]] +.SH DESCRIPTION +.B osc +runs openssl(1ssl)'s s_client subcommand with some options to make it behave a +bit like netcat(1), quieting errors and even handling STARTTLS if it knows how, +but still forcing correct verification of certificates and only connecting with +TLS (not SSL). +.P +If rlwrap(1) is available, the client will be run within that to allow line +editing. +.P +It's intended to be run as an interactive tool for cases where you want to +focus more on debugging the data exchange with the actual server, and not +debugging the OpenSSL negotiation itself. The author finds it handy for poking +his STARTTLS SMTP mailserver. +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> diff --git a/sh/profile.d/games.sh b/sh/profile.d/games.sh index 58db3487..ee56c593 100644 --- a/sh/profile.d/games.sh +++ b/sh/profile.d/games.sh @@ -1,2 +1,3 @@ # Add ~/.local/games to PATH if it exists -[ -d "$HOME"/.local/games ] && PATH=$HOME/.local/games:$PATH +[ -d "$HOME"/.local/games ] || return +PATH=$HOME/.local/games:$PATH diff --git a/sh/profile.d/keychain.sh b/sh/profile.d/keychain.sh index 9213de7f..f3d25c62 100644 --- a/sh/profile.d/keychain.sh +++ b/sh/profile.d/keychain.sh @@ -1,5 +1,5 @@ # keychain setup -command -v keychain >/dev/null 2>&1 && - eval "$(TERM=${TERM:-ansi} keychain \ - --eval --ignore-missing --quick --quiet \ - id_dsa id_rsa id_ecsda)" +command -v keychain >/dev/null 2>&1 || return +eval "$(TERM=${TERM:-ansi} keychain \ + --eval --ignore-missing --quick --quiet \ + id_dsa id_rsa id_ecsda)" @@ -20,5 +20,6 @@ for sh in "$HOME"/.shrc.d/*.sh ; do done unset -v sh -# If ENV_EXT was set and exists, source that too +# If ENV_EXT was set and exists, source that too, then clean it away [ -e "$ENV_EXT" ] && . "$ENV_EXT" +unset -v ENV_EXT diff --git a/sh/shrc.d/keychain.sh b/sh/shrc.d/keychain.sh index d9aaf63f..9a732384 100644 --- a/sh/shrc.d/keychain.sh +++ b/sh/shrc.d/keychain.sh @@ -1,4 +1,4 @@ # If GPG_AGENT_INFO is set, update GPG_TTY for clean use of pinentry(1) etc [ -n "$GPG_AGENT_INFO" ] || return -GPG_TTY=$(command -p tty) +GPG_TTY=$(command -p tty) || return export GPG_TTY diff --git a/vim/bundle/html5 b/vim/bundle/html5 -Subproject 6a5cc0511776b69994b5e3bb2cacccbb81fa846 +Subproject fc64e3d0de438a02dcfbe9d6fc7d73dbf721ce2 diff --git a/vim/bundle/pathogen b/vim/bundle/pathogen -Subproject 7ba2e1b67a8f8bcbafedaf6763580390dfd9343 +Subproject 020ab25c38f62627c1dab6c7a851176c6ad309f |