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.


  1. Useful app!

    I have Nexus One - phone without HW keyboard. So my suggestion is icon of this app in Android system notification bar (like ConnectBot has) to easier switching of this two apps.

  2. Good idea. I will check it out. Thanks.

  3. This comment has been removed by the author.

  4. Hi Joesef, I really like using the Terminal Helper it comes in handy often. I am using it on my Motorola Charm (MB502). I am wondering if you would be so kind to share the source code for educational purpose because I intend to change some of the settings around to fit my personal network needs, by making a (text box field) for my IP address and other variables. (THANKS, in advance.) I can be contacted by the email address, from my blog connected to yours.

  5. Hello Opticprism, I'm sorry about late answer. I left developing for android some time ago and don't even know where I have sources now. I will let you know when I find them.
    Thanks for using it.

  6. I appreciate, the response and I can understand how busy you must be with other things now that you have moved away from the android seen. I was also, thinking of turning your script into a python script, because that is what I am learning at this time aside from many other tutorials like linux bash commands and scripts. Right now I just got as far as writing a functional dialing number pad for my Nokia N900 using python. I would like to take your source code if you ever come across it and try to implement it in a python script to work in my Nokia N900 unless you might already have done this? Any help as in pointing me in the right direction or if you find your source code from the "Terminal Helper Project" would be Greatly Appreciated.
    I really have found your app "Terminal Helper" to be of great use to me and I appreciate the effort you put into it and sharing it.
    Thanks, and I hope you have a Great Day.