Word count script for medit - help troubleshoot please
I love medit for text editing, but it's missing a word count feature.
I found a "Statistics for medit" script on the Arch Linux Forums, but after installing as instructed, there was no popup. So I set it to output to a pane instead, and I got: Code:
[/home/cwg43/pwb] LENGTH=${#DOC} My scripting skill is extremely basic, so I'd appreciate any troubleshooting help. Thanks! (I'm using CrunchBang Statler, which is Debian Squeeze based - so I didn't ask for help on the Arch Linux Forums. |
I presume you are a member of bbs.archlinux.org, I think you should post this there asking ConnorBehan for help. I don't see why this problem is related to using Debian instead of Arch. Even if it is, the author may be interested in making the add on more universal.
What Google, especially Google Linux, searches have you done? I just installed medit-0.9.2 which is the latest Debian package available to me in SimplyMEPIS 8.0, including python & zenity. Which ver. of medit are you using? I ask because I can't find the "Settings > Preferences > Tools" mentioned in the wiki article you linked to. So I don't know how to install this add on. I think this line in the output is the key to your problem (it was red, after all :)): Code:
/bin/sh: Bad substitution Code:
/bin/sh HTH, at least you know someone has looked at your post. :) |
I also just installed the Debian package version of medit to test this out, and was very frustrated because it completely failed to install any of the documentation that was supposed to come with it (no info or help pages; only the man page, which gives no useful info about scripting).
So I downloaded the newest medit package and extracted it's help files, and I think I worked it out. The problem with the above is that the $DOC variable holds the current file name. But if the document hasn't been saved yet, then there's no file for it to work on, so you get empty variables. Apparently the newest versions of medit have a new input item called "Document Copy", which makes a temporary duplicate of the file for the script to work on. If your install has that option, then switching to it, and changing every instance of "DOC" to "INPUT_FILE", should make it work. Since Debian's version doesn't have that yet, I improvised a different solution. Since the other input options all feed to stdin, I modified the script like so: Code:
Command type: shell script Incidentally, you can copy this script to another filter and change the Input to "selection", and it will work on partial selections too. |
Quote:
Code:
/bin/sh: Syntax error: redirection unexpected happened.) But it's good to know that the original code works in a newer version of medit, so I can wait for that if necessary. |
Quote:
Can't remember the exact searches I used, but I do use http://www.google.com/linux - awesome tool. Thanks. |
It works for me. Perhaps yours isn't using bash to interpret the script? I used bash-specific here strings above.
I wonder if adding a #!/bin/bash shebang as the first line will work? Or try replacing the wc lines with a more portable version. e.g. Code:
bytes=$( echo "$input" | wc -c ) |
Solved, thanks!
Quote:
For the record, the full solution that works for me, with medit-0.10.4 running on CrunchBang Statler (Debian Squeeze-based) is: Files: [leave blank] Options: needs-doc Command type: shell command Input: whole document Output: none:asynchronous Filter: none [Default also seemed to work] And the script: Code:
input="$(cat)" |
All times are GMT -5. The time now is 05:16 PM. |