简体   繁体   中英

Run a Python script when opening Terminal(xterm)

Is there a way I can run a Python3 script while I open xterm?

What I want to do:
I want to create a ToDo list, which runs on startup of xterm (should be able to use ArgParse)

OS
I use gentoo = a unix/linux distro --> gnome3(X.org)

My research
I didn't find any solution, there were only results, where people wanted to start the Python interactive mode and not a solution to my problem (the way around)

You can try to use an alias, that is modify your.bashrc and add the next line:

my_alias='xterm -e /path/to/script/ /path/to/todo_script'

Where script file is the following script :

#!/bin/sh
"$@"
exec "$SHELL"

And todo_script is the script that you want to execute. For example, if todo_script contains

#!/bin/sh
echo "Hello World"

If you execute my_alias, it will show Hello World in a new xterm terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM