Reputation: 4282
I have been searching the Internet and my hard-drive trying to see if Python3 has an equivalent to BASH's ~/.bashrc file. The reason I need one is so I can have certain functions be defined as soon as I open Guake which I configured to use Python3.
For example, with such a file, I can add this function
def CLEAR(): os.system(['clear','cls'][os.name == 'nt'])
to such a file. Then, when I open Guake, I can use Python and type CLEAR() when I want to clear the terminal. Otherwise, I need to make the function every time I use it the first time in a Guake session and I am very lazy on some days (^u^).
So, the question is what goes in this blank:
BASH is to ~/.bashrc or /etc/bashrc as Python3 is to __
sh - ~/.bashrc = Python3 - ? def CLEAR(): os.system(['clear','cls'][os.name == 'nt'])
Upvotes: 1
Views: 357
Reputation: 369284
Make a file (for example ~/.pythonstartup)
import os
def CLEAR():
os.system(['clear', 'cls'][os.name == 'nt')
Set the environmental variable PYTHONSTARTUP
to reference above file. Put that into ~/.bashrc
export PYTHONSTARTUP=$HOME/.pythonstartup
See The Interactive Startup File in Python tutorial
Upvotes: 1
Reputation: 27577
Python is more flexible, you want to set the $PYTHONSTARTUP
variable to the pathname of your start up file
Upvotes: 2