diff options
-rwxr-xr-x | bin/common/askpass | 17 | ||||
-rwxr-xr-x | bin/common/gt | 4 | ||||
-rwxr-xr-x | bin/extra/myalscore.sh | 3 | ||||
-rwxr-xr-x | bin/extra/wd | 24 | ||||
-rwxr-xr-x | bin/menuscripts/mpass | 2 | ||||
-rwxr-xr-x | checkpoint.sh | 2 | ||||
-rw-r--r-- | config/essentials/git/config | 2 | ||||
-rw-r--r-- | config/essentials/shell/aliases.sh | 4 | ||||
-rw-r--r-- | config/essentials/shell/functions.sh | 14 | ||||
-rw-r--r-- | config/essentials/vis/visrc.lua | 29 | ||||
-rw-r--r-- | config/home/.mbsyncrc | 50 | ||||
-rw-r--r-- | config/home/.zshenv | 3 |
12 files changed, 115 insertions, 39 deletions
diff --git a/bin/common/askpass b/bin/common/askpass new file mode 100755 index 0000000..c7d2249 --- /dev/null +++ b/bin/common/askpass @@ -0,0 +1,17 @@ +#!/bin/sh + +# We can figure out the password for the key based on $1 +# which is in the following form: +# Enter passphrase for key 'path/to/key': +# The point is to retrieve the path where the filename is the name of +# the key. +# Then we can construct the path for pass and get the password. +key="$(printf '%s\n' "$1" | + cut -f 2 -d \' | + awk -F '/' '{print $NF}')" +pass="keys/$(hostname)/ssh/$key" + +# optional: add key to running ssh-agent +keyadd "$key" & + +pass show "$pass" | head -n 1 diff --git a/bin/common/gt b/bin/common/gt index c679b23..ceb58a8 100755 --- a/bin/common/gt +++ b/bin/common/gt @@ -15,10 +15,10 @@ help() { usage: gt [OPTION] -a PATH add repo -s update and show status of each repo --c COMMAND run 'git COMMAND' in each repo +-c COMMAND run 'git COMMAND' in each repo -h show this help -l list repos --e edit repos in $EDITOR +-e edit repos in \$EDITOR EOF } diff --git a/bin/extra/myalscore.sh b/bin/extra/myalscore.sh index ef68bcc..e2b4e25 100755 --- a/bin/extra/myalscore.sh +++ b/bin/extra/myalscore.sh @@ -4,4 +4,5 @@ query="$(printf '%s' "$*" | sed 's/\s/%20/g')" curl -s "https://myanimelist.net/search/prefix.json?type=all&keyword=$query&v=1" \ -H 'Accept: application/json, text/javascript, */*; q=0.01' | - jq -r '.categories[].items[] | [.payload.score, .name] | join(" ")' + jq -r '.categories[].items[] | "\(.payload.score)@\(.name)@\(.url)"' | + column -t -l 3 -s '@' diff --git a/bin/extra/wd b/bin/extra/wd index 73bbaf7..1b56aa6 100755 --- a/bin/extra/wd +++ b/bin/extra/wd @@ -1,16 +1,14 @@ #!/bin/sh +[ "$1" ] || exit 1 +dict "$1" | + sed -e '/^ /!d;s/^ //' | + sed -e '/^$/d;s/^[^ ].*$/\o033[1;4;34m&\o033[0m/' | -### Word Definition -# Based on https://askubuntu.com/questions/191125/is-there-an-offline-command-line-dictionary -# -### Installation -# > sudo mkdir -p /usr/share/stardict/dic/ -## Get the dictionaries -# > wget https://web.archive.org/web/20140428003644/http://abloz.com/huzheng/stardict-dic/dict.org/stardict-dictd_www.dict.org_gcide-2.4.2.tar.bz2 -# > wget https://web.archive.org/web/20140428004049/http://abloz.com/huzheng/stardict-dic/misc/stardict-xfardic-gnu-linux-2.4.2.tar.bz2 -## Other dictionaries I'd like to get -# https://foldoc.org/scalar + # foldoc + sed -e '/^ /s/</\o033[2m/g' -e '/^ /s/>/\o033[0m/g' | -sdcv -nj "$1" | - jq -r '.[].definition' | - sed -e '/^$/d;s/^[^ ].*$/\o033[1;4;38m&\o033[0m/' + # webster + sed -r -e 's/ \\\<\w+\>\\//g' -e '/^ *\[[^]]*Webster[^]]*\]/d' | + # replace {} by blue underline + sed -e '/^ /s/{/\o033[4m/g' -e '/^ /s/}/\o033[0m/g' | + tr -d '{}' # remove {} in word definition diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass index 7348321..f513b16 100755 --- a/bin/menuscripts/mpass +++ b/bin/menuscripts/mpass @@ -14,7 +14,7 @@ list_pswds() while [ -d "$store/$file" ] do - choice="$(list_pswds "$store/$file" | dmenu -c -g 4 -l 4)" + choice="$(list_pswds "$store/$file" | commander -c)" [ "$choice" ] || exit 1 [ -z "$file" ] && file="$choice" || file="$file/$choice" done diff --git a/checkpoint.sh b/checkpoint.sh index 62c138c..ba93d17 100755 --- a/checkpoint.sh +++ b/checkpoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -git commit -m 'checkpoint' +git commit -m 'checkpoint' $@ keyadd db git push diff --git a/config/essentials/git/config b/config/essentials/git/config index 99cf21e..2b2b202 100644 --- a/config/essentials/git/config +++ b/config/essentials/git/config @@ -9,7 +9,7 @@ [pull] rebase = false [merge] - ff = false + ff = true [alias] change-commits = "!f() { VAR1=$1; VAR='$'$1; OLD=$2; NEW=$3; echo \"Are you sure for replace $VAR $OLD => $NEW ?(Y/N)\";read OK;if [ \"$OK\" = 'Y' ] ; then shift 3; git filter-branch --env-filter \"if [ \\\"${VAR}\\\" = '$OLD' ]; then export $VAR1='$NEW';echo 'to $NEW'; fi\" $@; fi;}; f " [commit] diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index ddc605a..7ddd2f2 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -147,7 +147,6 @@ alias mdb='mariadb -u admin -ppass admindb' alias mdbw='mariadb -h 0.0.0.0 -u padmin -pbulbizarre padmindb' alias mdbwa='mariadb -h 10.3.50.5 -u padmin -pbulbizarre padmindb' alias tmux='pgrep tmux && tmux attach || tmux new-session' -alias wd='dict' # ssh alias sha='ssh-add' @@ -184,7 +183,7 @@ alias kll='killall' alias pi='ping 9.9.9.9 -c4' alias sba='source env/bin/activate || source bin/activate' -alias zsr='source ${ZDOTDIR:-~}/.zshrc && rehash' +alias zsr='exec zsh' alias rh='rehash' alias wf='doas wipefs -a' alias dmci="doas make clean install" @@ -250,6 +249,7 @@ alias ehyb='vi ~/.config/hypr/binds.conf' alias ewbj='vi ~/.config/waybar/config.jsonc' alias ewbs='vi ~/.config/waybar/style.css' alias cfd='vi config.def.h' +alias dump='vi ~/notes/dump.md' # /# quick cd
jV}k:!sort -t "'" -k 2
alias cdl='cd ~/dl' alias cdoc='cd ~/docs' diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh index 1b69fbd..27eb33e 100644 --- a/config/essentials/shell/functions.sh +++ b/config/essentials/shell/functions.sh @@ -364,17 +364,3 @@ ffconcat () { ffmpeg -y -f concat -safe 0 -i $tmp -c copy "$1" rm $tmp } - -# wrap ssh and add key if exists -ssh() { - if [ "$#" -gt 1 ] - then - /usr/bin/ssh $@ - return - fi - - grep -E "Host\s+$1" $HOME/.ssh/config > /dev/null 2>&1 && - keyadd "$1" > /dev/null 2>&1 - /usr/bin/ssh "$1" -} - diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 7847784..a763edc 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -26,7 +26,6 @@ local format = require("format") local fzfmru = require("fzf-mru") fzfmru.fzfmru_path = 'grep "^' .. os.getenv("PWD") .. '" | fzf' - -- todo: -- c-scope -- c-tags @@ -83,8 +82,12 @@ end, "Remove trailing whitespace") --- MAPPINGS ------------------------------------- -vis:map(m.NORMAL, "<C-p>", function() vis:command("fzf") end, "Open file with fzf") - +vis:map(m.NORMAL, " pf", function() + vis:command("fzf") +end, "Open file with fzf") +vis:map(m.NORMAL, " pr", function() + vis:command("fzfmru") +end, "Open file with fzf") vis:map(m.NORMAL, " r", function() wrap_restore(vis.command, vis, "e $vis_filepath") @@ -120,14 +123,32 @@ vis.events.subscribe(vis.events.INIT, function() end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args + -- automatically cd in parent dir of file + if win.file and win.file.path then + local dir = win.file.path:match(".*/") + vis:command("cd " .. dir) + end + win.options.relativenumbers = true if win.syntax == "bash" then map_keys( m.NORMAL, - " v", + ";p", "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/<Enter><Escape>", "Print variable" ) + map_keys(m.NORMAL, ";v", 'V:x/^(\\s*)(.+)$/ c/\\1"$(\\2)"/<Enter><Escape>', "Surround in variable") + map_keys(m.NORMAL, ";|", "V:x/\\| / c/|\n\t/<Enter><Escape>", "Wrap one-line multi pipe command") + map_keys( + m.NORMAL, + ";e", + 'V:x/^(\\s*)(.+)$/ c/\\1[ "\\2" ] || exit 1/<Enter><Escape>', + "Condition exit if empty" + ) + map_keys(m.NORMAL, ";sc", ":-/\\<case\\>/,/\\<esac\\>/<Enter>", "Expand to case") + map_keys(m.NORMAL, ";sw", ":-/\\<while/,/\\<done\\>/<Enter>", "Expand to while") + map_keys(m.NORMAL, ";sf", ":-/\\<for\\>/,/\\<done\\>/<Enter>", "Expand to for") + map_keys(m.NORMAL, ";si", ":-/\\<if\\>/,/\\<fi\\>/<Enter>", "Expand to if") end end) diff --git a/config/home/.mbsyncrc b/config/home/.mbsyncrc new file mode 100644 index 0000000..aa8c521 --- /dev/null +++ b/config/home/.mbsyncrc @@ -0,0 +1,50 @@ + +IMAPStore luca@spacehb.net-remote +Host mail.spacehb.net +Port 993 +User luca@spacehb.net +PassCmd "pass websites/spacehb.net/luca@spacehb.net" +AuthMechs LOGIN +SSLType IMAPS +CertificateFile /etc/ssl/certs/ca-certificates.crt + +MaildirStore luca@spacehb.net-local +Subfolders Verbatim +Path /home/aluc/.local/share/mail/luca@spacehb.net/ +Inbox /home/aluc/.local/share/mail/luca@spacehb.net/INBOX + +Channel luca@spacehb.net +Expunge Both +Far :luca@spacehb.net-remote: +Near :luca@spacehb.net-local: +Patterns * !"[Gmail]/All Mail" !"*fts-flatcurve*" !"*virtual*" +Create Both +SyncState * +MaxMessages 0 +ExpireUnread no +# End profile + +IMAPStore billy@spacehb.net-remote +Host mail.spacehb.net +Port 993 +User billy@spacehb.net +PassCmd "pass websites/spacehb.net/billy@spacehb.net" +AuthMechs LOGIN +SSLType IMAPS +CertificateFile /etc/ssl/certs/ca-certificates.crt + +MaildirStore billy@spacehb.net-local +Subfolders Verbatim +Path /home/aluc/.local/share/mail/billy@spacehb.net/ +Inbox /home/aluc/.local/share/mail/billy@spacehb.net/INBOX + +Channel billy@spacehb.net +Expunge Both +Far :billy@spacehb.net-remote: +Near :billy@spacehb.net-local: +Patterns * !"[Gmail]/All Mail" !"*fts-flatcurve*" !"*virtual*" +Create Both +SyncState * +MaxMessages 0 +ExpireUnread no +# End profile diff --git a/config/home/.zshenv b/config/home/.zshenv index a87f01d..34a7c2f 100644 --- a/config/home/.zshenv +++ b/config/home/.zshenv @@ -96,3 +96,6 @@ export PATH="$PATH:$GOPATH/bin" export PLAN9=/usr/lib/plan9 export PATH="$PATH:$PLAN9/bin" + +export SSH_ASKPASS=askpass +export SSH_ASKPASS_REQUIRE=prefer |