Customising Your Terminal

Basics

Each time your Terminal is opened, a series of scripts are also run. Some of these are intended to be personally customised, allowing for customisation of your Terminal experience. This functionality ranges from visual changes, through personal shortcuts (aliases) to personal functions. This topic if endless, but here are some key points.

Aliases

Some commands are typed a lot, making them a pain/waste of time. For example, you'll often be sshing into plum-p1 with the following:

ssh -X [email protected]

This command can be saved as a single variable if assigned as such in your .bashrc (or .bash_profile on Mac OS) file. For example, the following would call the same command from simply typing 'p1'.

alias p1='ssh -X [email protected]'

You can apply this principle to any command sent to the Terminal.

Functions

Just as you can create functions within R or Python, you can also create these within the Terminal. By default your Terminal should be using the 'bash' language, these functions are written in that language.

As an example, the following is an alternative to the default watch function. Default watch is designed to periodically run a command (usually tail or less), but it can break with certain types of loading bars. The following will resolve that bug. It works by infinitely looping a process of clearing the terminal output, printing the datetime, printing the process which follows watch2, waiting two seconds, and looping again.

function watch2() { while true; clear; date; echo; do $@; sleep 2s; done }

You can make similar functions to whatever purpose you want.

results matching ""

    No results matching ""