You are not logged in.
I'm still loving Interrobang and would just like to thank you again for this awesome utility. It's become one of those things that I didn't know I needed so badly until I started using it.
Last edited by jgreen1tc (2013-06-18 21:11:56)
Offline
Trilby, thanks for the suggestion! I am really liking the flexibility of Interrobang.
The "TAB()" parameter sets a handler for the default (non-bang) queries, correct? If that is the case, then it should be possible to do the same kind of history lookup there as well.
Keith
dotfiles
Offline
EDIT correction: perhaps bash's "compgen" command will work from a zsh shell, it so then you'd only need it installed. But I've never tried this myself - I'm pretty sure compgen is a bash builtin, though, so I'd be surprised if this worked.
I've been using Interrobang with ZSH so far without a problem -- I didn't have to make any changes to the default config, either.
Keith
dotfiles
Offline
Thanks for the thanks.
The TAB() does set the default completer. I do have to write a man page for this thing soon, and hopefully I'll clarify some of this. Originally I hoped the rc file would be fairly self explanatory ... and originally I think it was - but as bits and peices have been added, there are quite a few options that warrant a proper man page.
I'm (pleasantly) surprised to here this works with zsh. But is zsh really your systemwide default shell? Interrobang uses the system() function which invokes the default shell, then runs the command "compgen ..." - this *shouldn't* work if that defualt shell is zsh.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
@Trilby, you are correct: I tried replacing /bin/sh with a symlink to /bin/zsh and the completion stopped working. Reverting to /bin/bash fixed the issue.
So it seems it will work if you have bash, and /bin/sh links to /bin/bash; otherwise it may fail. Although, an easy work-around (if you have bash installed), would be to just create a "compgen" script which calls the bash compgen.
Of course, native ZSH completion would be ideal, but I haven't looked into that either... Perhaps another thing I can check into over the weekend
Keith
dotfiles
Offline
thx for the tips guys, after copying the rc file from github tab completion works
really loving interrobang, was wondering if i could make a suggestion/request? it would be cool to have commonly-chosen options before uncommon ones. that have Interrobang remember what i input so that after 3-4 time i press 'f' to launch firefox the next time i press f>TAB it would auto choose firefox as first completion option out of the whole list of apps starting with 'f'
i hope i made sesne
best and thx alot for this great little app
Zeltak
Offline
That can be done - see the post right before your first post in this thread.
Interrobang is kept intentionally ignorant of such details so that users *can* be creative with things like that. It would take a (very) little bit of shell scripting, but should be pretty easy. If no one else gets a fully working version before then, I could throw something together over the weekend.
The rc file notes that it is not interpreted by a shell interpreter - which may actually be a bit misleading: the *file* is not parsed by a shell, but the entries are. See the optional complex completer as an example, it is a series of bash commands, that process the completion options.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Hey Trilby,
I looked into ZSH completion a bit this morning, and it looks like there is a way to enable a bash-like compgen tool:
autoload bashcompinit
bashcompinit
If you run those commands in a ZSH script or session, it should make "compgen" available.
However, I created two small scripts two scripts to test the different version of compgen, and the results do not appear to be the same.
In theory though, with a little more playing around, it should be possible for people who only have ZSH to include those two lines in their .zshrc, and then use some (possibly slightly modified) version of compgen in there .interrobangrc.
Keith
dotfiles
Offline
On a different note, I have a few more questions for you when you have the time:
1. There is currently no hook for when the bang-less command is run, only one for it's tab completion, so there is no way currently to create a history file of the commands that were actually run, correct?
2. Would it be worth creating a minimal default config file (e.g. /etc/intterobangrc) which gets parsed first? This way users could at least use the basic functionality of interrobang with having to manually copy the config file to their home directory.
3. Do you have any suggestions for improving font appearance?
Currently I have:
font -*-droid sans mono-medium-r-*-*-14-*-*-*-*-*-*-*
In my interrobangrc file. I have not been able to figure out a way to enable anti-aliasing, however, in order to achieve something similar to what you might get in the console using with an "xft:" font specification. The problem is especially noticeable at larger font sizes.
Any suggestions?
Thanks!
Keith
dotfiles
Offline
EDIT, this may be innaccurate: You either need bash as your default shell, or you need to write a custom completer in the rc file. If you have bash installed, but just not as the default, you could probably just prepend "/bin/bash -c" to the current completer.
If you find any way to get zsh to provide completion options, that would be even better - but so far we've had no luck on that.
EDIT correction: perhaps bash's "compgen" command will work from a zsh shell, it so then you'd only need it installed. But I've never tried this myself - I'm pretty sure compgen is a bash builtin, though, so I'd be surprised if this worked.
zsh has 'emulate' built-in command (see zshbuiltins(1)), so I think 'compgen' should work, but that doesn't solve the integration into interrobang...
Last edited by lahwaacz (2013-06-19 11:22:12)
Offline
Interesting. I can't get it to really work though. Regardless of what it is passed as a parameter, it just dumps the *full* completion list. The following seems to *mostly* work:
TAB() PRE="%s"; for OPT in "$(compgen -cf | grep ^%s)"; do echo "${PRE}${OPT}"; done
Though I do *love* the fact that the only way to get completion results from zsh, so far, is to have zsh call on bash! I know zsh is quite popular, and rightfully so, so this is no flame, but (I think) a well reasoned criticism: zsh has a lot of "magic" that it doesn't want the user to understand. It's built in completion is a strenth ... but you can't use it in creative ways. There is the advice to not prevent users from doing something stupid, as in doing so you'll prevent them from doing anything creative. Zsh is really nice in having things work well for expected tasks, but prevents the type of creative re-purposing that I feel thrives in bash. (just my 2 cents ... you may want a refund).
Last edited by Trilby (2013-06-19 11:51:47)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
thx Trilby
It would take a (very) little bit of shell scripting, but should be pretty easy. If no one else gets a fully working version before then, I could throw something together over the weekend.
that would be epic, unfortunantly i dont know any coding at all (im an academic), but i can help out with testing, documentation etc
wanted to thank you again for Interrobang, its really great and i enjoy it very much!
Z.
Offline
Couple more ideas:
1. Include an option to automatically display matches, without pressing tab.
2. Include an option to align the tab completion results to the left-side instead of the right-side.
Are any of these suggestions things you would be willing to include in interrobang? If so, I can open up some issues on GH, and perhaps submit a couple PRs to implement them.
Keith
dotfiles
Offline
Both might be easy enough to do - but are you sure they are good ideas? The first would require a refreshing of the completion list with every keypress *and* it would have completion results after the very first key was pressed ... that'd be a lot of options.
The second one, I suppose, is just a matter of aesthetics: I *want* space between where the text I'd type would be entered and where the options are. Left-aligning the completion options would feel cramped, and would leave a useless gap on the right in many cases. ... unless you want the options on the left and the text entry on the right (?)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
What I was thinking of doing was piping the results to something like "head -3", so that only a few results would ever be displayed.
If I'm then able to get it set up so that the results are optimized based on my usage history (see above post regarding main hook), then I should be able to run almost any of the common applications I use with only ~2 keystrokes after invoking Interrobang, and by limiting the number of results displayed, it never should appear too cluttered.
I agree that having the tab-completion results right next to the command might be a bit cluttered though. I think I will have to try it out and see how it looks. I main reason I am thinking that it would be useful now is because I'll always know where to look to see what the current 'candidate' command is. The way it is set up now, if there are many options, then I look right next to the command being typed. If only a few possible options remain, however, I have to scan the right side of the screen to find the results.
Of course, this is a very minor issue, but I thought it would be good to at least try it out. Perhaps an ideal solution for me at least might be to align the results left, but have a small amount of padding (~20px) to avoid becoming too cramped.
Keith
dotfiles
Offline
Displaying (part of) completion list would also be useful when completing files, it could display something like "foo.zip bar.zip (another 5 items)". Possible usage would be to open last downloaded file, e.g. sort files in download folder by creation/modification time and show N newest files. Another issue with this: whether tab should cycle through all items in completion list, or only through the shown items.
Offline
As is, if there is a long list, only those that will fit in the bar are displayed - but tab does cycle through all of them. It was actually a bit tricky to make sure one could tab through all the options while having the slected item displayed in the list (if the real list was long).
Actually - I know I solved this in my head, I should see if I actually wrote that code yet. (edit: nope, this code is still just in my head - this is the first task Opps,that was done - I just hadn't installed it yet).
Adding some indicator that what is shown is not the full list is a good idea - I'll get on that soon.(done)
Last edited by Trilby (2013-06-20 19:33:02)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Trying to set up default tab completion now such that commands from a history file are prepended to the tab-completion results, but so far no luck.
Here is what I have so far:
HIST=~/.interrobang_history
TAB() (grep %s $HIST | sort | uniq -c | sort -r | awk '{print $2}'; compgen -P "%s" -cf %s) | awk ' !x[$0]++' | head -5
(The second awk removes redundant entries...)
The parameter to maintain a history (courtesy of Trilby) is:
run_hook cmd="%s"; echo $cmd >> ~/.interrobang_history; $cmd
When I use the above TAB(), however, the history commands are not prepended as expected, and the listed completion options all include the string being typed twice, e.g.
input: ch
chchang chchecksites chcheck-regexp chchromium ...
Any ideas?
Keith
dotfiles
Offline
Your tab completion command has 3 %s in it, but there are only two strings passed to the printf function.
That should be
pre="%s"; str="%s"; grep "$str" ~/.interrobang_history | sort | uniq -c | sort -r | awk '{print $2}'; compgen -P "$pre" -cf $str
edit: fixed typo
Last edited by Trilby (2013-06-22 11:30:47)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Hmm. did you try that out? It seems to return the entire history followed by all possible commands, regardless of the input.
What are the two string that are input into compgen? The second one ($str) is the input string, right? What is $pre?
Keith
dotfiles
Offline
No, I didn't try it - it looked odd to me, but I just revised based on the apparent intent of you version.
The two strings passed are the prefix and the query string. Or, specifically, the second %s is replaced by the last "word" in the line, and the first %s is everything up to the last "word". For normal completion, you'd only want to match against the last word, and prepend everything that came before it.
If I were to have typed "mupdf ~/doc/pdfs/Ma" the completer should look for files starting with Ma in that folder - it should not look for file/commands starting with "mupdf ~/...". The mupdf part is already complete.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Hmm. okay, so when you are only typing a single command, the prefix would just be an empty string?
For example, would typing the input "chr" set pre="" and str="chr", resulting in:
(pre=""; str="chr" grep "$str" ~/.interrobang_history | sort | uniq -c | sort -r | awk '{print $2}'; compgen -P "$pre" -cf $str) | awk ' !x[$0]++' | head -5
When I run the above on the command line, it returns the desired result (combination of history and commands starting in 'chr'). But when used in interrobangrc, the result is not the same so I think there is still something I am misunderstanding.
Keith
dotfiles
Offline
Yes, pre would be empty.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Well, there is a typo. The value of str is only set for gret in that one. That should have been `str="chr"; grep "$str"...`
It works as expected here.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline