Use a shell script instead of an alias.
in ~/.bashrc:
export PATH="$PATH":~/bin
your script in ~/bin/runthat:
#!/bin/bash
sudo nohup /path/to/binary > /dev/null 2>&1 &
Then to run it, just do it like:
$ runthat
Or if you skipped the PATH step, then run it like:
$ ~/bin/runthat
If this is a system-wide (all users) script instead of just you, then put it in /usr/local/bin instead.
Or also you could use a function. eg. in ~/.bashrc:
runthat() {
sudo nohup /path/to/binary > /dev/null 2>&1 &
}
Also just FYI and not a direct answer to the question, another alternative is to put it in the sudoers file:
sudo visudo
(your editor pops up here)
username ALL=NOPASSWD: /path/to/binary
And now it won't ask for a password at all. (which means lower security... maybe some security exploit will now let malware run this app too... so make sure you accept that small risk)
&
when you're already usingnohup
?