Re: Using xbindkeys to process current file in console
From: Dances With Crows (danSPANceswitTRAPhcrows_at_gmail.com)
Date: Fri, 22 Apr 2005 13:53:14 -0500
On 22 Apr 2005 09:14:43 -0700, Claus Dormeier staggered into the Black
Sun and said:
> I want to use xbindkeys to start with a key a script that should
> process the current file shown in the console.
Er... "console" meaning what, exactly? If you meant "tty", then
xbindkeys won't help you; xbindkeys requires X. If you meant "an
xterm", that may be doable, but it'll be really annoying.
> E.g. there is a html file shown in the console and F12 should start a
> sed script parsing that file and deleting all newlines. Is xbindkeys
> able to find the path/filename of the last shown file in the console?
Er, if you "tr -d '\n' " an HTML file, that file will be really
difficult to edit in the future. You don't want to do that. Did you
mean "tr -s '\n' ", instead? Which terminal emulator are you using?
Which program are you using to view this file?
> What is the Environment variabel I have to use in the xbindkeys macro?
Impossible to tell without more specific information. Pagers like less
and editors like vim typically don't set environment variables saying
which file they're viewing. If you're viewing this file in a Real Text
Editor, that editor already *has* all the macro functionality you'll
need for editing text. Use your editor's macro language to do the
equivalent of "tr -s '\n' " on the file.
Also, if you're going to do anything semi-complex with xbindkeys, you
probably should have xbindkeys invoke a script (C program, whatever...)
instead of trying to pack the entire command on one line in
In fact, I think you may have better luck doing this *without* involving
xbindkeys. Like so:
# in file called killnewlines.sh
tr -s '\n' < $1 > temp.temp
mv -f temp.temp $1
# end of script; chmod +x this
...put that script somewhere, drag text file onto script using file
manager, bingo. That's how it works in KDE, at least; YWindowManagerMV
but GNOME at least offers similar functionality. HTH,
-- Matt G|There is no Darkness in Eternity/But only Light too dim for us to see Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong http://www.brainbench.com / Hire me! -----------------------------/ http://crow202.dyndns.org/~mhgraham/resume