I saved a python file in my desktop and want to run it in the terminal, but everytime I run it I have to type ' python /home/m3gn/Desktop/ex1.py' Is there anyway to shorten this so that I only have to type 'python ex.1'?
Thank you!
/home/m3gn/bin
Ubuntu in theory can add this directory to your path automatically.chmod +x ex1.py
home/m3gan/bin
directoryex1.py
If Ubuntu does not automatically add bin to your path, you can manually add it at your .bashrc
file by adding the following lines:
if [ -d ~/bin ] ; then
PATH=$PATH:~/bin
fi
Save and close .bashrc
and issue: source .bashrc
in terminal, it should be ok and ready for use.
Add variable
ex1="/home/m3gn/Desktop/ex1.py"
to your ~/.bashrc
file and run
source ~/.bashrc
Now you can just use
python $ex1
cd
into /home/m3gn/Desktop first and then runpython ex1