diff --git a/keybinds.h b/keybinds.h index aca3401..1343527 100644 --- a/keybinds.h +++ b/keybinds.h @@ -23,13 +23,14 @@ static Shortcut shortcuts[] = { { CONTROL, XK_p, clippaste, {.i = 0} }, { CONTROL, XK_Num_Lock, numlock, {.i = 0} }, { CONTROL, XK_Escape, keyboardselect, {.i = 0} }, - { CONTROL|SHIFT, XK_C, kexec, {.scmd = "clear" } }, - { CONTROL|SHIFT, XK_H, kexec, {.scmd = "st_help" } }, - { CONTROL|SHIFT, XK_E, kexec, {.scmd = "$EDITOR" } }, - { CONTROL|SHIFT, XK_D, kexec, {.scmd = "$PERM !!" } }, - { CONTROL|SHIFT, XK_F, kexec, {.scmd = "$EDITOR $(find ~/.config -type f | fzf)" } }, - { CONTROL|SHIFT, XK_S, kexec, {.scmd = "$EDITOR $(find ~/Scripts -type f | fzf)" } }, + { CONTROL|SHIFT, XK_H, kexec, {.scmd = ";st_help" } }, + { CONTROL|SHIFT, XK_E, kexec, {.scmd = ";$EDITOR" } }, + { CONTROL|SHIFT, XK_D, kexec, {.scmd = ";$PERM !!" } }, + { CONTROL|SHIFT, XK_F, kexec, {.scmd = ";$EDITOR $(find $HOME/.config -type f | fzf)" } }, + { CONTROL|SHIFT, XK_S, kexec, {.scmd = ";$EDITOR $(find $HOME/Scripts -type f | fzf)" } }, + { CONTROL|SHIFT, XK_W, kexec, {.scmd = ";$PERM make clean install" } }, { CONTROL|SHIFT, XK_K, kscrollup, {.i = -1} }, { CONTROL|SHIFT, XK_J, kscrolldown, {.i = -1} }, { CONTROL|SHIFT, XK_U, externalpipeout,{.v = listurl } }, + { CONTROL|SHIFT, XK_C, externalpipeout,{.v = copyout } }, }; diff --git a/options.h b/options.h index e017735..0cef2b8 100644 --- a/options.h +++ b/options.h @@ -183,6 +183,7 @@ static unsigned int mousebg = 0; /* Background cursor color */ /* Externalpipe commands */ static char *listurl[] = { "/bin/sh", "-c", "st_urllist", NULL }; +static char *copyout[] = { "/bin/sh", "-c", "st_copyout", NULL }; /* URL click command * diff --git a/scripts/st_copyout b/scripts/st_copyout new file mode 100755 index 0000000..0727ba8 --- /dev/null +++ b/scripts/st_copyout @@ -0,0 +1,10 @@ +#!/bin/sh +# original script by Jaywalker and Luke Smith (https://github.com/Lukesmithxyz/st) +tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX) +trap 'rm -f "$tmpfile"' 0 1 15 +sed -n "w $tmpfile" +sed -i 's/\x0//g' "$tmpfile" +ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)" +chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 -w $WINDOWID -g 1 | sed 's/[^^]/[&]/g; s/\^/\\^/g')" +eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')" +awk "/^$chosen$/{p=1;print;next} p&&/$eps1/{p=0};p" "$tmpfile" | xclip -selection clipboard