diff options
| author | Mike Vink <ivi@vinkies.net> | 2025-02-24 19:51:47 +0000 |
|---|---|---|
| committer | Mike Vink <ivi@vinkies.net> | 2025-02-24 19:52:04 +0000 |
| commit | e32edc85c4aad654f6680f486f0e55a8d845806d (patch) | |
| tree | 19e6c3d8ce30ccc2b5b87bf711319788e58b8d40 | |
| parent | 6414c916ee871ef11ef035e40837a8126f2d64a7 (diff) | |
use ksh dirs
| -rwxr-xr-x | .config/ksh/dirs | 15 | ||||
| -rw-r--r-- | .config/ksh/ksh.kshrc | 11 | ||||
| -rw-r--r-- | .config/shell/aliasrc | 2 | ||||
| -rw-r--r-- | .config/shell/bm-dirs | 15 | ||||
| -rw-r--r-- | .config/shell/profile | 2 | ||||
| -rw-r--r-- | .config/vis/visrc.lua | 5 | ||||
| -rw-r--r-- | .kshrc | 2 | ||||
| -rwxr-xr-x | .local/bin/shortcuts | 42 |
8 files changed, 82 insertions, 12 deletions
diff --git a/.config/ksh/dirs b/.config/ksh/dirs index be5982d..a6931b1 100755 --- a/.config/ksh/dirs +++ b/.config/ksh/dirs @@ -92,6 +92,7 @@ function _cd function mcd { typeset dir="${PWD#$HOME/}" + integer i=0 case $dir in $HOME) dir=\~ @@ -99,10 +100,14 @@ function mcd /*) ;; *) dir=\~/$dir esac - PS3='Select by number or enter a name: ' - select dir in "$dir" "${_push_stack[@]}" - do if _cd $REPLY - then return - fi + + REPLY=$( + { + echo "1) $dir" + while (( i < (_push_max - _push_top) )) + do echo "$(( i + 2 ))) ${_push_stack[_push_top + i]}" + i=i+1 done + } | vis-menu -p 'Hoist:' | cut -d')' -f1) + [ -z "$REPLY" ] || _cd "$REPLY" } diff --git a/.config/ksh/ksh.kshrc b/.config/ksh/ksh.kshrc index 6ce52ae..ed183e8 100644 --- a/.config/ksh/ksh.kshrc +++ b/.config/ksh/ksh.kshrc @@ -9,7 +9,8 @@ lfcd () { [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi } -bind -m ^O=' lfcd^J' +bind -m ^O=' mcd^J' +bind -m ^X^F=' REPLY="$(vis-open .)"; [ -z "$REPLY" ] || cd "$REPLY"^J' # Emacs mode clear chops off multline prompts. export PS1="$(hostname):/\$( @@ -22,10 +23,16 @@ pwd | cut -d'/' -f2- --output-delimiter ' )\$(prompt-git)\$(prompt-tf)\n jobs(\j) # " bind -m ^L="^A^K clear^J" -eval "$(zoxide init posix --cmd cd --hook prompt)" +# eval "$(zoxide init posix --cmd cd --hook prompt)" export HISTFILE="$HOME/.history" export HISTCONTROL=ignorespace export HISTSIZE=100000 + +[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" +[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" +[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" +[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" + set -o emacs diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc new file mode 100644 index 0000000..613e843 --- /dev/null +++ b/.config/shell/aliasrc @@ -0,0 +1,2 @@ +alias \ + ref="shortcuts >/dev/null; . ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; . ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" diff --git a/.config/shell/bm-dirs b/.config/shell/bm-dirs new file mode 100644 index 0000000..2e1152f --- /dev/null +++ b/.config/shell/bm-dirs @@ -0,0 +1,15 @@ +# You can add comments to these files with # +cf ${XDG_CONFIG_HOME:-$HOME/.config} +sd $HOME/.local/src/dotfiles +D ${XDG_DOWNLOAD_DIR:-$HOME/Downloads} +d ${XDG_DOCUMENTS_DIR:-$HOME/Documents} +dt ${XDG_DATA_HOME:-$HOME/.local/share} +rr $HOME/.local/src +h $HOME +m ${XDG_MUSIC_DIR:-$HOME/Music} +mn /mnt +pp ${XDG_PICTURES_DIR:-$HOME/Pictures} +sc $HOME/.local/bin +src $HOME/.local/src +vv ${XDG_VIDEOS_DIR:-$HOME/Videos} + diff --git a/.config/shell/profile b/.config/shell/profile index a6b3c48..eff95c1 100644 --- a/.config/shell/profile +++ b/.config/shell/profile @@ -13,3 +13,5 @@ alias s="{ git status --short ; git log --oneline @{push}.. ; }" alias d="docker " alias k="kubectl " alias t="terraform " + +[ ! -f "$XDG_CONFIG_HOME/shell/shortcutrc" ] && setsid -f shortcuts >/dev/null 2>&1 diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua index 452ebc0..482e822 100644 --- a/.config/vis/visrc.lua +++ b/.config/vis/visrc.lua @@ -93,11 +93,8 @@ local pcwd = function() return parent_cwd end -vis:map(m.NORMAL, "<C-x>~", function() +vis:map(m.NORMAL, "<C-x><C-d>", function() vis:command("cd " .. pcwd()) - return true; -end) -vis:map(m.NORMAL, "<C-x>_", function() local code, result, err = vis:pipe("vis-open .") if result then vis:command("e " .. result) @@ -1,6 +1,6 @@ [ -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/dirs" ] && . "$HOME/.config/ksh/dirs" # [ -f "$HOME/.config/ksh/pushd" ] && . "$HOME/.config/ksh/pushd" # [ -f "$HOME/.config/ksh/popd" ] && . "$HOME/.config/ksh/popd" [ -f "$HOME/.config/ksh/ksh.kshrc" ] && . "$HOME/.config/ksh/ksh.kshrc" diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts new file mode 100755 index 0000000..4d53bc5 --- /dev/null +++ b/.local/bin/shortcuts @@ -0,0 +1,42 @@ +#!/bin/sh + +bmdirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" +bmdirs_dir="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs.d" +bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files" + +# Output locations. Unactivated progs should go to /dev/null. +shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" +shell_env_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" +zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" +lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc" +vim_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim" +qute_shortcuts="/dev/null" +fish_shortcuts="/dev/null" +vifm_shortcuts="/dev/null" + +# Remove, prepare files +rm -f "$shell_env_shortcuts" "$lf_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" 2>/dev/null +printf "alias " > "$shell_shortcuts" + +# Format the `directories` file in the correct syntax and sent it to all three configs. +eval "echo \"$(cat "$bmdirs"; for i in "$bmdirs_dir"/*; do cat $i; done)\"" | \ +awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); + printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" }" +# " printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; +# printf(\"abbr %s \42cd %s; and ls -A\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; +# printf(\"map g%s :cd %s<CR>\nmap t%s <tab>:cd %s<CR><tab>\nmap M%s <tab>:cd %s<CR><tab>:mo<CR>\nmap Y%s <tab>:cd %s<CR><tab>:co<CR> \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ; +# printf(\"config.bind(';%s', \42set downloads.location.directory %s ;; hint links download\42) \n\",\$1,\$2) >> \"$qute_shortcuts\" ; +# printf(\"map C%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ; +# printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$vim_shortcuts\" " + +# Format the `files` file in the correct syntax and sent it to both configs. +# eval "echo \"$(cat "$bmfiles")\"" | \ +# awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); +# printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; +# printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" }" +# " printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; +# printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; +# printf(\"map %s :e %s<CR> \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; +# printf(\"map E%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ; +# printf(\"cmap ;%s %s\n\",\$1,\$2) >> \"$vim_shortcuts\" }" |
