Bash script with graphical menus - bash

I have been writing simple bash scripts for a while now, and I was wondering how I could implement simple menus and, if possible, use menus with color.
In the past, I have written simple C applications that use ncurses and would like to (if possible) have menus in my bash script where the user can use the up/down arrows to select items in a list, and go back/forth through a series of yes/no/cancel prompts.
I am familiar with setting up colored text in bash, so there's a start (eg: bash using colors), so the only requirement left at this point is to see if bash has these capabilities. I would prefer to avoid having to code an application in C/C++ for this, as I would like to be able to edit it on the fly.

there is a package called dialog, is this relevant to your requirement?

I haven't used this myself, but have you checked out bashsimplecurses? From the documentation, it looks like a possible solution.

Related

Multiple Cursors in Autohotkey

Is there any way in Autohotkey to mimic multiple cursors like in sublime. I need a hotkey that sends and couple of text lines and leaves me with multiple cursors so I don't have to type the same text over and over. Like in the gif below.
Thanks xD.
I need a hotkey that sends and couple of text lines and leaves me with multiple cursors so I don't have to type the same text over and over.
Just to open Sublime Text and type the text you need to.
and leaves me with multiple cursors
You cannot just put several cursors/carets on any application. The application must to provide support for multiple cursors creation. AutoHotKey is not a magic application which becomes everything possible, it is an automation application to automate boring or repeated tasks. Nevertheless, maybe you can search if there are some application, which can hijack other applications to compel them to use multiple cursors/carets.
However, if you are interested in make the AutoHotKey application to create several cursors on Sublime Text, you can write an AHK script to automate the cursors creation on Sublime Text using the Sublime Text keyboard shortcuts. The default Sublime Text API for Multiple cursors/carets is not very rich by keyboard, but there are Packages/Plugins as Power Cursors and Column-Select you can install on Sublime Text to improve it.
Personally I think you are better off writing a Sublime Text Package/Plugin with the Sublime Text API to create the multiple cursors/carets you want to, instead of externally to perform it with an AHK script by keyboard shortcuts.
Ultimately you can write a AHK script which asks a text and type it for you on several lines. For example:
If you enter Type This,5
The script could type on the current window caret/cursor position
To go back with the caret 9 positions.
To go one line down by pressing the down key.
To type again the same text.
Repeate this process until 5 times.
However with this we may easily see down sides as when there are empty lines as on your screen animation. So you would be better off just using Sublime Text, which is in my Opinion the best software that exists from the all as Notepad++, Atom, etc. Sadly it is closed source, so you cannot improve it by yourself or know why it is crashing certain times, which makes me wonder to write a new one open source, compatible with the current plugins and settings for it.
As others have mentioned, you cannot use true multiple cursors unless the program your're using supports it - however, you could attempt to emulate multiple cursors in the following way:
Build a defined list of cursor positions relative to the user's cursor (e.g. 2 lines down, 3 chars across, etc.). Must be relative! How you build this list is up to you.
Wait for the user to press a key
Once input is complete, move the physical cursor to the relative positions in sequence and repeat the keypress from step 2. This should be fast so the user doesn't notice the cursor jumping around.
Move the cursor back to where the user had it and go to step 2.
This is essentially how Sublime Text implements multiple cursors, but it has much better support (and speed) because it is software-level. This solution is input-level and will probably be unable to display where the multicursors actually are, will be slow, etc. Also, because it requires a fair bit of positional calculation, the implementation may complex and prone to bugs.
Sorry - this is the best I've got, it's definitely a hack - probably better (simpler) to just automate a copy and paste :P

Creating a bash-like Terminal GUI

I asked this before and didn't get an answer. I would like to create a linux-like scene for my game. This means that it should look like this: https://upload.wikimedia.org/wikipedia/commons/2/29/Linux_command-line._Bash._GNOME_Terminal._screenshot.png . Right now I have the two window approach(like common text based games) but i cant mimic the behavior in linux.

How to register complex hotkeys

I have a very long list of things I want to trigger with hotkeys in windows. (Unmuting, Playing a soundfile, muting). I have more than 100 soundfiles I want to reach that way, so the normal combinations of windows-hotkeys are not enough (since I do not want to override shortcuts already used by other programs).
My idea is to have something similar to ASCII-codes, where you press ALT-152 to get ÿ for example. Do you know of any tool that allows something like that?
I already tried to use ÿ directly as a hotkey, but that does not seem to work.
Edit: I already tried using autohotkey, but did not manage to achieve my goals (see comment to Santis answer)
I recommend you AutoHotkey, which allows you to program keyboard shortcuts. I always have used it with the classic accelerators (CTRL, ALT, WIN...), but I know it allows two-keys shortcuts.

ctrl-r history search equivalent for R64/R GUI OS X Application [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Retrieving Variable Declaration
I would like some way to search through the history of commands sent to R for a running session. This can be done in Bash using ctrl-r history search, and I find it extremely useful.
Is there a shortcut key in the R GUI IDE that does this? I've looked through changelogs and done some google searching, and I can't find it.
If not, is there a way outside of the R GUI IDE to extract this information? Possibly by searching through some sort of .Rhistory file maybe?
How are other R users accessing command history?
In the R GUI there is is a discoverable side panel that appears to whichever side of the screen has the most space and it has the history entries displayed in a clickable manner. That panel is kbd-toggled with shift-cmd-H, and if opened that way will place the active cursor in an entry line. That line at the top of that panel accepts regex expressions that will limit the displayed lines to those that match. It's a bit confusing (to me anyway) that there are separate history files. The side panel like the R.app or R64.app uses a file named ".Rapp.history", while the regular history file that a Terminal R session would access has its expected name.
The icon that does the show/hide toggling is exposed to the toolbar item selection panel of the console, so I suspect it is exposed to AppleScript commands. I'm not a big user of AppleScript and that last part is a hunch more than a promise.
The MacOSX FAQ says R will accept Applescript delivered R commands.
What is available as a shortcut depends on what interface you are using. If you use the r terminal on windows (but not the GUI) then ctrl-r works like you describe.
One tool (though not as easy) that should work for all interfaces is to use the 'history' command. Y can type something like history(pat='plot') and the recent commands that included "plot" in them will be displayed and you can cut and paste to rerun the command of interest.

Windows text editor that shows/hides lines based on RegEx or Grep syntax?

One of my application components produces some extremely hairy log files. They require a lot of poking and prodding before they produce useful information. I'm on the hunt for a text editor for windows that will let me enter text in either RegEx or Grep-style syntax, and automatically show/hide the relevant lines.
Does anyone know of a text editor that has this feature?
Thanks!
IVR Avenger
I know it's answered already, but http://glogg.bonnefon.org/ is the perfect answer for this. Couldn't live w/o it.
I would recommend Notepad++ as far as a good all-around Windows text editor is concerned - it is very extensible and includes just about every power feature you need to wade through data logs. If your log files are in a well-defined format, you can even use the built-in language editor to define a custom visual scheme for your logs - easier on the eyes.
-matt
GVim with for example, :g command. There are also plugins that allow entering search criteria, and they show relevant lines, and fold everything else.
Emacs, of course (occur), but I think pretty much every editor will do this.
Another option is SlickEdit using it's "Selective Display..." option
Although it wont show/hide based on a regex, Textpad will allow you to search and produce a hyperlinked result file with the lines that will allow you to click into the actual log. Consider the benefit: You can keep the filtered results up on your left monitor, and you can click into the full files and show them on your right monitor to see the context.
SPFLite is free and does just what you want. At least the IBM SPF and ISFP (used on IBM mainframes as part of the MVS operating system) that it emulates is just what you want.
From what I have tried, SPFLite will probably do the job. It can X (exclude) all lines from view, or eXclude lines with a given character or phrase (optionally starting in a certain column) from view. Or after eXcluding all lines, you can display, by Finding, characters or strings (optionally starting in a certain column). I think it also has a macro capability. The original does, and I think this Lite does as well. How robust I do not know. The original could create interactive screens and programs using the MVS TSO Command Language.
I found SPFLite at http://www.spflite.com/
I found that this interface is not so easy to use, but one gets used to about anything if necessary.

Resources