Nautilus alias with variable

Hi,

When I run the following in terminal, nautilus comes up normally and connects me to the server:

Code

nmcli con up id pfSense; nautilus 'sftp://nextcloud/root

But when I create the following as alias and run it with sftpv nextcloud I get 2 error messages:

alias sftpv="nmcli con up id pfSense; nautilus 'sftp://${1}/root'"

image

image

I just don’t quite understand why my variable doesn’t work in this case.
I created the same with ssh and there the variable works

When you use '(single quotes) ${1} doesn’t get expanded. Try it without the single quotes.

Does this work?

alias sftpv="nmcli con up id pfSense; nautilus \"sftp://${1}/root\""

EDIT: Actually, can you use $1 in an alias by default in bash? I don’t think you can.

You can use a function instead.

unalias sftpv
function sftpv() { nmcli con up id pfSense; nautilus "sftp://${1}/root"; }
1 Like

so the ssh command works, only the nautilus command does not
alias sshv="nmcli con up id pfSense; ssh ${1}"

no it does not work

can i write the function in bashrc and call it via sftpv?

Yes.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.