Raspberry Pi Computer Architecture Essentials
上QQ阅读APP看书,第一时间看更新

Installing Screen and Vim

Two useful tools to install on your Raspberry Pi 2 are Screen—a terminal multiplexor—and Vim—a text editor.

We will be installing these via a package management tool called apt-get. A package management tool is used for installing extra software onto your operating system. It makes the process easy by keeping track of and downloading any libraries or dependencies needed by the software. It also makes upgrades and removal quite simple.

You can read more about apt-get at http://linux.die.net/man/8/apt-get.

Before installing Screen and Vim you should update the cache of the apt-get repository. This can be done by running the following command:

sudo apt-get update

We are now ready to install our terminal multiplexor.

We will start by installing Screen. This will allow you to keep multiple bash shells open when you login and out of your Raspberry Pi, so you can leave applications running while you are not directly connected to the device.

Note

The Bourne Again Shell (bash) is the shell used in Raspbian by default. You can read more about it here: https://www.gnu.org/software/bash/

To install Screen you can use the apt-get package manager:

sudo apt-get install screen

Once installation is complete, to run Screen you simply type the following command:

screen

The Screen application will now load, allowing you to create multiple windows containing bash sessions. To create a new window in the screen session type the following command:

Ctrl + a then c

If you want to remove a window you can kill it. The command to do this is as follows:

Ctl + a then k

When you have multiple windows open you will want to navigate between them. To move between each open window use the following command:

Ctrl + a then num #where num is the screen number, for example 1 or 3

To give the screens window a user friendly name type this command:

Ctrl + a then Shift + a.

This will give you a prompt where you can label the window for ease of use.

To detach from a screen session type the following command:

Ctrl + a then d

To re-attach you can then type this command:

screen –x

If more than one screen session is open, type the ID in after the -x, for example:

screen –x 1234

More information can be found at https://www.gnu.org/software/screen/manual/screen.html.

By default, the Screen application is very plain looking. However, its look and feel can be modified through a .screenrc file.

To learn more about this process, check out the gnu.org site's section on customizing screen at https://www.gnu.org/software/screen/manual/html_node/Customization.html#Customization.

Vim – an optional handy text editor

In addition to the text editors installed by default with Raspbian, you may also wish to install Vim, a powerful text-editing tool. You will see this tool referenced later in this book, so you may find it easier to follow along if you install this.

To install it via our package manager run the following command:

sudo apt-get install vim

Vim is a complex tool but if you persist with it, you will find it rewarding. A guide can be found here: http://vimhelp.appspot.com/.

Finally, there are a number of other text editors worth exploring if you wish. You can find a list at the official Raspberry Pi website here: https://www.raspberrypi.org/documentation/linux/usage/text-editors.md.