Not an elegant solution, but it may serve your use case (and it's definitely how I would solve it myself).
You can create a bash script that overrides the mount
command as an alias, checking the arguments and doing what you need when that exact argument is passed, falling back to the actual mount
command when anything else is passed.
Have a look at this script:
#!/bin/bash
mount_disk1 () {
disk1="/dev/disk/by-uuid/84ea2a10-abcd-abcd-abcd-06deabcdabcd"
sudo cryptsetup luksOpen "${disk1}" disk1-crypt
sudo mount /dev/mapper/disk1-crypt /mnt/disk1
}
[[ "$@" == "disk1" ]] && mount_disk1 \
|| mount "$@"
Here you have a function that does what you want. If the only thing you pass into it is disk1
it will execute that function, else it'll execute the original mount
passing all arguments.
You can put this script in a folder and set an alias in your ~/.bashrc
or ~/.zshrc
using
alias mount='<path to script>'
Then if you want to use the original mount
, you can run \mount
in the terminal.
Hope it helps!