One argument, two places
Ishe Chinyoka
Much of my day ends with copying a folder to my drive. The command is always the same shape:
rclone sync Audiobooks drive:Library/Audiobooks --progressAs a bookmark in The Textsmith it has two places, the folder here and the folder on the drive:
#send: rclone sync <from> drive:Library/<to> --progressSo I would type send Audiobooks Audiobooks. Nearly every time the two
names were the same, but not always, so a single place used twice,
<dir> ... <dir>, would have taken away the one time they differ.
My first idea was a shortcut: a trailing period, send Audiobooks., to mean
“use this word for every argument”. But in the shell a period already means
something, the current folder, and a real name can end in one. A shortcut
that quietly changes what a word means is how the wrong folder gets synced.
A default that names another place
The Textsmith already had default values: <disk:/dev/sdb> fills in
/dev/sdb when you leave it out. The answer was to let the default be
another place:
#send: rclone sync <from> drive:Library/<to:<from>> --progress<to:<from>> reads “to, which is from unless I say otherwise”. Now:
send Audiobooks rclone sync Audiobooks drive:Library/Audiobooks --progress
send Audiobooks Books rclone sync Audiobooks drive:Library/Books --progressThe meaning is written in the bookmark itself, where I can read it, and the way I type the call has not changed. Tab completion and the error messages explain it too: “send takes 1 to 2 arguments: from, to defaults to from”.
The default can also add to the other place. A quick backup:
#bk: cp <file> <to:<file>.bak>
bk notes.txt cp notes.txt notes.txt.bakAnd when the bookmarks are exported as shell functions, for other terminals,
to falls back to the first argument there as well.
The bookmarks chapter of the manual has the rest.