From 3145010306902a8b9e0a5863527837aa963afef5 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Fri, 21 Jun 2024 22:37:33 +0200 Subject: checkpoint --- config/essentials/vis/visrc.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'config/essentials/vis/visrc.lua') diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 7847784..e35b436 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -125,9 +125,28 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a if win.syntax == "bash" then map_keys( m.NORMAL, - " v", + ";p", "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/", "Print variable" ) + map_keys( + m.NORMAL, + ";v", + "V:x/^(\\s*)(.+)$/ c/\\1\"$(\\2)\"/", + "Surround in variable" + ) + map_keys( + m.NORMAL, + ";|", + "V:x/\\| / c/|\n\t/", + "Wrap one-line multi pipe command" + ) + map_keys( + m.NORMAL, + ";e", + "V:x/^(\\s*)(.+)$/ c/\\1[ \"\\2\" ] || exit 1/", + "Condition exit if empty" + ) + end end) -- cgit v1.2.3 From 30f72f36d20e9757eddcd71301403920779f31d6 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 22 Jun 2024 13:49:00 +0200 Subject: checkpoint --- bin/common/askpass | 8 ++++++-- bin/common/gt | 4 ++-- bin/extra/myalscore.sh | 3 ++- config/essentials/shell/aliases.sh | 4 ++-- config/essentials/vis/visrc.lua | 30 +++++++++++++----------------- 5 files changed, 25 insertions(+), 24 deletions(-) (limited to 'config/essentials/vis/visrc.lua') diff --git a/bin/common/askpass b/bin/common/askpass index 2725dbf..c7d2249 100755 --- a/bin/common/askpass +++ b/bin/common/askpass @@ -3,11 +3,15 @@ # 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 and use the final name of the key -# find the according password. +# 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/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/vis/visrc.lua b/config/essentials/vis/visrc.lua index e35b436..9bc18f9 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, "", 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") @@ -129,24 +132,17 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/", "Print variable" ) - map_keys( - m.NORMAL, - ";v", - "V:x/^(\\s*)(.+)$/ c/\\1\"$(\\2)\"/", - "Surround in variable" - ) - map_keys( - m.NORMAL, - ";|", - "V:x/\\| / c/|\n\t/", - "Wrap one-line multi pipe command" - ) + map_keys(m.NORMAL, ";v", 'V:x/^(\\s*)(.+)$/ c/\\1"$(\\2)"/', "Surround in variable") + map_keys(m.NORMAL, ";|", "V:x/\\| / c/|\n\t/", "Wrap one-line multi pipe command") map_keys( m.NORMAL, ";e", - "V:x/^(\\s*)(.+)$/ c/\\1[ \"\\2\" ] || exit 1/", + 'V:x/^(\\s*)(.+)$/ c/\\1[ "\\2" ] || exit 1/', "Condition exit if empty" ) - + map_keys(m.NORMAL, ";sc", ":-/\\/,/\\/", "Expand to case") + map_keys(m.NORMAL, ";sw", ":-/\\/", "Expand to while") + map_keys(m.NORMAL, ";sf", ":-/\\/,/\\/", "Expand to for") + map_keys(m.NORMAL, ";si", ":-/\\/,/\\/", "Expand to if") end end) -- cgit v1.2.3 From 364ad8e2c66b35dc893cf379956beeea0972c23d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 22 Jun 2024 15:51:37 +0200 Subject: checkpoint --- bin/extra/wd | 24 +++++++++++------------- checkpoint.sh | 2 +- config/essentials/vis/visrc.lua | 1 + 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'config/essentials/vis/visrc.lua') 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[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/checkpoint.sh b/checkpoint.sh index 62c138c..e2ee407 100755 --- a/checkpoint.sh +++ b/checkpoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -git commit -m 'checkpoint' +git commit -a -m 'checkpoint' keyadd db git push diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 9bc18f9..04d4792 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -123,6 +123,7 @@ vis.events.subscribe(vis.events.INIT, function() end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args + vis:info(win.file.name) win.options.relativenumbers = true if win.syntax == "bash" then -- cgit v1.2.3 From fcc378109f2c9d3f80a6213646d7c170dd93100d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 22 Jun 2024 16:22:29 +0200 Subject: checkpoint --- config/essentials/vis/visrc.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'config/essentials/vis/visrc.lua') diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 04d4792..a763edc 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -123,7 +123,12 @@ vis.events.subscribe(vis.events.INIT, function() end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args - vis:info(win.file.name) + -- 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 -- cgit v1.2.3