shithub: docs.9front.org

ref: b962b3f7da70cc249ae70c77d513a0af0306a154
dir: /tips-and-tricks.md/

View raw version
Tips and tricks
===============

## Opening URLs from 9front on your phone/tablet

One way to do it is to display a QR code and then scan it:

	echo http://some.url.here/blah | qr | resample -x 800% | page

## Rio

Filename completion is available with CTRL+F. To go from anywhere back to the command prompt, use CTRL+B.
More information about shortcuts and keys in general is available in `rio(1)` and `keyboard(6)`.

Command `"` prints the last used command.
`""` _executes_ the last command.
Both accept an optional argument to match a command string, ie:

	term% touch /tmp/1
	term% lc /tmp
	1
	term% "
		term% lc /tmp
	term% ""
		term% lc /tmp
	1
	term% "" to
		term% touch /tmp/1
	term% "" l
		term% lc /tmp
	1

Hint: `grep '^term% ' /dev/text`.

If there is a command you want to run repeatedly, it's easy to define a rc function and use it instead:

	fn t { mk && ./6.out some arguments here >log && grep something log }
	t

To change the function without having to search it in the window, run `whatis t`, then redefine it.
`ls /env/fn*` will show which functions are defined.

To clear the window from any text run `echo >/dev/text`.

If you need to snarf an output of some command, instead of outputting into the window and then using mouse,
consider doing it directly instead: `command arg arg >/dev/snarf`.

Want to do advanced searching on window's text? Run your favorite text editor on it: `sam /dev/text`.

Want to take a screenshot of a window, but no idea which id that window has? Try seaching by its label:
`grep sam /dev/wsys/*/label`. Replace the `label` in the path to `window` and take the screenshot:
`topng </dev/wsys/X/window >/n/mycoolblog.com/www/files/acme.png`.

Having screen image filled up with some random messages on top of rio? Run `window -hide -scroll cat /dev/kprint` in
your `riostart`.

When it gets difficult to work with too many windows on the screen, consider running `winwatch` and using one
nested `rio` per virtual "workspace". If you're into keyboard-controlled window managers with virtual
desktops, try out [riow](https://git.sr.ht/~ft/riow).

## Random facts

`cat input | something >output` or `something <input >output`? Prefer the latter as it requires
less resources. It also allows the `something` program to use `input` as a normal file rather than
a pipe, ie it has random access, while with pipes all it can do is read the file in strictly
sequential order.