diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2025-12-26 11:55:21 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2025-12-26 11:55:21 -0500 |
| commit | e223ea0a045f1e086e0780f7c1778a94bce92ad6 (patch) | |
| tree | 39983b748e0c98e7a4c137ffffedea9c5df779d7 /kshrc | |
| parent | 9cd1e4f16131c41f2b16637ced9fd184573a7102 (diff) | |
| download | dotfiles-e223ea0a045f1e086e0780f7c1778a94bce92ad6.tar.gz dotfiles-e223ea0a045f1e086e0780f7c1778a94bce92ad6.tar.xz | |
Some tweaks and updates to dotfiles
Diffstat (limited to 'kshrc')
| -rw-r--r-- | kshrc | 69 |
1 files changed, 47 insertions, 22 deletions
@@ -27,10 +27,6 @@ alias setxkbmap-list="man xkeyboard-config" #shellcheck disable=SC2139 [ -x "$(command -v python3)" ] && alias python="$(command -v python3) -q" -if [ "$(uname)" = "OpenBSD" ] ; then - ! [ -x "$(which seq 2>/dev/null)" ] && alias seq="echo \"use jot(1)\"" -fi - if [ "$(uname)" = "Linux" ] ; then alias bc='bc -q' fi @@ -77,6 +73,7 @@ xbps-remove pkg_add pkg_delete pkg +pkgin tlp tlp-stat zfs @@ -165,6 +162,10 @@ set_ksh_competion() { set -A complete_passenv -- \ $(showPasswordStore ~/.password-store) + #shellcheck disable=SC2046 + set -A complete_dpwenv -- \ + $(showPasswordStore ~/.password-store) + fi #shellcheck disable=SC2046 @@ -314,6 +315,10 @@ sshSetAskpass() { export SSH_ASKPASS_REQUIRE=force } +# checkSSHAgentForward is useful for if we're an active SSH connection and setup +# the `agent_conf` for it. this can be dropped into your ~/.kshrc.local on a +# remote server to allow your remote sessions to pick up on forwarded keys, +# useful for jump boxes, remote development and similar. checkSSHAgentForward() { if ! [ -d "$HOME"/.ssh ] ; then mkdir -p "$HOME"/.ssh @@ -331,15 +336,20 @@ checkSSHAgentForward() { fi } +# checkSSHAgent is my go-to agent setup, it's aggressive, non-standard and a +# little hacky, but way more reliable at setting up a persistent ssh-agent than +# doing something at login and hoping everything else inherits it +# usage is fairly straightforward, drop it into your `~/.kshrc.local` and +# let it do it's thing. #shellcheck disable=SC2120 checkSSHAgent() { if [ "$1" = "-k" ] ; then pkill -9 ssh-agent fi - # So OpenSSH 10.1 steps on my configuration, rather than passing in - # -T which doesn't exist on older SSH, simply move my configuration - # out of the way. + # So OpenSSH 10.1 steps on my old configuration, rather than passing in -T + # which doesn't exist on older SSH, simply move my configuration out of the + # way. if [ -f "$HOME/.ssh/agent" ] ; then rm "$HOME/.ssh/agent" fi @@ -360,11 +370,13 @@ checkSSHAgent() { fi } +# checkSSHAgentGPG sets up SSH to talk to GPG for its keys instead checkSSHAgentGPG() { #shellcheck disable=SC2155 export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" } +# calls pass and dumps the contents of the password into your environment passenv() { _f="$(mktemp)" pass "$@" > "$_f" @@ -373,6 +385,16 @@ passenv() { rm -f "$_f" } +# calls dpw ( https://git.riedstra.dev/mitch/dpw ) and dumps the contents of the +# password into your environment +dpwenv() { + _f="$(mktemp)" + dpw "$@" > "$_f" + #shellcheck disable=SC1090 + . "$_f" + rm -f "$_f" +} + # gensubids is useful for generating /etc/subuid and /etc/subgid # if you have say a 3rd user you want to add gensubids() { @@ -402,20 +424,31 @@ gensubids() { echo "$_un:$(( (_n*_step) + 1 )):$(( (_n*_step) + _step ))" } +# scangit is useful for checking which repositories you've modified scangit() { + verbose=false ref="origin/master" while [ $# -gt 0 ] ; do case $1 in + -v) verbose=true ; shift ;; -r) ref="$2"; shift ; shift ;; --) break ;; - *) echo "bad option '$1' usage: scangit [-r <ref>] -- <paths>" ; return ;; + *) echo "bad option '$1' usage: scangit [-v] [-r <ref>] -- <paths>" ; return ;; esac ; done find "$@" -iname '.git' -type d 2>/dev/null \ - | while read -r d ; do - cd "$(dirname "$d")" - git diff-index --quiet "$ref" 2>/dev/null \ - || echo "$(dirname "$d")" + | while read -r _d ; do + $verbose && echo "Checking... $(dirname "$_d") against ref \"$ref\"" + cd "$(dirname "$_d")" + if $verbose ; then + git diff-index --quiet "$ref" 2>/dev/null \ + || echo "Has changes" + else + git diff-index --quiet "$ref" 2>/dev/null \ + || echo "$(dirname "$_d")" + fi + cd - >/dev/null done } + gitdate() { date="" while [ $# -gt 0 ] ; do case $1 in @@ -455,17 +488,11 @@ gpgTmpDir() { setcolorterminal() { case $TERM in - xterm-kitty) - # Prevent xterm-kitty from being turned into xterm-256color - return; - ;; xterm*) export TERM=xterm-256color - # printf $'\033]0;'"$(hostname)"$'\007'; ;; screen*) export TERM=screen-256color - # printf $'\033k'"$(whoami)"$'\033\\'; ;; esac } @@ -509,8 +536,6 @@ path_preappend "$HOME/bin" PRELOAD="$HOME/${SHELL_CONFIG}.pre" LOCAL="$HOME/${SHELL_CONFIG}.local" -export PASSWORD_STORE_ENABLE_EXTENSIONS=true - # Don't put any variables below this, as they can't be overridden before the # functions if you do that @@ -566,12 +591,12 @@ elif [ -n "$BASH" ] ; then fi fi -if [ $COLOR -eq 1 ] ; then +setcolor() { colormanpages setcolorterminal setcoloraliases setlscolors -fi +} [ -d "$HOME/.local/bin" ] && path_preappend "$HOME/.local/bin" |
