Linux Format

Terminal Custom profiles

Nick Peers reveals how the terminal can be customised for different uses with the help of custom profiles.

-

Nick Peers reveals how the Terminal can be customised for different uses with the help of custom profiles.

Ubuntu’s default terminal is the Gnome-Terminal, and one of its lesser known features is support for profiles. Profiles are a collection of terminal settings, including profile name, font and background colours, and scrolling. In addition, profiles can be set to run a specific command or shell on startup, launch to a specific screen and even connect to a remote computer via SSH.

This flexibilit­y makes it easy to see why a single user might want to develop more than one profile for using the terminal – you may, for example, regularly administer another PC via SSH, such as a headless Pi Zero running a Mopidy music server (see LXF218). In this case, you could create a profile that logs you directly into your Pi Zero, one that uses a different colour scheme to help you differenti­ate that terminal window from any others you might also be running.

Create and manage profiles

In a departure from the norm, you can’t use the command line to create and manage profiles – the dconf tool can be used from the shell once you’ve set up a profile, but it can only be used to view and make changes to settings you’ve configured following the tips and advice below. The box reveals what you can do using the dconf tool.

So, to create your first custom profile, you need to open the terminal, then select File > New Profile. A dialog box will appear consisting of five tabs. Start by giving your profile a suitably descriptiv­e name that you’ll use to select when switching profiles going forward.

Before going further, click the Close button, then switch to your new profile via the Terminal > Change Profile menu. Now select Edit > Profile Preference­s to reopen the Editing Profile dialog – doing this logs you in as your new profile as you make changes, so any tweaks you make are applied in real time and can be previewed in the terminal window as you go. If you’re looking to experiment with colour schemes, different fonts and so on, it’s a must.

The General tab also includes options for setting the initial size of your terminal window in columns and rows – 80x24 is the default. You can also change the cursor shape from the default Block to I-Beam (a straightfo­rward flashing vertical line used by the likes of LibreOffic­eWriter) or Underline – you’ll see the cursor update as you switch between them.

Untick the Terminal Bell box if you don’t want to receive audio notificati­ons via your PC’s internal speaker – sadly, you can’t choose to switch on visual (ie, flashing) notificati­ons in its place for specific profiles. The final three options found under the General tab are self-explanator­y, and start with a setting for disabling bold text. You can also specify whether to allow text to automatica­lly rewrap when manually resizing the terminal window, plus choose a custom font for the display.

The dconf tool reveals that the custom font option comprises two separate settings. The first – “use-systemfont” – determines if you’re using the system font or not, with a simple true (unticked) or false (ticked) value. The second – “font” – only works when “use-system-font” is set to false, and determines the replacemen­t font, style and size.

More customisat­ion options

Switch to the Colours tab next to set your text and background colours – untick Use Colours From System Theme and you can quickly switch to a different built-in scheme (such as green text on a black background) or manually specify colours using the various colour pickers. You can also switch on transparen­cy, then use the slider to blend

the terminal window into the background. The Palette section lets you set individual colours – again you can choose between various built-in schemes or opt for Custom to handpick each colour.

The Scrolling tab controls the terminal’s behaviour in four different ways: first, you can opt to show or hide the scrollbar (if you hide it, you’ll need to scroll exclusivel­y using your mouse wheel or by trackpad gesture). Scroll on Output is unticked by default, so you can scroll upwards with the mouse to stop scrolling automatica­lly when a large amount of output is being produced. Ticking this option disables your ability to do this.

Scroll on Keystroke is ticked, and works in a similar way as Scroll on Output, except it’s linked to your actual keystrokes, and for that reason is best left as it is. Finally, Limit Scrollback To reveals how many terminal lines of output are stored in memory – this buffer is cleared every time you restart a terminal session, so you may want to reduce the number if you’re low on memory and need to produce large volumes of output without referring to earlier lines. If you’d rather not limit this at all – not recommende­d except where you’ve plenty of RAM to spare – then set the figure to 0, but beware sluggish performanc­e.

The Compatibil­ity tab allows you to alter the behaviour of the Backspace and Delete keys, plus set the default encoding for your terminal session. The final option – Ambiguous-width Characters – can be set to Wide should you work with certain languages or characters, such as Greek, or Asian logograms.

Custom commands

Now you’ve prettified your profile, it’s time to tackle the Commands tab, where you’ll find two check boxes. To run a simple command on launching the profile, tick Run a Custom Command Instead of My Shell, then enter your chosen command into the Custom Command box. For example, to log on to a remote computer: ssh user@compname

The When Command Exits dropdown menu allows you to determine what happens when the command is completed – by default, the terminal window will exit, but you can choose Hold the Terminal Open or Restart the Command too. If you’re executing a simple command like sudo apt-get update , then the former is the sensible choice.

Note that when you use the custom command to log on remotely to another computer, the When Command Exits: action is implemente­d when you manually close the connection, typically using the Exit command. Choose Hold the Terminal Open, for example, and you’ll see a pop-up menu appear with a handy Relaunch button if you want to reconnect immediatel­y for whatever reason.

The Command tab also houses the Run Command as a Login shell option – tick this to have the terminal read the

.profile file – which is the main system wide initialisa­tion file that’s executed when logging into the shell directly – rather than the .bashrc file, which is used when you open terminal via the Unity desktop. You’ll know if or when you need it.

Complete your tweaks

That concludes the process of creating and editing your first profile. When you next open the terminal, it’ll default to your basic profile, but you can easily switch following the advice in the second box. Need another custom profile? Choose File > New Profile again to create one based on the currently selected profile, complete with same name and settings, ready for you to fine-tune. If you want to create a new profile from scratch, choose Edit > Preference­s and switch to the Profile tab.

Here you’ll see a list of all existing profiles – click New to create your blank new profile, or select a profile from the list and click Clone to create one based on that template. You can also edit profiles from here without having to switch to them first, plus delete unwanted profiles too.

Last, but not least, you’ll also see a dropdown menu at the bottom – Profile Used When Launching a New Terminal. Use this to pick the default profile that’s selected when you launch terminal (or open a new terminal window) in future.

 ??  ?? Profiles are created and set up via the Profile Preference­s dialog box, accessed through the terminal’s Edit menu.
Profiles are created and set up via the Profile Preference­s dialog box, accessed through the terminal’s Edit menu.
 ??  ?? Set your default profile via this dialog box – it’s also where you go to manage your profile collection.
Set your default profile via this dialog box – it’s also where you go to manage your profile collection.

Newspapers in English

Newspapers from Australia