diff options
| -rw-r--r-- | .config/kak/kakrc | 31 | ||||
| -rw-r--r-- | .config/ksh/ksh.kshrc | 9 | ||||
| -rw-r--r-- | .config/shell/aliasrc | 1 | ||||
| -rw-r--r-- | .gnupg/gpg-agent.conf | 4 | ||||
| -rw-r--r-- | .kshrc | 2 | ||||
| -rwxr-xr-x | .local/bin/pn | 64 | ||||
| -rwxr-xr-x | .local/bin/push.sh | 41 | ||||
| -rwxr-xr-x | .local/bin/pwd-short | 9 |
8 files changed, 103 insertions, 58 deletions
diff --git a/.config/kak/kakrc b/.config/kak/kakrc index 74a2019..02d52e2 100644 --- a/.config/kak/kakrc +++ b/.config/kak/kakrc @@ -10,30 +10,11 @@ map -docstring "Jump to next make error" global goto ] <esc>:make-next-error map -docstring "Jump to previous make error" global goto [ <esc>:make-previous-error<ret> hook global RegisterModified '"' %{ nop %sh{ - export kak_client_pid="$kak_client_pid" + export kak_client_pid="$kak_client_pid" printf %s "$kak_main_reg_dquote" | vis-clipboard --copy }} - -# define-command -docstring "Edit file relative to current buf" -params 1 edit-relative %{ edit "%sh{dirname ""${kak_buffile}""}/%arg{@}" } -# alias global er edit-relative -# complete-command -menu edit-relative shell-script %{ -# orig="$(realpath --relative-to . $(dirname "$kak_buffile"))" -# q="${1}" -# if [ "$(basename "$q")" = ".." ]; then -# d="$(realpath --relative-to . "$q")" -# elif [ "$(basename "$q")" = "." ]; then -# d="$(realpath --relative-to . "$q")" -# elif [ -n "$q" ]; then -# if [ "$(printf "$q" | tail -c 1)" = / ]; then -# d="$q" -# else -# d="$(dirname "$q")" -# fi -# else -# d="." -# fi -# # echo "orig:$orig" -# # echo "q:$q" -# # echo "d:$d" -# fdfind --base-directory "$orig" --full-path --hidden --exact-depth 1 -- . "$d" | fzf --filter "$q" -# } +hook global WinCreate ^[^*]+$ %{editorconfig-load} +hook global BufSetOption filetype=python %{ + set-option buffer formatcmd 'ruff format -' + hook buffer -group format BufWritePost .* format +} diff --git a/.config/ksh/ksh.kshrc b/.config/ksh/ksh.kshrc index 532640a..40ec46c 100644 --- a/.config/ksh/ksh.kshrc +++ b/.config/ksh/ksh.kshrc @@ -1,3 +1,8 @@ +if SOME_VARIABLE=`push.sh 2>/dev/null` +then eval "$SOME_VARIABLE" +else echo "push.sh not installed" >&2; exit 1 +fi + ..() { set -- ".." "$@"; for up; do cd $up; done; } lfcd () { @@ -26,4 +31,6 @@ export HISTSIZE=100000 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" set -o emacs - +[ -f /run/.containerenv ] && [ -n "$PNSH_KAK_AUTOSTART" ] && { + ks s 2>&1 >/dev/null || kc s +} diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc index 8f50878..0d7ee65 100644 --- a/.config/shell/aliasrc +++ b/.config/shell/aliasrc @@ -8,5 +8,4 @@ alias d="docker " # alias k="kak " alias kd='echo cd $PWD | kak -p s ' alias kb='cd $(cd-kak-buf)' -alias t="terraform " alias e='$EDITOR ' diff --git a/.gnupg/gpg-agent.conf b/.gnupg/gpg-agent.conf index f30e893..18d63b7 100644 --- a/.gnupg/gpg-agent.conf +++ b/.gnupg/gpg-agent.conf @@ -5,8 +5,8 @@ #pinentry-program /usr/bin/pinentry-x11 #pinentry-program /usr/local/bin/pinentry-curses #pinentry-program /usr/local/bin/pinentry-mac -#pinentry-program /opt/homebrew/bin/pinentry-mac -pinentry-program /usr/bin/pinentry-dmenu +pinentry-program /opt/homebrew/bin/pinentry-mac +#pinentry-program /usr/bin/pinentry-dmenu enable-ssh-support ttyname $GPG_TTY default-cache-ttl 60 @@ -1,4 +1,4 @@ -[ -f "$HOME/.profile" ] && . "$HOME/.profile" +# [ -f "$HOME/.profile" ] && . "$HOME/.profile" [ -f /etc/ksh.kshrc ] && . /etc/ksh.kshrc [ -f "$HOME/.config/ksh/dirs" ] && . "$HOME/.config/ksh/dirs" # [ -f "$HOME/.config/ksh/pushd" ] && . "$HOME/.config/ksh/pushd" diff --git a/.local/bin/pn b/.local/bin/pn index 78163aa..682fdcd 100755 --- a/.local/bin/pn +++ b/.local/bin/pn @@ -1,33 +1,41 @@ #!/bin/sh -args="$( -printf "%q " \ -"--init" \ -"--entrypoint=/usr/local/bin/oksh" \ -"--env=TERM=xterm-ghostty" \ -"--env=EDITOR=vis" \ -"--volume=$TERMINFO/78/xterm-ghostty:/usr/share/terminfo/x/xterm-ghostty" \ -"--env=_ZO_DATA_DIR=/hostfs/.local/share/zoxide" \ -"--volume=/etc/profiles/per-user/ivi/etc/profile.d:/etc/profiles/per-user/ivi/etc/profile.d" \ -"--env=SHELL=/usr/bin/nu" \ -"--env=DISPLAY" \ -"--env=XDG_RUNTIME_DIR" \ -"--volume=$HOME/.ssh/known_hosts:$HOME/.ssh/known_hosts" \ -"--volume=/run/pcscd/pcscd.comm:/run/pcscd/pcscd.comm" \ -"--hostname=$(hostname)" \ -"--env=STARSHIP_CONFIG=/hostfs/.config/starship.toml" \ -"--env=HOME" \ -"--volume=${HOME}:${HOME}" \ -"--workdir=${PWD:-$HOME}" \ -"--volume=${HOME}/.ssh:/root/.ssh" \ -"--volume=${XDG_RUNTIME_DIR:-/var/run}/docker.sock:/var/run/docker.sock" \ -"--net=host" -)" +if SOME_VARIABLE=`push.sh 2>/dev/null` +then eval "$SOME_VARIABLE" +else echo "push.sh not installed" >&2; exit 1 +fi -pnsh \ - --pnsh-host-bindfs-disabled \ - --pnsh-docker-extra-args="$args" \ - --with-docker \ +# Append arguments that configure pnsh. +da="--pnsh-docker-arg=" +Push args \ + $da--init \ + $da"--env=SHELL=/usr/local/bin/oksh" \ + $da"--env=HOME" \ + $da"--volume=${HOME}:${HOME}" \ + $da"--volume=${HOME}/.ssh:/root/.ssh" \ + $da"--workdir=${PWD:-$HOME}" \ + $da"--hostname=pnsh" \ + $da"--net=host" \ + $da"--env=XDG_RUNTIME_DIR" \ + $da"--env=TERM=xterm-ghostty" \ + $da"--volume=$TERMINFO/78/xterm-ghostty:/usr/share/terminfo/x/xterm-ghostty" \ + $da"--volume=${XDG_RUNTIME_DIR:-/var/run}/docker.sock:/var/run/docker.sock" \ + $da"--workdir=${PWD:-$HOME}" \ + --pnsh-shell=/usr/local/bin/oksh \ --docker-image=okshnew \ --docker-tag=latest \ - -- -l -c "$*" + --with-docker +my_name="$(basename "$0")" +cmd= +if [ $# -gt 0 ] +then if [ x"$my_name" != x"pn" ] + then Push cmd "$my_name" + fi + Push cmd "$@"; Push args -- -l -c "$cmd" +else if [ x"$my_name" != x"pn" ] + then Push cmd "$my_name"; Push args -- -l -c "$cmd" + fi +fi + +eval "set -- $args" +exec pnsh "$@" diff --git a/.local/bin/push.sh b/.local/bin/push.sh new file mode 100755 index 0000000..b48e59c --- /dev/null +++ b/.local/bin/push.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env cat +# Push, Encodes arrays correctly as strings with Posix Shell only. +# Meaning we can use this script in any Posix shell (bash, zsh, ksh, dash, ...). +# +# taken from: https://github.com/vaeth/push/blob/main/bin/push.sh +Push() { + case $1 in + -c) + PushA_= + shift;; + *) + eval PushA_=\$$1;; + esac + PushB_=$1 + shift + for PushE_ + do [ -z "${PushA_:++}" ] || PushA_="$PushA_ " + unset PushF_ + case ${PushE_:-=} in + [=~]*) + PushF_=false;; + esac + PushC_=$PushE_ + while PushD_=${PushC_%%\'*} + do if ${PushF_-:} && case $PushD_ in + *[!-+=~@%/:.,_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*) + false;; + esac + then PushA_=$PushA_$PushD_ + else PushA_="$PushA_'$PushD_'" + unset PushF_ + fi + [ x"$PushD_" = x"$PushC_" ] && break || \ + PushA_=$PushA_\\\' + PushC_=${PushC_#*\'} + done + done + eval "$PushB_=\$PushA_ + unset PushA_ PushB_ PushC_ PushD_ PushE_ + [ -n \"\${$PushB_:++}\" ]" || return 1 +} diff --git a/.local/bin/pwd-short b/.local/bin/pwd-short index a4a1500..e791866 100755 --- a/.local/bin/pwd-short +++ b/.local/bin/pwd-short @@ -1,4 +1,13 @@ #!/bin/sh +parts="$( +for d in $(pwd); do + [ -z "$d" ] && continue + IFS= + echo "$d" | head -c3 + echo +done +)" + printf '%s' $( IFS=/ parts="$( |
