You are not logged in.

#101 2013-05-14 08:59:34

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby,
interrobang is great and clever, thx a lot.

Only one thing I miss: an interrobang commands history.
Is the an easy way to have one?

Offline

#102 2013-05-14 10:41:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

You mean just some sort of log file, or do you want to be able to recall items from the history?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#103 2013-05-14 12:54:35

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I've used bashrun2 since I discover interrobang.
So for history, yes I miss a kind of bash history for recall items or search history inside interrobang.

If I can suggest one more thing,
I think about a mechanism to present/call and select between a list of commands define in interrobagrc would be great too smile

I'm not a programmer only user, so please do not regard this as express requests, I love and appreciate to use interrobang whatever features you integrate ^^

EDIT: fix typo

Last edited by mentat (2013-05-14 12:55:08)

Offline

#104 2013-05-14 13:14:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

History is a good idea, I'll tinker with an option for that - but I've never used bash2run, so if there are specific features you'd like you'll have to elaborate.

mentat wrote:

I think about a mechanism to present/call and select between a list of commands define in interrobagrc would be great too

This is already built in with the custom tab completion mechanism.  For example, if you list your preferred programs (one per line) in a file called ~/.myprograms, then in your ~/.interrobangrc you can add a tab-completion with something like the following:

TAB()     pre="%s"; grep "%s" ~/.myprograms | while read match; do echo "${pre}${match}; done

You could also use the following if you only wanted to use this mechanism when you select a 'fav' bang:

!fav          %s
TAB(fav)      pre="%s"; grep "%s" ~/.myprograms | while read match; do echo "${pre}${match}"; done

EDIT: I've just pushed this "fav" bang with tab completion to the default rc on github.

EDIT2: as an aside, this has been one of the things about interrobang that has even really amazed me: a design choice made out of laziness, has opened up the possibility of all sorts of creative uses with just tiny bits of shell code in the rc file.

Last edited by Trilby (2013-05-14 13:22:45)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#105 2013-05-14 14:29:22

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

History is a good idea, I'll tinker with an option for that - but I've never used bash2run, so if there are specific features you'd like you'll have to elaborate.

bash2run is a terminal is a bash session application launcher based on bash feature for completion and history.

History work :
- with all bash variables: HISTFILE, HISTFILESIZE, HISTIGNORE, HISTSIZE ...
- with bash shortcuts: arrows up and down to recall prev / next command and with ctrl+r for reverse search of history.

So for example.

I launch interrobang and enter my bang command:

!term htop

Next interrrobang call I push arrow up to recall it or use reverse search ctrl+r:

(reverse-i-search)`ht':!term htop
mentat wrote:

I think about a mechanism to present/call and select between a list of commands define in interrobagrc would be great too

This is already built in with the custom tab completion mechanism....

Yes it's work like charm for a `fav` bang command.
But sorry I wasn't clear.
The mechanism was _about all bang commands_ inside your rc file.

For example.

I launch interrobang, enter the bangchar:

- hit `TAB` to present the first bang command, hit multiple times to naviguate between all commands define in my rc order (from the beginning to the end).
- write the begining of a command, hit `TAB` to complete the command, hit multiple times to naviguate if multiple commands have the same begining.

EDIT: I've just pushed this "fav" bang with tab completion to the default rc on github.

Cool, just integrate `!fav` in my rc file wink

EDIT2: as an aside, this has been one of the things about interrobang that has even really amazed me: a design choice made out of laziness, has opened up the possibility of all sorts of creative uses with just tiny bits of shell code in the rc file.

Cleverness inside ^^

Offline

#106 2013-05-14 14:57:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Oh, I see, so you want bang-completion?  I've looked at how this might be able to be added, and it would take a good amount of additional code.  Bangs are your own creation and are likely quite short, so I don't see much justification in adding all the needed code for that.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#107 2013-05-14 15:19:26

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Yes for bang-completion, if it's sound an heavy amount of code, it doesn't matter.

Just write this bang command to make part of the job:

!b            %s
TAB(b)      pre="%s"; cat ~/.interrobangrc | egrep -o  "^\![[:alnum:]]+" | while read match; do echo "${pre}${match}"; done

But history mechanism can be great addon.

Offline

#108 2013-05-14 15:31:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Great idea.  I just pushed a revision of that bang that saves a cat, and a loop.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#109 2013-05-14 18:14:24

mentat
Member
From: France
Registered: 2009-01-13
Posts: 138
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Ouch'
you're right about rewrite

TAB(?)      ignore="%s%s"; grep -o -E "^\![[:alnum:]]+" ~/.interrobangrc

100x "don't have to grep a file via cat with a pipe !"

Offline

#110 2013-05-16 16:06:56

alban
Member
Registered: 2013-05-12
Posts: 15

Re: Interrobang: a tiny menu packing a big bang (syntax)

Hi,

Thanks for this great launcher, it is working very well.
Just a remark, completion is not working using hushbang. I don't know if it is wanted or a small bug.
I just write a "patch" (well, 2 lines...) for that. There is no side effect I think.

@@ -282,6 +282,8 @@ static int main_loop() {
	        		if (strncmp(bangs[i].bang,line+1,strlen(bangs[i].bang))==0)
 							comp = bangs[i].comp;
 				}
+				if (hushbang > -1)
+					comp = bangs[hushbang].comp;
 				if (!comp) comp = defaultcomp;
 
 				sprintf(cmd,comp,prefix,sp);

Many thanks anyway
PS : first time I try to submit a patch, hope I was right

Offline

#111 2013-05-16 17:25:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Thanks alban, you're exactly right on what the problem was, and that is a great fix.

I revised it only slightly before pushing to git to put the hushbang check before the strncmp check.  This way if there is a hushbang the string comparision and loop never have to happen, but if there isn't a hushbang, the only processing cost is a numeric comparison.

For practical purposes it makes no difference whatsoever - but I have a bit of OCD about wasted processor cycles.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#112 2013-05-18 16:23:03

silenc3r
Member
From: Poland
Registered: 2009-08-29
Posts: 149

Re: Interrobang: a tiny menu packing a big bang (syntax)

I'm not sure if I missed something, but can't see any commands/autosuggestions in interrobang bar. Tab completion doesn't work either.

Offline

#113 2013-05-18 16:30:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Are you using the default rc (did you move it to ~/.interrobangrc)?  Is bash your default shell?  Do the commands you type in run properly?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#114 2013-05-18 16:38:34

silenc3r
Member
From: Poland
Registered: 2009-08-29
Posts: 149

Re: Interrobang: a tiny menu packing a big bang (syntax)

Heh, I had no ~/.interrobangrc. Thanks.
But still, interrobang doesn't display list of commands like dmenu does. Is it even meant to?
Anyway I quite like it.

Last edited by silenc3r (2013-05-18 16:52:36)

Offline

#115 2013-05-18 17:13:03

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: Interrobang: a tiny menu packing a big bang (syntax)

Yeah its not meant to:

Trilby wrote:

This tool does not display options like dmenu, rather you can type whatever letters you want, then hit tab for shell-style tab completion.  If there is more than one possible completion for what you've put you can hit tab repeatedly to cycle through the options.

Offline

#116 2013-05-29 18:27:45

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 748

Re: Interrobang: a tiny menu packing a big bang (syntax)

A few months there was talk about '^u' keybinding to clear the line, I think another good feature would be to provide way to clear only the completion - for example, when I write 'ls ~/foo/', pressing tab completes through ~/foo/{bar,baz} and pressing for example '^c' would delete only {bar,baz}. Basically restoring the line to the state before tab was pressed for the first time.

Offline

#117 2013-05-29 18:39:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

That is a good idea.  It's done and on git.  Let me know if it leads to any unintended issues.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#118 2013-06-04 16:37:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I just added a small feature called "autocomplete" which will essentially simulate a tab-key upon starting up, so a completion list is populated and the first option is filled in.  This would likely be a horrible thing to use except when paired with a hushbang.  I added this option along with the ability to use up/down arrows to select completion options, so I could replace my dmenu logout tool.

These options allow for a more 'dmenu-like' menu creating option.  To see a simple example, this is the logout script I have bound to my laptop's power key:

#!/bin/bash

case $(interrobang logout - <<'EOF'
font        -*-terminus-medium-r-normal--12-120-72-72-c-*-*-*
autocomplete
!logout		echo %s
TAB()		echo -e "cancel\nshutdown\nreboot\nlogout"
EOF
) in

shutdown) sudo shutdown -h now ;;
reboot) sudo reboot ;;
logout) killall xinit ;;
cancel) exit ;;

esac

When I hit the power button, the menu comes up with "shutdown" already there as a default.  Hitting up/down arrows (or tab/shift-tab) cycles through the options.  Hitting Enter selects the option.

Last edited by Trilby (2013-06-04 16:39:09)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#119 2013-06-10 08:30:42

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: Interrobang: a tiny menu packing a big bang (syntax)

I use interrobang and I love it -- thank you very much for this handy program!

A suggestion: It would be nice if the prompt emulated the text editing behaviour of emacs/vim, just like bash or zsh do. For example moving the cursor to the beginning of the prompt on pressing Ctrl-a or ^.

I guess this is what GNU readline is for, but I don't know if it is considered bloat or contradicts your program's philosophy...

Offline

#120 2013-06-10 08:41:42

lahwaacz
Wiki Admin
From: Czech Republic
Registered: 2012-05-29
Posts: 748

Re: Interrobang: a tiny menu packing a big bang (syntax)

ball wrote:

I use interrobang and I love it -- thank you very much for this handy program!

A suggestion: It would be nice if the prompt emulated the text editing behaviour of emacs/vim, just like bash or zsh do. For example moving the cursor to the beginning of the prompt on pressing Ctrl-a or ^.

I guess this is what GNU readline is for, but I don't know if it is considered bloat or contradicts your program's philosophy...

It would be only like bash, because zsh doesn't use readline... But I agree that it would open many new possibilities, as you can even enable vim-like editing mode wink

Offline

#121 2013-06-10 11:22:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Adding particular key bindings is easy enough, that's how Ctrl-u and Ctrl-c were added.  But if you want to be able to move within the text and insert, that would take a *lot* more code.

I'll have to consider readline, as it would provide all such options, but I'm not sure it could be practical to have it interact well with the completion mechanisms - more importantly, readline may only work in a terminal.  I will *not* make interrobang into a full terminal for readline.

Actually, after a very quick review - this last point seems to be the deal breaker.  If anyone knows otherwise, feel free to point me to documentation of how readline can be used without a terminal.

Last edited by Trilby (2013-06-10 11:26:48)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#122 2013-06-15 15:48:22

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: Interrobang: a tiny menu packing a big bang (syntax)

I just came across a rather odd problem (and I'm unsure if this is related):

Whenever I want to launch slrn in a terminal window from interrobang, the terminal window immediately disappears, it's only visible for less than a second, like flickering. It seems to make no difference whether I try it with "!slrn" or "urxvt -e slrn". However, the command "urxvt -e slrn" works fine when I try it from an urxvt window. Until now slrn is the only program which behaves like this...

Last edited by ball (2013-06-15 15:49:46)

Offline

#123 2013-06-15 16:10:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I'm trying to replicate this to troubleshoot - but I've never used slrn before and I can't even get it to start in a normal terminal.

EDIT: solved:  slrn *requires* an enviornment varibale to be set to specify the news server, otherwise it not only fails to start, it fails in a very ugly way.  If this is actively developed, I'd report this failure as a bug.  To see this, just UNSET your server environment variable and try to run slrn.  In a normal terminal it will just fail to start - fair enough.  But if you do "urxvt -e slrn" without that environment variable set it fails in the ugly way: it crashes the terminal, but the window remains present (but invisible) - this may only be notable in a tiling wm.

Point is, though, this is the same problem that came up earlier: using environment variables in this way is just wrong.  A work around would be to make sure the environment variable is exported *before* starting X, as interrobang inherits the environment from X, not from any terminal you may have open (you don't need a terminal open to run interrobang).

To confirm this is the issue, run interrobang from a terminal where slrn works: then you should be able to run slrn from interrobang, because the environment is inherited from the original terminal.

The longterm workaround specifics will depend on how you start X.  If you use an xinitrc, then export the NNTPSERVER variable there before launching your window manager, then it works fine.

Last edited by Trilby (2013-06-15 16:30:03)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#124 2013-06-15 17:53:44

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby, just wow! (I am kind of speechless -- how did you come up with the server variable being the culprit? I knew that it required the variable but I was not able to make the connection that the variable is not set when starting interrobang not from my terminal.)

Last edited by ball (2013-06-15 18:07:09)

Offline

#125 2013-06-15 18:27:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I've seen it before is all.  Environment variables are often misused.  They can be set in one process, but that setting will only then apply to that process and any child processes.

For clarification of my above post, interrobang (like any other program) inherits the environment variables of it's parent process.  If it is launched from a terminal emulator then it will have any environment variable that was defined in the shell session.  But most often interrobang would be launched from a window manager key binding.  Used this way, it inherits only the environment of it's parent process: the window manager.  The WM, in turn, inherits from xinit or whatever process starts X.

Last edited by Trilby (2013-06-15 18:32:10)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB