Forth colon

I like the simplicity of prl/ForthLang, especially the succint nature of the prl/ForthColon word. I wrote something similar for BashShell, which is as follows:
#!/bin/bash
# This is Forth's famous colon
# Each arg is a command with parameters as a literal string
# e.g.
# $ d hello 'echo hello world' 'echo fluffy bunny' 'echo "$0"'
A="$1" ; shift
if [ -e "$A" ]; then echo "$A already exists."; exit 1; fi
echo '#!/bin/bash' > "$A" || exit 2
I=11
while [ -n "$1" ]; do
echo "$1" >> "$A" || exit $((I))
shift
((I++))
done
which I call 'd' use invoke as
d cmd 'line1' 'line2' ...
for example
d qdsk 'qemu-img create -f qcow2 "$@"'
is a shorthand for creating qcow2 images, so I need only type
qdsk myos1.img 5G
to create an image.

In general I create new shorthands very often, sometimes in separate folders. I then have a UsefulBashFunction to prepend the current folder to the path, or a specified folder. (This must be a function, or course.) Thus I can use folders of scripts in lieu of prl/ForthLang's system of prl/WordList's.

Make executable

I then have
#!/bin/bash
chmod a+rx "$@"
under the name 'cx' so I can make a script executable via 'cx scriptname'.

Symbolic link helper

Making absolute symbolic links to relatively named files is useful. I use this script to do this.
#!/bin/bash
declare -a A=("$@")
N="${#A[@]}"
M=$((N-1))
T="${A[$M]}"
unset A[$M]
for s in "${A[@]}"; do
if [ -e "$s" ]; then
ln -s "$(readlink -f "$s")" "$T"
fi
done
which you use via
lns file1 file2 file3 ... filen target
and it also serves as a useful reference to using BashArray's

Udisks mount helpers

I tend to have automount disabled by default, and work a lot from the command line. To save typing, I have the following four scripts. The first guesses the block device for its argument, for example:
guessbd d1
will return /dev/sd1 if that devnode is present;
guessbd /media/myuser/MountPoint
will return the devnode for the device mounted there. What this is in aid of is that I can type
udm c1 d1 e2
rather than
udisksctl mount -b /dev/sdc1
udisksctl mount -b /dev/sdd1
udisksctl mount -b /dev/sde2
and finally lb is a one-liner for lsblk -f.

So guessbd:

#!/bin/bash
f() {
	# if argument is a block device, echo it and exit
	if [ -b "$1" ]; then
		echo "$1"
		exit 0
	fi
}
f "$1"          
f "/dev/$1"     
f "/dev/sd$1"
if [ -e "$1" ]; then
	# If we get here, then presume the argument names a file or directory
	# and find the block device for the filesystem containing it.
	A="$(df "$1" | tail -n1 | cut -f1 -d\ )"
	f "$A"
fi
echo "Failed to guess block device for '$1'"
exit 1
This then facilitates udm
#!/bin/dash

do_one() {
    local BD
    if BD="$(guessbd "$1")"; then
        echo Mounting "$BD"
        udisksctl mount -b "$BD"
    else
        echo Cannot mount "$1"
    fi
}

for s; do do_one "$s"; done
and the corresponding unmounter udu
#!/bin/dash

do_one() {
    local BD
    if BD="$(guessbd "$1")"; then
        echo Unmounting "$BD"
        udisksctl unmount -b "$BD"
    else
        echo Cannot unmount "$1"
    fi
}

for s; do do_one "$s"; done

X11 clipboard helpers

I use the xsel package for this. I name these two pc and pp, for 'pasteboard copy' and 'pasteboard paste' respectively. (On cygwin and macosx I have equivalent scripts which use /dev/clipboard and pbcopy/pbpaste respectively.)
#!/bin/dash
xsel -i -b # send stdin to clipboard
#!/bin/dash
xsel -o -b # send clipboard to stdout