Reputation: 4731
I want to make alias to open file with GUI editor on background from command line.
I tried:
alias new_command="editor_path &"
new_command file
But it just open editor without loading the file.
Upvotes: 5
Views: 1793
Reputation: 14786
The & is ending the command, so it is not seeing your file argument. You can't use alias if you want to substitute the filename string into the command with the ampersand on the end.
From the bash manpage:
There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used (see FUNCTIONS below).
Consider creating a shell function:
function new_command
{
editor_path "$1" &
}
Upvotes: 7
Reputation: 20724
You can try something like this:
alias new_command="sudo -b editor_path"
Although you'd need to enter your password.
Upvotes: -1