I would like replace the nano command when I am using a Terminal Session with remote ssh in Visual Studio Code.
Why I need it?
Using different linux server not always I have the code editor available and I am live little frustating mitstakes:
I often write nano when code is available and sometimes I write code in putty.
I would like a special "nano" command / function:
if code is available then execute code
else execute nano
end if
Of course other way are accepted.
thanks
UPDATE: I changed a bit the function and this one works fine.
function nano() {
if [[ $(type -t code) = "file" ]]; then
code "$@"
else
command nano "$@"
fi
}
2
Answers
Maybe the way to do that you want is create a "alias" in the bashrc file of the system.
To open VSCode insteand of Nano if it is installed, this alias has to be created into a if statement.
If vscode is not installed default nano will open. But, if you use different Linux Systems you need to do this configuration at each of them.
Assuming VSCode is installed at /usr/bin/code, try this :