I've got Python IDEs like Eric and Spyder installed, but I still find myself starting Kate to get editing without screen clutter and all the editing tools I need -- and then I have to go to a Konsole any time I need to run the script. I expect there's a way to set up Kate to run the Python script that's currently being edited with a shortcut key -- with a plugin(?) -- but if there is it's not obvious to me. Help please.
Announcement
Collapse
No announcement yet.
Can Kate run a Python script it is editing?
Collapse
This topic is closed.
X
X
-
I've figured out a solution. I can now run the Python (or other) script being edited with F2. Here's my notes:
Kate setup:
Settings -> Configure Kate -> Plugins -> Build Plugin -> Check
View -> Tool Views -> Show Build Output -> Check
Target Settings Pane -> dbl-click "T: Target Set" rename to "Run Scripts"
Delete lines "Clean", "Config", and "ConfigClean" (click red "X")
Build -> Check
Dbl-click "make", replace with "%f" (assumes scripts will have suitable hashbang)
Settings -> Configure Shortcuts -> search "build" ->
Build Target -> Custom -> F2
Edit: Now I've found that Kate will lock up if I use the above method to run a Python script which I've accidentally forgotten to start with the hashbang line. (When the shell hits the Python script's first "import" line, it tries to execute the command-line "import" from ImageMagick. The same problem would also lock up Konsole if I ran the script from the command-line.) So to fix that I created a file called "kate-run-scripts" in "/usr/local/bin" as below, and changed Kate's "Build" line (see above) to: kate-run-scripts "%f"
Code:#!/bin/bash if [[ -z $(head -n1 "$@" | grep '^#!') ]]; then echo "Script must start with hashbang." else $@ fi
Last edited by Dave Rove; Nov 11, 2017, 08:30 AM.
- Top
- Bottom
Comment
-
Can't find this:
Target Settings Pane -> dbl-click "T: Target Set" rename to "Run Scripts"
Delete lines "Clean", "Config", and "ConfigClean" (click red "X")
Build -> Check"A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
– John F. Kennedy, February 26, 1962.
- Top
- Bottom
Comment
-
Originally posted by GreyGeek View PostAh, that's much clearer.Windows no longer obstructs my view.
Using Kubuntu Linux since March 23, 2007.
"It is a capital mistake to theorize before one has data." - Sherlock Holmes
- Top
- Bottom
Comment
Comment