Thursday, January 27, 2011

Terminal Helper

I often need to be available 24/7 whole week and check or fix something on linux, AIX or other unix type servers if needed. Because notebook is so heavy and it's a bit hard to put it to trouser pocket, I often use my Android phone with hardware keyboard, which is actually HTC Desire Z, previously it was HTC Dream. Sometimes I need to put long command into my SSH terminal on phone, which is ConnectBot, and even on hardware keyboard it's not so comfortable. So I made this android application to help me create several and universal command lines, with possiblility to put custom strings in the middle and then just replace them with words or commands actually needed, without moving cursor over whole command line. This application is something like "string builder" with copy to clipboard function when finish. It's most useful when you are in ConnectBot or other terminal and you can run Terminal Helper by shortcut key. You can find application on Android Market or install it by QR code.



When you run Terminal Helper for first time, you will see something like this, with information that you can click on [ Settings ] and then use Menu button on your android device to start managing commands.


By clicking on settings you will enter to screen, showing all you already defined commands sorted with priority you gave it before. First time it's empty so hit Menu button to se what you can do here.


Then you can hit Add to add first command like this



Here i created command to restart WebSphere J2EE server from terminal console for example. As you can see, i need to put 3 variables, which could be always different, because I may want restart every time any other server, on other location or environment with different login and password. So I put 3 variables called #customString# (exactly this string) and application will show me dialog when I want use it. Here you can see #customString username# and so, which just add a "hint" to dialog fields what you should fill here, in case you need many custom strings in your command. You will see later.

Then the best way to use it is map some shortcut key on your hardware keyboard to run this application. When you need it, just run ConnectBot, login to server and hit that shortcut key to choose which command you want to use. You should end up with something like this


Then just select your defined command and you will see dialog, where you can fill boxes which replace #customString# sections in your command. That hints like servers (#customString servers#), username and password are optional. If you put just #customString# word, application will always give you as many options, as many custom strings you used. Just fields in dialog will be without hints. Of course, you don't need put any #customString# in your command, if you don't need replace something in your command before using it.


Fill dialog


And when you choose OK then application will end and your command is copied to your clipboard



Here i used for cycle in command if restart more than one server is needed. Then just use menu (or long click in other terminal) to paste from your clipboard



That's it. With minimun typing on keyboard. You can use in settings "Send ENTER key on finish" if you wish to execute it immediately after paste. There is also context menu on Setting screen where you can Delete, Send your command with name by SMS or Email.

 
Also you can Export your DB to SD card (terminalHelper.txt in your SD card) and also Import. If you check that plain text file format, you can easily create your commands on your computer and then import them into application. Just DO NOT use ENTER key in command line either in application or in terminalHelper.txt file when editing by hand (in that case, you have to keep it's structure). There is also priority field, which purpose is only for sorting. It's number from 1 to 100, smaller number is higher position in listing.

Icon of application is GPL licensed from Sergio Sánchez López, small icon of Enter at the right side on main screen is Free for non-commercial use from Harwen Zhang and icon in Notification area is Creative Commons licensed from Yusuke Kamiyamane.


Update:  I added option to show notification icon for fast access even for users without hardware keyboard or with hardware keyboard just without shortcut keys. If you enable it, you will find it again in notification area even if you reboot your device. Check screens below



Update 2: minor UI/usability improvements already updated in the main article. After few days of using:



The "+" at the start of the line means that there is #customString# used in command and therefore ask dialog will appear and you have to put fill it.
Have fun.