Home > OS >  How would I create a python program that puts the shell into a certain state?
How would I create a python program that puts the shell into a certain state?

Time:01-05

For example if I run setstate.py to shell would go from ~/Desktop $ to (customstate) ~/Desktop $

sort of like in anaconda when you activate an environment

for example something like:

import shellstate

shellstate.set_state("custom_state")
print('set state to custom state')


CodePudding user response:

You can't. That would be a security breach.

The shell is a process, your python program is another.

What you call "anaconda when you activate an environment" is something else: you don't run another process, you run command in the shell. By sourcing a shell script. (I don't know anaconda well, but something like source activate environment, which is a shell command, not a python program)

Any "state" (or any other internal change of your shell) has to be triggered by a shell command. It can't happen from a command of another process.

  • Related