diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-06-25 01:10:02 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-06-25 01:10:02 +0200 |
commit | 44c011c5988077b515204159b6930c69c0475571 (patch) | |
tree | 8e441b3c7b8de05f7a92e0bcf61959713bf1edf8 | |
parent | 58ba99570d0bdbb41b5c7c8f2a0c53ea9299ea4c (diff) |
checkpoint
-rwxr-xr-x | bin/guiscripts/osurf-fill | 46 | ||||
-rw-r--r-- | config/essentials/vis/visrc.lua | 10 | ||||
-rw-r--r-- | config/essentials/zsh/.zshrc | 7 | ||||
-rw-r--r-- | config/essentials/zsh/widgets.zsh | 11 |
4 files changed, 40 insertions, 34 deletions
diff --git a/bin/guiscripts/osurf-fill b/bin/guiscripts/osurf-fill index 6ea8e7e..52a410d 100755 --- a/bin/guiscripts/osurf-fill +++ b/bin/guiscripts/osurf-fill @@ -1,10 +1,11 @@ #!/bin/sh -# Fills a password for a given website +# Fills a password for a given website # original script by Avalon Williams (avalonwilliams@protonmail.com) # This version uses the window id to know the url of the surf window # and to know which fifo it must use. Then it injects javascript code. # that will fill the forms with the credentials +printf '\n\n' # dependencies: # - surf fifo patch (http://surf.suckless.org/patches/fifo/) @@ -13,10 +14,9 @@ # $1: winid -fifodir="$HOME/.config/surf/fifo" -if [ -z "${winid:=$1}" ] -then - winid="$(osurfls | dmenu -c -F -i | cut -f1 -d' ')" +fifodir="$HOME/.config/surf/fifo" +if [ -z "${winid:=$1}" ]; then + winid="$(osurfls | dmenu -c -F -i | cut -f1 -d' ')" fi [ "$winid" ] || exit 1 fifo="$fifodir/$winid" @@ -24,26 +24,24 @@ fifo="$fifodir/$winid" # Get only domain name + top-level domain url="$(xprop -id "$winid" _SURF_URI | - cut -f 2 -d'"' | - sed 's,^.*://\([^/]*\)/.*,\1,' | - sed -r -e 's/^([^.]+)\.([^.]+)\.([^.]+)$/\2.\3/')" + cut -f 2 -d'"' | + sed 's,^.*://\([^/]*\)/.*,\1,' | + sed -r -e 's/^([^.]+)\.([^.]+)\.([^.]+)$/\2.\3/')" [ "$url" ] || exit 3 ->&2 printf 'url: %s\n' "$url" +printf >&2 'url: %s\n' "$url" # get pass with url and ask if multiple are found pass="$({ find $PASSWORD_STORE_DIR/websites/ -type f -name '*.gpg' | - grep "$url/" || echo; } | head -n 1 | - sed "s,$PASSWORD_STORE_DIR/,,;s/\.gpg$//" | - dmenu -c)" + grep "$url/" || echo; } | head -n 1 | + sed "s,$PASSWORD_STORE_DIR/,,;s/\.gpg$//" | + dmenu -c)" # if dmenu was stopped, exit [ $? -gt 0 ] && exit 4 # if no password was found, search through password store manually with dmenu -if [ -z "$pass" ] -then - store="${PASSWORD_STORE_DIR:-$HOME/.password-store}" - while [ -d "$store/$file" ] - do +if [ -z "$pass" ]; then + store="${PASSWORD_STORE_DIR:-$HOME/.password-store}" + while [ -d "$store/$file" ]; do choice="$(find "$store/$file" \ -maxdepth 1 -mindepth 1 \ -not -name '.*' -type d -printf "%y\t%f\n" -o \ @@ -56,22 +54,24 @@ then done pass="$file" fi ->&2 printf 'pass: %s\n' "$pass" +printf >&2 'pass: %s\n' "$pass" herbe "filling ${pass#websites/}" & # Get password and username in variables with only one call to 'pass' # escape single quotes eval "$(pass show "$pass" | - sed -n "1s/'/'\\\\''/g;1s/.*/password='&'/p;s/^login: \?\(.\+\)/username='\1'/p")" + sed -n "1s/'/'\\\\''/g;1s/.*/password='&'/p;s/^login: \?\(.\+\)/username='\1'/p")" printf '%s : %s\n' "$username" "$password" # Escape quotes and backslashes for javascript javascript_escape() { - printf '%s' "$1" | sed -s 's,['\''"\\\\],\\&,g' + # The string will be inside double quotes + # we need to add 2 backslashes, one for shell (heredoc) and one for javascript + printf '%s' "$1" | sed -s 's,["\\],\\\\&,g' } js() { -cat <<EOF + cat <<EOF function isVisible(elem) { var style = elem.ownerDocument.defaultView.getComputedStyle(elem, null); if (style.getPropertyValue("visibility") !== "visible" || @@ -118,7 +118,7 @@ EOF } printjs() { - js | sed 's,//.*$,,' | tr '\n' ' ' + js | sed 's,//.*$,,' | tr '\n' ' ' } -echo "inject $(printjs)" >> "$fifo" +echo "inject $(printjs)" >>"$fifo" diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 78f7cfe..f9242c8 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -119,10 +119,12 @@ 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 + vis:command_register("cdp", function() + if win.file and win.file.path then + local dir = win.file.path:match(".*/") + vis:command("cd " .. dir) + end + end, "Cd to parent dir of file") win.options.relativenumbers = true diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 5981fd9..63e3d62 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -113,6 +113,13 @@ add-zsh-hook -Uz precmd set_wt (){ print -Pn "\e]0;%n@%m on %~\a"; } ## automatic ls after cd add-zsh-hook -Uz chpwd (){ [ "$PWD" = "$HOME" ] || ls -A; } +bottom_margin() { + TBUFFER="$BUFFER" + BUFFER="\n\n\n" + BUFFER="\n\n\n $TBUFFER" +} +add-zsh-hook -Uz precmd bottom_margin + ### Variables ## Run menuscripts with fzf export MENUCMD='fzf' diff --git a/config/essentials/zsh/widgets.zsh b/config/essentials/zsh/widgets.zsh index 233ea65..cce9fbc 100644 --- a/config/essentials/zsh/widgets.zsh +++ b/config/essentials/zsh/widgets.zsh @@ -1,8 +1,7 @@ # Surround line in variable -surround_in_var() -{ - BUFFER=" \"\$($BUFFER)\"" - zle beginning-of-line +surround_in_var() { + BUFFER=" \"\$($BUFFER)\"" + zle beginning-of-line } zle -N surround_in_var bindkey '\ev' surround_in_var @@ -10,9 +9,7 @@ bindkey '\ev' surround_in_var # Insert output from the previous command zmodload -i zsh/parameter insert-last-command-output() { - LBUFFER+="$(eval $history[$((HISTCMD-1))])" + LBUFFER+="$(eval $history[$((HISTCMD - 1))])" } zle -N insert-last-command-output bindkey "^Xl" insert-last-command-output - -# |