Command Line Navigation Tutorial
A majority of Freesurfer tools are command-line based. This short tutorial touches upon a few basic command-line key sequences which helps navigating. You just need to open the terminal for this tutorial.
A typical command in a Freesurfer environment looks like the following. Type the following in your terminal and press Enter to view the current date.
For our illustration, we'll use the following command. Type this but don't press Enter. In fact, we won't use Enter anymore since we'll be operating on this single command.
mksurfer subject lh inflated
Now, the cursor will be at the end of the command. We notice that instead of tksurfer, we have typed mksurfer. The normal method would be to use the left arrow key to go to the beginning of the command and replace m with t. However, a faster way is to use Esc-b ( type Escape key and the b key in immediate succession ). This key takes your cursor one word back. Repeat the key sequence few times to go to the start of the command. The navigation in opposite direction is Esc-f which takes you one word forward. Shuttle between the beginning and the end a few times by taking word jumps.
A faster way is to simply use Ctrl-a which takes you to the beginning of the command directly. Use this to go to the beginning and change m to t. And it's counterpart Ctrl-e takes you to the end of the command. Shuttle between the two boundaries of the command a few times.
Ctrl-l is a special sequence which is used to clear the screen. It'll clear the screen and place your prompt and the command in the first line of the cleared screen. Press Ctrl-l now and clear the screen. Note that the command is still intact.
Esc-b : one word back
Esc-f : one word forward
Ctrl-a : Go to the beginning of the command. ( a is the first letter of alphabet )
Ctrl-e : Go to the end of the command.
C-l : C-l-ear
Now, go to the end of the command... Yes, Ctrl-e. You should be at the end of the word inflated. Suppose you want to view the white surface, you must replace inflated with white. Press Esc-Backspace to delete from the cursor to the start of the word. Type in white. Your command should look like this now:
tksurfer subject lh white
Suppose you want to view the right hemisphere - rh instead of lh. Try and go to the start of the word lh.. Yes, Esc-b two times. Press Esc-d to delete from the cursor to the end of the word. Type rh. Your command will look like
tksurfer subject rh white
Many times, you would want to delete characters till the end of the current line. Suppose you are between the words tksurfer and subject. ( Navigate there using the sequences.) You want to change the subject to sub1, rh to lh and white to pial, it's wiser to delete everything from the cursor position to the end of the command. Ctrl-k does just that. It kills everything from cursor to end. Try and delete till end of command and type such that your new command looks like:
tksurfer sub lh pial
Think of the key Esc as a substitute for word. We have seen that Esc-b and Esc-f take you back and forward by one word respectively.
Esc-Backspace : Delete a word back
Esc-d : Delete a word forward ( Normal delete )
Ctrl-k : kill till the end of command.
- This tutorial touches upon only a tiny subset of command line navigation key sequences. These are pretty common sequences, however. Also, introducing too many sequences clutter the mind.
The command line interfaces use a library called Readline. Its documentation is rather extensive.
The Esc key is called Meta key in Readline parlance. If Esc doesn't work, Alt most probably will.
- Instead of learning more sequences, it's better to master these basic sequences (practice!) and then build upon once you are comfortable with these.