GraphTerm is a browser-based graphical terminal interface, that aims to seamlessly blend the command line and graphical user interfaces. The goal is to be a fully backwards-compatible terminal emulator for xterm. You should be able to use it just like a regular terminal interface, accessing additional graphical features only as needed. GraphTerm builds upon two earlier projects, XMLTerm which implemented a terminal using the Mozilla framework and AjaxTerm which is an AJAX/Python terminal implementation. (Another recent project along these lines is TermKit.)
In addition to terminal features, GraphTerm implements file "finder" or "explorer" features, and also some of the detached terminal features of GNU screen. GraphTerm is designed to be touch-friendly, by facilitating command re-use to minimize the use of the keyboard.
GraphTerm is a terminal server, not just a terminal. Multiple users can connect to the terminal server simultaneously and share terminal sessions for collaboration. Also, multiple computers can connect to a single terminal server, allowing an user to manage several computers without having to log into each one separately.
Images of GraphTerm in action can be found in screenshots and in this YouTube Video. Here is a sample thumbnail/video of GraphTerm illustrating graphical gls and cat command output using a 3D perspective theme (captured on OS X Lion, using Google Chrome)
To install GraphTerm, you need to have Python 2.6+ and the Bash shell on your Mac/Linux/Unix computer. For a quick install, if the python setuptools module is already installed on your system, use the following commands:
(If setuptools is not installed, consider installing it using apt-get install -y python-setuptools on Debian Linux systems or its equivalent on other systems.)
For a manual install procedure, download the release tarball from the Python Package Index, untar, and execute the following command in the graphterm-<version> directory:
For the manual install, you will also need to install the tornado web server, which can be downloaded from https://github.com/downloads/facebook/tornado/tornado-2.3.tar.gz
You can also try out GraphTerm without installing it, after untarring the source tarball (or checking out the source from github). You can run the server gtermserver.py in the graphterm subdirectory of the distribution, after you have installed the tornado module in your system (or in the graphterm subdirectory).
You can browse the GraphTerm source code, and download the development version, at Github.
Documentation and updates can be found on the project home page, info.mindmeldr.com/code/graphterm, which also has some tutorials and examples for using GraphTerm. You can also use the following command:
to view a slideshow about GraphTerm within GraphTerm.
To report bugs and other issues, use the Github Issue Tracker.
To start the GraphTerm server, use the command:
Type gtermserver -h to view all options. You can use the --daemon=start option to run it in the background.
Once the server is running, you can open a terminal window on the localhost in the following ways:
To open a remote terminal window, open up a browser of your choice that supports websockets, such as Google Chrome, Firefox, or Safari (Chrome works best), and enter the following URL:
Once within the graphterm browser page, select the host you wish to connect to and create a new terminal session on the host.
Once you have a terminal, try out the following commands:
These are graphterm-aware scripts that imitate basic features of the standard ls and vi commands. To display images as thumbnails, use the gls -i ... command. Use the -h option to display help information for these commands, and read the UsingGraphicalFeatures tutorial for usage examples.
You can use the command which gls to determine the directory containing graphterm-aware commands, to browse for other commands, which include:
(There is also a sample gcowsay command which can be downloaded separately from its Github repository)
In the default theme, blue color denotes text that can be clicked or tapped. The action triggered by clicking depends upon two factors, whether there is text in the current command line, and whether the Control modifier in the Bottom menu is active. Click on the last displayed prompt to toggle display of the Bottom menu. Clicking on other prompts toggles display of the command output (unless the Control modifier is used, in which case the entire command line is copied and pasted.)
You can navigate folders in GraphTerm just like you would do in a GUI, while retaining the ability to drop back to the CLI at any time. If the current command line is empty, clicking on a folder or filename displayed by the gls command will change the current directory to the folder, or cause the file to be opened. If you have typed anything at all in the current command line, even if it is just a space, the clicking action will cause text to be pasted into the command line, without any command being executed. You can edit the pasted text, then press the Enter key to execute it.
Select icons in the top menu to activate icon display for commands like gls.
Themes, selected using the top menu, are a work in progress, especially the 3-D perspective theme (which only works on Chrome/Safari).
Click on the cursor before beginning the paste operation (on the command line, a box will appear at the cursor location). Then use the browser's paste menu command or a keyboard shortcut (like Command/Control-V) to paste the text. Alternatively, you can use the Actions->Paste special menu item.
Sort of works! You can drag a filename (grabbing the icon does not work) and drop it on a folder, an executable, or the command line. For drag-and-drop between two GraphTerm windows running on the same host, the file will be moved to the destination folder. For windows on two different hosts, the file will be copied. (Graphical feedback for this operation is not properly implemented at this time. Look at the command line for the feedback.)
If the command line is empty, up/down arrows will use the underlying shell for command recall (like Control-P and Control-N). If the command line contains any text, including whitespace, up/down arrows will cause GraphTerm to search for matching previous commands that begin with the text already typed (ignoring any leading whitespace). You can use the right arrow to complete the recalled command (for editing) or use the Enter key to execute it. Typing any other key, including the left arrow, will cancel the command recall process.
Click on the cursor to display virtual keyboard on the iPad. The Bottom menu, exposed by clicking on the lowermost prompt, can be quite useful on the iPad.
The default terminal type is set to xterm, but it may not always work properly. You can also try out the terminal types screen or linux, which may work better for some purposes. You can use the --term_type option when running the server to set the default terminal type, or use the export TERM=screen command. (Fully supporting these terminal types is a work in progress.)
More than one host can connect to the GraphTerm server. The local host is connected by default (but this can be disabled using the --nolocal option). To connect an additional host, run the following command on the computer you wish to connect:
where serveraddr is the address or name of the computer where the GraphTerm server is running (which defaults to localhost). You can use the --daemon=start option to run the gtermhost command in the background. By default, the Graphterm server listens for host connections on port 8899. The multiple host feature should only be used within a secure network, not on the public internet.
NOTE: Unlike the sshd server, the gtermhost command is designed to be run by a normal user, not a privileged user. So different users can connect to the GraphTerm server pretending to be different "hosts" on the same computer. (If you are running a Python server, it can connect directly to the GraphTerm server as a "host", allowing it to be dynamically introspected and debugged using otrace.)
For each host, sessions are assigned default names like tty1 etc. You can also create unique session names simply by using it in an URL, e.g.:
Anyone with access to the GraphTerm server can use the session URL to connect to it. This is like "screensharing", but more efficient, because only the content is shared, not the graphical themes. The first user to create a session "owns" it, until they detach from it. Others connecting to the same session have read-only access, unless they "steal" the session (see the Action menu). For example, if you forgot to detach your session at work, you can ssh to your desktop from home, use SSH port forwarding (see below) to securely access your work desktop, and then steal the session using your home browser.
NOTE: Although GraphTerm supports multiple users, it currently assumes a cooperative environment, where everyone trusts everyone else. (This may change in the future.)
A session path is of the form session_host/session_name. You can use the shell wildcard patterns *, ?,  in the session path. For example, you can open a wildcard session for multiple hosts using the URL:
For normal shell terminals, a wildcard session will open a "blank" window, but any input you type in it will be broadcast to all sessions matching the pattern. (To receive visual feedback, you will need to view one or more of the matching sessions at the same time.)
For otrace debugging sessions of the form */osh, GraphTerm will multiplex the input and output in wildcard terminals. Your input will be echoed and broadcast, and output from each of the matching sessions will be displayed, preceded by an identifying header (with the special string ditto used to indicate repeated output). See the otrace integration section for more information.
NOTE: Multiplexed input/output display cannot be easily implemented for regular shell terminals.
If you enable the Webcast in the top menu, anyone can use the session URL to view the session, without the need for authentication, but will not be able to steal it. Use this feature with caution to avoid exposing exposing sensitive data.
The glandslide command, which is a slightly modified version of the web-based slide slideshow program Landslide, can be used to create a slideshow from Markdown (.md) or reStructured Text (.rst) files. A few sample .md files are provided in the graphterm/bin/landslide directory of the distribution. To view a slideshow about GraphTerm, type:
Type h for help and q to quit slideshow. (The unmodified Landslide program can also be used, with the -i option, but remote sharing will not work.)
The gimage command, which displays images inline, can also be used for slideshows and simple presentations. Just cd to a directory that has the images for a slideshow, and type:
To select a subset of images in the directory, you can use a wildcard pattern. For publicly webcasting a slideshow, use the -b option.
A widget appears as an overlay on the terminal (like picture-in-picture for TVs, or dashboard widgets on the Mac). This is an experimental feature that allows programs running in the background to display information overlaid on the terminal. The widget is accessed by redirecting stdout to a Bash tcp socket device whose address is stored in the environment variable GRAPHTERM_SOCKET. For example, the following command will run a background job to open a new terminal in an overlay iframe:
You can use the overlay terminal just like a regular terminal, including having recursive overlays within the overlay!
A specific example of widget use is to display live feedback on the screen during a presentation. You can try it out in a directory that contains your presentation slides as images:
The first command uses gfeedback to capture feedback from others viewing the terminal session as a stream of lines from $GRAPHTERM_SOCKET. The viewers use the overlaid feedback button to provide feedback. The stdout from gfeedback is piped to gfeed which displays its stdin stream as a "live feed" overlay, also via $GRAPHTERM_SOCKET. (The gimage -f command displays all the images in the directory as a slideshow.)
To display a live twitter feed as an overlay on a presentation, you can use the commands:
The GraphTerm is not yet ready to be executed with root privileges. Run it logged in as a regular user. The --auth_code option can be used to specify an authentication code required for users connecting to the server. Although multiple hosts can connect to the terminal server, initially, it would be best to use graphterm to just connect to localhost, on a computer with only trusted users. You can always use SSH port forwarding (see below) to securely connect to the GraphTerm server for remote access. As the code matures, security will be improved through the use of SSL certificates and server/client authentication. (SSL/https support is already built in. Feel free to experiment with it, although it is not yet ready for everyday use.)
If you login to a remote computer using SSH, you can use the Action -> Export Environment menu option to set the Bash shell environment variables on the remote computer. This will allow some, but not all, of GraphTerm's features to work on the remote session. If you wish to use more features, set the PATH environment variable on the remote machine to allow access to gls and other commands, and also use reverse port forwarding to forward your local port(s) to the remote computer, e.g.:
Currently, the most secure way to access the GraphTerm server running on a remote computer is to use SSH port forwarding. For example, if you are connecting to your work computer from home, and wish to connect to the GraphTerm server running as localhost on your work computer, use the command:
This will allow you to connect to http://localhost:8900 on the browser on your home computer to access GraphTerm running on your work computer.
GraphTerm was originally developed as a graphical front-end for otrace, an object-oriented python debugger. Any Python program can serve as a "host" and be connected to the GraphTerm server using the gotrace command:
The above command loads example.py as a module and connects to the GraphTerm server for debugging. This program will appear in the list of hosts under the name example. Open the terminal session example/osh to connect to the otrace console, and issue the run <function> command to begin executing a function in example.py. You can also initiate program execution directly from the command line as follows:
The above command executes the function test(arg=) in example.py, where arg is a list of string arguments from the command line.
If you wish to use the otrace console features for multiplexing, without actually needing to a debug a program, you can use the --oshell option when using gtermhost to connect to the server.
(You can also embed code in a Python program to directly connect to the GraphTerm server for monitoring/debugging. See gotrace.py to find out how it can be done.)
The GraphTerm distribution includes the scripts ec2launch, ec2list, ec2scp, and ec2ssh to launch and monitor Amazon Web Services EC2 instances. These are the scripts used to test new versions of GraphTerm by running them in the "cloud". You will need to have an Amazon AWS account to use these scripts, and also need to install the boto python module.
To create an instance, use the ec2launch command. You will be presented with a "web form" to enter details of the instance to be launched. Once you fill in the form and submit it, a command line will be automatically created, with command options, to launch the instance. To launch another instance with slightly different properties, you can simply recall the command line and edit it. Ensure that the security group associated with the cloud instance allows access to inbound TCP port 22 (for SSH access), 8900 (for GraphTerm users to connect), and port 8899 (for GraphTerm hosts to connect).
To temporarily run a publicly accessible GraphTerm server for demonstration or teaching purposes, log in to the instance using the command ec2ssh ubuntu@instance_address, wait a few minutes for tornado and graphterm packages to finish installing, and then issue the following command:
Note: This is totally insecure and should not be used for handling any sensitive information.
Secondary cloud instances should connect to the GraphTerm server on the primary instance using the command:
For increased security in a publicly-accessible server, you can use a cryptic authentication code, and also use https instead of http, with SSL certificates. Since GraphTerm is currently in alpha status, security cannot be guaranteed even with these options enabled. (To avoid these problems, use SSH port forwarding to access GraphTerm on localhost whenever possble.)
A graphterm-aware program writes to to the standard output in a format similar to a HTTP response, preceded and followed by xterm-like escape sequences:
where <cookie> denotes a numeric value stored in the environment variable GRAPHTERM_COOKIE. (The random cookie is a security measure that prevents malicious files from accessing GraphTerm.) The opening escape sequence is followed by a dictionary of header names and values, using JSON format. This is followed by a blank line, and then any data (such as the HTML fragment to be displayed).
A graphterm-aware program can be written in any language, much like a CGI script. See the programs gls, gimage, giframe, gvi, gfeed, yweather, ec2launch and ec2list for examples of GraphTerm API usage. You can use the which gls command to figure out where these programs are located. The file gtermapi.py contains many helper functions for accessing the GraphTerm API. See also the gcowsay program for an example of a stand-alone GraphTerm-aware command.
The GraphTerm server may be run on your desktop or on a remote computer. Users create and access terminal sessions by the connecting to the Graphterm server on port 8900, either directly or through SSH port forwarding. By default, the localhost on the computer where the GraphTerm server is running is available for opening terminal sessions. Other computers can also connect to the GraphTerm server, on a different port (8899), to make them accessible as hosts for connection from the browser.
A pseudo-tty (pty) is opened on the host for each terminal session. By setting the PROMP_COMMAND environment variable, GraphTerm determines when the stdout of the previous command ends, and the prompt for the new command begins.
The connection between the browser and the GraphTerm server is implemented using websockets (bi-directional HTTP). The GraphTerm server acts as a router sending input from controlling browser terminal sessions to the appropriate pty on the host computer, and transmitting output from each pty to all connected browser terminal sessions.
GraphTerm extends the xterm terminal API by adding a new control sequence for programs to transmit a CGI-like HTTP response through standard output (via a websocket) to be displayed in the browser window. GraphTerm-aware programs can interact with the user using HTML forms etc.
GraphTerm is inspired by two earlier projects that implement the terminal interface within the browser, XMLTerm and AjaxTerm. It borrows many of the ideas from XMLTerm and re-uses chunks of code from AjaxTerm. The server uses the asynchronous Tornado web framework and the client uses jQuery.
The 3D perspective mode was inspired by Sean Slinsky's Star Wars Opening Crawl with CSS3.
GraphTerm was developed as part of the Mindmeldr project, which is aimed at improving classroom interaction.