A bookmark is a command you save once and run by name. The Textsmith keeps
them in one plain text file, bookmarks, one per line, which you can edit
by hand and carry between machines.
Making a bookmark
Type the command as a comment, with a name and a colon in front, then press Alt+M:
#vps: ssh forge
The line is saved as a bookmark called vps. Alt+M on a line without a
label bookmarks it as it is; on an empty line, it bookmarks the last
command you ran. Pressing Alt+M on a bookmark that is already there removes
it. Alt+Shift+M saves the bookmark and runs it at once.
A label can carry a description, which the bookmark list shows:
#vps my server: ssh forge
Running a bookmark
There are three ways, all at your shell’s prompt:
- Alt+Enter. Type the name and its arguments as if it were a command,
vps, and press Alt+Enter instead of Enter. #@. Type#@vpsand press Enter. Tab after#@completes the names and says what each bookmark takes.- The bookmark list. Alt+Shift+B lists every bookmark. Type to filter it, then Enter to run one. A bookmark that needs arguments is put on the command line for you to complete. Ctrl+Enter puts it there to edit; Delete removes it.
Whichever way you use, the command line first shows what will actually run, and that is what goes into your history. A mistake, such as an unknown name or a missing argument, is said on a line of its own and your line stays as it was. Alt+Shift+Enter fills a call in without running it, so you can read the command before pressing Enter.
Places for arguments
<> or <name> marks where an argument goes:
#copy: cp <src> <dst>
copy a.txt backup/ runs cp a.txt backup/
Arguments fill the places in the order they first appear, and are put in
exactly as you typed them, quotes and all. A name used twice gets the same
value both times. To write a real <> in a command, type \<>.
Default values
<name:default> is a place that fills itself in when you leave it out:
#burn: dd if=<iso> of=<disk:/dev/sdb> bs=1M status=progress
burn arch.iso runs dd if=arch.iso of=/dev/sdb ...
burn arch.iso /dev/sdc runs dd if=arch.iso of=/dev/sdc ...
Arguments fill places in order, so a default only helps when every place
after it has a default too. A default can hold spaces and quotes, but not
>.
A default taken from another place
When two arguments are usually the same, but not always, let one default to the other:
#send: rclone sync <from> drive:Library/<to:<from>> --progress
send Music runs rclone sync Music drive:Library/Music --progress
send Music Songs runs rclone sync Music drive:Library/Songs --progress
<to:<from>> reads “to, which is from unless you give it”. The default can
add to the other place: #bk: cp <file> <to:<file>.bak> makes bk notes.txt
copy to notes.txt.bak. When two values are always the same, use one name
twice instead: <dir> ... <dir>.
Any number of arguments
<..> (or <name..>) takes every argument the other places leave over,
none included:
#install: sudo apt install -y <..>
install vim git htop runs sudo apt install -y vim git htop
#cpto: cp -v <..> <dst>
cpto a.txt b.txt backup/ runs cp -v a.txt b.txt backup/
A bookmark has one such place (the same name used again repeats it), and it
can have a default: <opts..:--all-targets>.
Counting arguments
A count in the label says how many arguments a bookmark takes. Without places, the arguments are added at the end:
#copy(2..): cp -v at least two
#l(..1): ls -lF at most one
#install(1..): sudo apt install -y <..> at least one package
Bookmarks at the end of a line
#@ at the end of a command adds a bookmark to it, much like a global alias
in zsh. A bookmark whose label starts with #| is piped into:
#|count: wc -l
#|grab: grep -i <>
ls -1 #@count runs ls -1 | wc -l
find . #@grab todo @count runs find . | grep -i todo | wc -l
After the first #@, further bookmarks only need @.
The bookmarks file
The file is called bookmarks, in The Textsmith’s folder (see
Preferences). Each line is a bookmark exactly as you would
type it, and lines that start with # (a hash and a space) are notes:
# Servers
#vps my server: ssh forge
#site: rsync -rltvP --delete <source> forge:/var/www/<destination>
Edit it with any text editor; The Textsmith reads it again each time it is used. The Electron edition reads the same file.