copy output of command with alt-o

This commit is contained in:
Luke Smith 2019-05-08 11:26:11 -04:00
parent 140c6b0a3f
commit 84d49f527d
No known key found for this signature in database
GPG Key ID: 4C50B54A911F6252
5 changed files with 44 additions and 21 deletions

View File

@ -43,7 +43,9 @@ dist: clean
install: st install: st
mkdir -p $(DESTDIR)$(PREFIX)/bin mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f st $(DESTDIR)$(PREFIX)/bin cp -f st $(DESTDIR)$(PREFIX)/bin
cp -f st-copyout $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/st chmod 755 $(DESTDIR)$(PREFIX)/bin/st
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout
mkdir -p $(DESTDIR)$(MANPREFIX)/man1 mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1 sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
@ -52,6 +54,7 @@ install: st
uninstall: uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/st rm -f $(DESTDIR)$(PREFIX)/bin/st
rm -f $(DESTDIR)$(PREFIX)/bin/st-copyout
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1 rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
.PHONY: all options clean dist install uninstall .PHONY: all options clean dist install uninstall

View File

@ -1,32 +1,33 @@
# Luke's build of st - the simple (suckless) terminal # Luke's build of st - the simple (suckless) terminal
The [suckless terminal (st)](https://st.suckless.org/) with some additional features: The [suckless terminal (st)](https://st.suckless.org/) with some additional features that make it literally the best terminal emulator ever:
## Unique features (using dmenu)
+ *follow urls* by pressing `alt-l`
+ *copy urls* in the same way with `alt-y`
+ *copy the output of commands* with `alt-o`
## Bindings for
+ *scrollback* with `alt-↑/↓` or `alt-pageup/down` or `shift` while scrolling the mouse
+ OR *vim-bindings*: scroll up/down in history with `alt-k` and `alt-j`. Faster with `alt-u`/`alt-d`.
+ *zoom/change font size*: same bindings as above, but holding down shift as well. `alt-home` returns to default
+ *copy text* with `alt-c`, *paste* is `alt-v` or `shift-insert`
## Pretty stuff
+ Compatibility with `Xresources` and `pywal` for dynamic colors. The `Xdefaults` file shows a usage example. + Compatibility with `Xresources` and `pywal` for dynamic colors. The `Xdefaults` file shows a usage example.
+ Default [gruvbox](https://github.com/morhetz/gruvbox) colors otherwise. + Default [gruvbox](https://github.com/morhetz/gruvbox) colors otherwise.
+ Transparency/alpha, which is also adjustable from `~/.Xresources`. + Transparency/alpha, which is also adjustable from your `Xresources`.
+ Default font is system "mono" at 16pt, meaning the font will match your system font. + Default font is system "mono" at 16pt, meaning the font will match your system font.
+ Very useful keybinds including:
+ Copy is alt-c, paste is alt-v or alt-p pastes from primary selection ## Other st patches
+ Alt-l feeds all urls on screen to dmenu, so they user can choose and
follow one (requires dmenu installed).
+ Alt-y does the same as above, but copies the url with xclip.
+ Zoom in/out or increase font size with Alt+Shift+k/j or u/d for larger intervals.
+ Hold alt and press either ↑/↓ or the vim keys k/j to move up/down in the terminal.
+ Shift+Mouse wheel do the same.
+ Alt-u and Alt-d scroll back/forward in history a page at a time.
+ Alt-PageUp and Alt-PageDown will do the same.
+ Vertcenter + Vertcenter
+ Scrollback + Scrollback
+ updated to latest version 0.8.2 + updated to latest version 0.8.2
The following additional bindings were added before I forked this:
+ Scroll through history -- Shift+PageUp/PageDown or Shift+Mouse wheel
+ Increase/decrease font size -- Shift+Alt+PageUp/PageDown
+ Return to default font size -- Alt+Home
+ Paste -- Shift+Insert
## Installation for newbs ## Installation for newbs
``` ```
@ -56,8 +57,7 @@ For example, you can define your desired fonts, transparency or colors:
... ...
``` ```
The `alpha` value (for transparency) goes from `0` (transparent) to `1` The `alpha` value (for transparency) goes from `0` (transparent) to `1` (opaque).
(opaque).
### Colors ### Colors

View File

@ -217,6 +217,8 @@ static char *copyurlcmd[] = { "/bin/sh", "-c",
"sed 's/.*│//g' | tr -d '\n' | grep -aEo '((http|https)://|www\\.)[a-zA-Z0-9./&?=_-]*' | uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard", "sed 's/.*│//g' | tr -d '\n' | grep -aEo '((http|https)://|www\\.)[a-zA-Z0-9./&?=_-]*' | uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard",
"externalpipe", NULL }; "externalpipe", NULL };
static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL };
static Shortcut shortcuts[] = { static Shortcut shortcuts[] = {
/* mask keysym function argument */ /* mask keysym function argument */
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
@ -250,6 +252,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_D, zoom, {.f = -2} }, { TERMMOD, XK_D, zoom, {.f = -2} },
{ MODKEY, XK_l, externalpipe, {.v = openurlcmd } }, { MODKEY, XK_l, externalpipe, {.v = openurlcmd } },
{ MODKEY, XK_y, externalpipe, {.v = copyurlcmd } }, { MODKEY, XK_y, externalpipe, {.v = copyurlcmd } },
{ MODKEY, XK_o, externalpipe, {.v = copyoutput } },
}; };
/* /*

12
st-copyout Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Using external pipe with st, give a dmenu prompt of recent commands,
# allowing the user to copy the output of one.
# xclip required for this script.
# By Jaywalker and Luke
tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX)
trap 'rm "$tmpfile"' 0 1 15
sed -n "w $tmpfile"
ps1="$(grep "\S" "$tmpfile" | tail -n 1 | cut -d' ' -f1)"
chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 | 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

5
st.1
View File

@ -152,6 +152,11 @@ Show dmenu menu of all URLs on screen and choose one to open.
.B Alt-y .B Alt-y
Show dmenu menu of all URLs on screen and choose one to copy. Show dmenu menu of all URLs on screen and choose one to copy.
.TP .TP
.B Alt-o
Show dmenu menu of all recently run commands and copy the output of the chosen command to the clipboard.
.I xclip
required.
.TP
.B Break .B Break
Send a break in the serial line. Send a break in the serial line.
Break key is obtained in PC keyboards Break key is obtained in PC keyboards