Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start wsltty terminal in WSL user's home directory and other questions #3

Closed
fpqc opened this issue Sep 16, 2016 · 25 comments
Closed

Comments

@fpqc
Copy link

fpqc commented Sep 16, 2016

I modified the shortcut to start in %localappdata%\lxss\home\fpqc, but for some reason this starts wsltty in the root (/) of the lxss installation rather than the user home /home/fpqc.

Also, is there a way to invoke wsltty from the Run (Win+R) dialog?

Lastly, is there any way as of yet to add functionality similar to @xilun 's cbwin, which allows invoking Windows applications from a WSL instance by calling back over tcp? This functionality is nice, since it allows you to do fun things like run powershell and cmd inside of tmux (although I guess since this is using cygwin, we could just use the cygwin version of tmux and load wslbridge from there instead)?

@mintty
Copy link
Owner

mintty commented Sep 16, 2016

I modified the shortcut to start in %localappdata%\lxss\home\fpqc, but for some reason this starts wsltty in the root (/) of the lxss installation rather than the user home /home/fpqc.

How exactly did you try to achieve that? Actually, the default setup, using bash option -l, should start in your Linux home directory, unless you tweaked your bash profiles.

Also, is there a way to invoke wsltty from the Run (Win+R) dialog?

Hmm, for this a .bat script wrapper would have to invoke what now the shortcut does, and add an -i option to catch the shortcut icon, and be installed in your path, e.g. %windir%\System32. Maybe I'll add such a script.

Lastly, is there any way as of yet to add functionality similar to @xilun 's cbwin, which allows invoking Windows applications from a WSL instance by calling back over tcp? This functionality is nice, since it allows you to do fun things like run powershell and cmd inside of tmux (although I guess since this is using cygwin, we could just use the cygwin version of tmux and load wslbridge from there instead)?

There is the wsl-terminal project that adds a suitable tool for this purpose. It does not install out-of-the-box, on the other hand. If people want wsltty to provide that, it might be considered...

@fpqc
Copy link
Author

fpqc commented Sep 16, 2016

In order to get Mintty to launch in ~, I had to do the following

Change the filepath in the shortcut to:

%localappdata%\wsltty\bin\mintty.exe /bin/wslbridge -e MSD=/home/fpqc -t /bin/bash

(MSD=Mintty Start Dir)

then add an if statement to the .bashrc:

if [ -n "$MSD" ] then cd "$MSD" fi

@fpqc
Copy link
Author

fpqc commented Sep 16, 2016

I guess that writing a script or a batch file with arbitrary parameter passing (and allowing manual location overriding by passing the "MSD" env var argument) could be annoying, but it would then be a fully general solution.

Anyway, excellent project! Excited to see more.

@mintty
Copy link
Owner

mintty commented Sep 16, 2016

Setting MSD is really user-specific and it's out of scope of wsltty what you do in your profile scripts, so I wonder what you think wsltty could do better here (but also why this failed for you in the first place).

@fpqc
Copy link
Author

fpqc commented Sep 16, 2016

@mintty Launching from the desktop shortcut starts in the "starts in" directory, not the ~ directory of wsl.

@mintty
Copy link
Owner

mintty commented Sep 16, 2016

In the standard configuration, it starts in your home directory. If you tweak it, anything can happen.

@fpqc
Copy link
Author

fpqc commented Sep 17, 2016

@mintty I'm sitting here, I reinstalled wsltty, and when I click the link on my desktop, it is starting in C:

Here is a screenshot after a clean install (all I did was change my colorscheme to solarized and increase the font size):
2016-09-17

When I look at the Desktop Shortcut's properties, I see:

2016-09-17 1

as expected.

I am using a brand new unedited .bashrc on a brand new installation of Windows Subsystem for Linux, on a brand new install of wsltty 0.51.

Can you explain what I'm doing wrong, because what you are saying (that it starts in /home/fpqc) is not true.

@lf-
Copy link

lf- commented Sep 18, 2016

I can confirm the issue with the start directory. It's starting in C:. I've tried bash --norc --noprofile -l to no result.

@mintty
Copy link
Owner

mintty commented Sep 18, 2016

I was in fact mistaken by my own profile scripts, sorry. The WSL global scripts in /etc do not cd $HOME as they would often do elsewhere.
Now here is a problem; the start directory cannot be the Linux user directory because the Linux username is not known. Other options are:

  • %LOCALAPPDATA%\lxss\home – less useful
  • %LOCALAPPDATA%\lxss – behaves strangely
  • %USERPROFILE% – maybe this is a good idea because some people might like to work on common folders; and users have a choice to add cd $HOME to their profile anyway

Or the home directory could be enforced by invoking /bin/bash -c "cd; exec bash -l" but I'd rather prefer to keep the target command simple.

@mintty
Copy link
Owner

mintty commented Sep 18, 2016

Released 0.6.0:

  • Adding a wrapper wsl.bat. However, it's only installed in the wsltty installation directory, because copying it to %SYSTEMROOT%\System32 needs admin rights.
  • Start directory in shortcuts changed to %USERPROFILE%. As suggested above, I think this is the best choice for all use cases. If you don't like it from the Linux point of view, it can easily be fixed in your .profile. Fixed README.md to describe this properly.

@mintty mintty closed this as completed Sep 18, 2016
@mintty
Copy link
Owner

mintty commented Sep 28, 2016

There is option -C~ now in wslbridge (rprichard/wslbridge#2 (comment)).
Not sure though whether wsltty should change its shortcut because the current solution is still a good trade-off, together with the hint to adapt your .profile if desired.

@mintty mintty reopened this Sep 28, 2016
@fpqc
Copy link
Author

fpqc commented Sep 28, 2016

I already updated manually the bridge. I think you should change default shortcut tho.

@mintty
Copy link
Owner

mintty commented Sep 28, 2016

My point was that I think offering %USERPROFILE% may actually be a cute idea, and can easily be modified as described, so maybe I should not change the default shortcut?

I could also provide different shortcuts, at least in a Start menu subfolder.

@fpqc
Copy link
Author

fpqc commented Sep 28, 2016

%Userprofile% has the DriveFS, not VolFS. It is formally very different and does not support inotify or permissions.

@mintty
Copy link
Owner

mintty commented Sep 28, 2016

No idea what you mean. It's the name of the user's Windows profile directory, and you can cd to it.

@thejimmyjames
Copy link

In ~/.profile just before the "fi" terminator in the # if running bash code block add cd with no modifiers and it will load the shell in ~

@fpqc
Copy link
Author

fpqc commented Oct 19, 2016

@thejimmyjames There is already a way in wslbridge to do this with a parameter..

@mintty
Copy link
Owner

mintty commented Nov 18, 2016

Revised set of installed shortcuts and command-line scripts in 0.7.0.

@mintty mintty closed this as completed Nov 18, 2016
@mintty
Copy link
Owner

mintty commented Oct 23, 2017

Released 1.8.0, resolving this issue to the bash.exe launcher.

dscho pushed a commit to dscho/mintty that referenced this issue Nov 30, 2018
@georgthegreat
Copy link

georgthegreat commented Nov 14, 2019

I have default shell changed to /usr/bin/zsh and -C~ does not work for me (at least in wsltty=3.0.6).

My command line is as follows:

mintty.exe --WSL= --configdir="..\AppData\Roaming\wsltty" -C~

How do I start shell in $HOME?

@Biswa96
Copy link
Contributor

Biswa96 commented Nov 14, 2019

Replace -C~ with -~.

@georgthegreat
Copy link

Thanks, this works

@tnguyen14
Copy link

@mintty I'm running into something similar here, where my mintty terminal opens up as root user, instead of my own user. If I start the default Ubuntu app, it brings me to my user, which is the default. The same is true when using Windows Terminal. Do I need to configure the starting user (not directory, but user itself) somewhere?

@mintty
Copy link
Owner

mintty commented Jan 21, 2021

Likely a different issue, however, I do not reproduce that. My wsltty WSL session starts in user mode.

@tnguyen14
Copy link

Thank you for the quick response. I've created #270 to ask more question about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants