OpenSSH in Windows Terminal open in the same directory

Advertisement

toshiki
Joined:
Posts:
4

OpenSSH in Windows Terminal open in the same directory

Hi, I'm using WinSCP v6.3.1. I want to use OpenSSH in Windows Terminal and open it in the same directory. I followed this article (https://winscp.net/eng/docs/integration_putty#wt). However, it seems that the command there can't treat paths with spaces. The path seems to be truncated after the first space. I tried
"C:\Users\Arsci\AppData\Local\Microsoft\WindowsApps\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\wt.exe" -w 0 ssh.exe !U@!@ -p !#  -t "cd '!/' \; /bin/bash --login"
i.e. adding single quotes. But it still doesn't work.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: OpenSSH in Windows Terminal open in the same directory

Single quotes do work for me, like this:
wt.exe ssh.exe !U@!@ -p !#  -t "cd '!/' \; /bin/bash --login"
If it does not work for you, we need more details. What error/problem are you getting? What system are you connecting to?

Reply with quote

toshiki
Joined:
Posts:
4

Thank you. I don't get any error messages. I was logged in to the cluster and was put in the directory I specified in ~/.bashrc. I deleted the cd command in .bashrc and now it works. I guess this is the expected behavior?

The thing is, I've always been using PiTTY where it works even if I specify a starting directory in .bashrc. Now, I can get the desired behavior by changing my .bashrc, but then I won't be in the directory I want when I don't use WinSCP. Is there a way to make it work without modifying bashrc? Or I wonder if I can modify .bashrc in a way that distinguishes the two login scenario..

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

I assume you can do something like this:
wt.exe ssh.exe !U@!@ -p !#  -t "cd '!/' \; export DONTCD=1; /bin/bash --login"
(edited)
And then in .bashrc don't do cd, when the DONTCD is set.

Reply with quote

toshiki

wt.exe ssh.exe !U@!@ -p !#  -t "cd '!/' \; DONTCD=1 \; /bin/bash --login"
I tried this command, but it seems that DONTCD is undefined when .bashrc is executed. If I echo $DONTCD in .bashrc, it's empty.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum