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

Terminal startup commands setting? #299

Open
suedunham opened this issue Jan 2, 2022 · 2 comments
Open

Terminal startup commands setting? #299

suedunham opened this issue Jan 2, 2022 · 2 comments
Assignees

Comments

@suedunham
Copy link

Description of your problem

This may be more of a feature request than a problem. I don't want to have an Anaconda prompt in regular PowerShell, but I'd like one in spyder-terminal within spyder. Is there a way to set any opening commands when the terminal starts up?

A working illustration from a similar app.

For instance, I've created a Conda task in ConEmu by pasting the text present in the Anaconda Prompt shortcut created when installing Anaconda or Miniconda. The process in that program goes like this.

  1. Click menu button and select Settings…
  2. Select Tasks pane.
  3. Select {Shells::PowerShell} from Predefined tasks box and press Clone button.
  4. Paste the following into the Commands box:
    powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\MyName\miniconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\MyName\miniconda3' "

This allows me to have an Anaconda prompt for ConEmu without having them everywhere else.

Is there any facility for opening spyder-terminal within spyder while invoking those commands? Is there another way of getting an Anaconda prompt there that I haven't found?

Versions and main components

  • Terminal Version: 1.2.0
  • Spyder Version: 5.2.1
  • Python Version: 9.9.7
  • Operating system: Windows 10
@steff456
Copy link
Member

Hi @suedunham,

We do not support Anaconda prompt since it is not a terminal shell. However, we do support conda, so if you go ahead and type conda activate 'C:\Users\MyName\miniconda3' and select your shell in preferences as powershell, then you will have your environment active in that terminal.

I haven't used ConEmu before, but it seems that it is a graphical application for windows, which we are unable to connect to spyder-terminal. Maybe, you can try adding the commands you always need to the profile file (https://superuser.com/questions/144347/is-there-windows-equivalent-to-the-bashrc-file-in-linux), in that way they will always run on startup.

Hope this helps!

@suedunham
Copy link
Author

Perhaps I wasn't clear. I'm not trying to link ConEmu, I was just using it to illustrate the functionality I was looking for in Spyder. The Anaconda Prompt is just a shortcut to cmd or PowerShell that opens those programs with an additional command invoked in order to activate Anaconda in that session. Instead of the link merely going to powershell.exe, for instance, it says this:

powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\Username\miniconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\Username\miniconda3' "

What I was asking about in Spyder was if there is anything similar. Is there a setting somewhere where I can paste additional commands so that when that spyder-terminal session is opened, those commands can be run for that session?

Yes, I can run the script once, and—f Anaconda is not configured to prevent it—the conda prompt will show up in every PowerShell session whether I am using PowerShell.exe, ConEmu, or Spyder. This is what I don't want. I want those other terminals to be clean. However, in Spyder, I am more likely to be using Anaconda in the terminal, and it would be nice to be able to automatically invoke those shell commands when the terminal opens.

Sure, it's not too hard to just type conda activate into Spyder-terminal when I need to, but it would be nice to have that taken care of.

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

No branches or pull requests

2 participants