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

Allow integrated terminal to run as login shell #7263

Closed
luchillo17 opened this Issue Jun 6, 2016 · 17 comments

Comments

Projects
None yet
7 participants
@luchillo17
Copy link

luchillo17 commented Jun 6, 2016

  • VSCode Version: 1.2.0
  • OS Version: Ubuntu 16.04

While testing the integrated terminal i realized that my native terminal aliases and custom commands are missing, say i have an alias like alias ll='ls -FGlahp' defined in my .bash_profile which gives me colored folder list with / terminated names for folders, if i try the same in the integrated terminal the output is the following, is it possible to embed the native terminal or config in the integrated one the import to the same config files of the native one?

ll: command not found

Steps to Reproduce:

  1. In Ubuntu just put a custom alias in the config files of your bash session, most likely .bash_profile or .bashrc.
  2. Try to use that new custom alias in the VS Code integrated terminal.
@luchillo17

This comment has been minimized.

Copy link
Author

luchillo17 commented Jun 6, 2016

I've tried to call source ~/.bash_profile and it worked perfectly, maybe if we could configure the source file for the integrated terminal session this would be a finished feature.

@luchillo17

This comment has been minimized.

Copy link
Author

luchillo17 commented Jun 6, 2016

Ok i've been testing and the difference with native and integrated is the fact that i configured the native to Run as login shell, idk if the integrated one has the config option like the native like this in profile:
image

@gertcuykens

This comment has been minimized.

Copy link

gertcuykens commented Jun 7, 2016

+1 for startup command feature so you can launch source ~/.bash_profile automaticlly

@Tyriar

This comment has been minimized.

Copy link
Member

Tyriar commented Jun 7, 2016

Yes currently the terminal runs as a non-login shell, I'll add this to the backlog.

In the meantime, if you don't want differences between login and non-login shells, I recommend moving the .bash_profile contents to your .bashrc and adding the following to your .bash_profile:

# .bash_profile
if [ -r ~/.bashrc ]; then
  . ~/.bashrc
fi

@Tyriar Tyriar added this to the Backlog milestone Jun 7, 2016

@Tyriar Tyriar self-assigned this Jun 7, 2016

@Tyriar Tyriar changed the title [Feat] Integrated terminal missing native configs Allow integrated terminal to run as login shell Jun 7, 2016

@luchillo17

This comment has been minimized.

Copy link
Author

luchillo17 commented Jun 7, 2016

I already have the source to .bashrc in .bash_profile however i will avoid editing the provided .bashrc by the system, i think i will stick to the native one until we can configure the launch of the integrated terminal.

@Tyriar

This comment has been minimized.

Copy link
Member

Tyriar commented Jun 7, 2016

@Luchillo it should be safe to just add their own stuff to the bottom of the default .bashrc file.

@coreh

This comment has been minimized.

Copy link

coreh commented Jun 7, 2016

Workaround:

  1. Create a file named /usr/local/bin/bash-login (or whatever you'd like to name it) and add the following lines to it (You might need root to create that file depending on your setup):
#!/bin/bash
bash -l
  1. Make it executable with chmod +x /usr/local/bin/bash-login.

  2. On your VSCode user settings, set:

{
  "terminal.integrated.shell.linux": "/usr/local/bin/bash-login"
}
  1. Profit

@Tyriar

This comment has been minimized.

Copy link
Member

Tyriar commented Jun 7, 2016

@coreh if adding the -l arg is all there is to it then this should make it into the next release in the form of #7266

@luchillo17

This comment has been minimized.

Copy link
Author

luchillo17 commented Jun 7, 2016

@Tyriar Yes, -l flag, that's all it needs.
Also i won't edit the .bashrc but put all changes in .bash_profile in order to have compatibility with OSX systems, i have my .bash_profile in a repo that saves the changes so that i get similar behaviour in both OSX and Ubuntu, same aliases and OS dependent commands.

@luchillo17

This comment has been minimized.

Copy link
Author

luchillo17 commented Jun 7, 2016

@coreh Awesome workaround, how didn't i tough about it?

@Tyriar

This comment has been minimized.

Copy link
Member

Tyriar commented Jun 14, 2016

Going to close this in favor of #7266 which will allow you to do this in 1.3.0:

{
  "terminal.integrated.shell.linux": "bash",
  "terminal.integrated.shellArgs.linux": [ "-l" ]
}

In the meantime if you want this working on stable you can do the workarounds that myself #7263 (comment) or @coreh #7263 (comment) suiggested.

@luchillo17

This comment has been minimized.

Copy link
Author

luchillo17 commented Jun 14, 2016

Cool.

@tiagolo

This comment has been minimized.

Copy link

tiagolo commented Jul 7, 2016

guys, what about in windows??
Will I be able to do the same with Windows 10 Ubuntu Bash, or Git-Bash?
Anyone can give a tip on creating a .bat file to launch bash as a login shell?

@Tyriar

This comment has been minimized.

Copy link
Member

Tyriar commented Jul 7, 2016

@tiagolo not sure it's even a concept on git bash, for Ubuntu Bash it's all about whether the executable accepts command line arguments, not really a question for us.

@tiagolo

This comment has been minimized.

Copy link

tiagolo commented Jul 7, 2016

@Tyriar actualy the Git-Bash shell has the same issue with the non-login shell, so after some search I could get away with a batch file like this:

@ECHO OFF
"C:\Program Files\Git\bin\bash.exe" --login -i
@kattak2k

This comment has been minimized.

Copy link

kattak2k commented May 9, 2017

Just to help others, to fix the issue on Ubuntu 17.04... try below code

{
    "terminal.integrated.shellArgs.linux": ["--login"]
}

result: basically it formats to /bin/bash --login

@w5m

This comment has been minimized.

Copy link

w5m commented Aug 2, 2017

Overriding default settings with the following user settings worked nicely for me on Windows...

{ 
   // Git Bash
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    // start a login shell to pick up aliases from .bash_profile
    "terminal.integrated.shellArgs.windows": ["--login"]
}

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.