I need a shortcut for GEdit that will run the currently open .py file when I press, say, F5. I have a script that does this through an external terminal window, but I have more problems creating a version that uses an internal output window (shell output, I think), since I cannot find a good way to capture pyenv details from a ~ file. / bashrc. Work with pyenv is required.
Here is what I have through the GEdit External Tools plugin:
UNSOLVED: inner shell method:
I wanted to access the pyenv settings in ~. / Bashrc, so I tried these external script tools:
#!/bin/bash set +m bash -i python $GEDIT_DOCUMENTS_PATH
This works (thanks -i), but it gives me the warning "bash: no job control in this shell". Running set + m should get rid of this message, but it is not.
So, I moved the appropriate material that I had at the end of ~ / .bashrc to this script, which is not perfect at all:
#!/bin/bash export PYENV_ROOT="${HOME}/.pyenv" if [ -d "${PYENV_ROOT}" ]; then export PATH="${PYENV_ROOT}/bin:${PATH}" eval "$(pyenv init -)" fi export PYENV_VERSION=3.3.4 export LD_LIBRARY_PATH=~/.pyenv/versions/3.3.4/lib/python3.3/site-packages/PySide-1.2.1-py3.3.egg/PySide/ python $GEDIT_CURRENT_DOCUMENT_NAME
Problems: this last block is terrible. It is simply copied from ~ / .bashrc, and it should even include PySide data that ~ / .bashrc should take care of. Also, for some reason, using this method always displays the first line of the .py file (say, import sys). Obviously, no input signal () can be set using this method, and output to the GEdit Embedded Terminal seems impossible. In addition, I cannot get rid of the “Finish” message, even using set + m or by running a command in a subshell.
SOLVED: external terminal window method:
#!/bin/sh gnome-terminal -x $SHELL -ic "python $GEDIT_CURRENT_DOCUMENT_NAME; printf \"\nPress any key to continue.\"; read -n 1 -s"
or, define a terminal profile called, say, Wait, which sets the Title and Command-> When the terminal exits: Keep the terminal open and do the following:
#!/bin/sh gnome-terminal --profile=Wait -x $SHELL -ic "python $GEDIT_CURRENT_DOCUMENT_NAME; printf \"\nPress any key to continue.\""
This gives the message “status 0”, so another method is better. Both methods use an interactive shell to access ~ / .bashrc.