User Tools

Site Tools


setting_up_your_terminal_environment

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
setting_up_your_terminal_environment [2021/05/11 22:22] – created 168.91.18.151setting_up_your_terminal_environment [2023/07/25 12:02] (current) – [The Terminal] 134.190.232.186
Line 1: Line 1:
 Documentation by Joran Martijn (11 May 2021) Documentation by Joran Martijn (11 May 2021)
 +
 +==== The Terminal ====
  
 By default the terminal is a very monotone and hard to navigate. The prompt is indistinguishable from the commands and the output, and the 'ls' output looks the same whether they are files or directories. We can configure our terminal experience by modifying the so-called ''.bashrc'' file. By default the terminal is a very monotone and hard to navigate. The prompt is indistinguishable from the commands and the output, and the 'ls' output looks the same whether they are files or directories. We can configure our terminal experience by modifying the so-called ''.bashrc'' file.
  
 The ''.bashrc'' file is loaded whenever you open a new terminal session, either by simply opening the Terminal program or by SSHing into a remote server. The ''.bashrc'' file is loaded whenever you open a new terminal session, either by simply opening the Terminal program or by SSHing into a remote server.
 +
 +NOTE: Logging into Perun seems to be an exception and does not load the ''.bashrc'' by default on login. It instead attempts to load the ''.bash_profile'' file, which is also located in your home folder. If you don't have it, simply create it via ''touch ~/.bash_profile'' and then edit it so it includes the following
 +
 +<code>
 +if [ -f $HOME/.bashrc ]; then
 +        source $HOME/.bashrc
 +fi
 +</code>
 +
 +Now, when you login, the ''.bash_profile'' is loaded, which in turn loads the ''.bashrc'' file.
  
 === Adjusting the look of the prompt === === Adjusting the look of the prompt ===
Line 24: Line 36:
 export PS1="\[\e[00;37m\][\[\e[0m\]\[\e[00;31m\]\h\[\e[0m\]\[\e[00;37m\]][\[\e[0m\]\[\e[00;32m\]\u\[\e[0m\]\[\e[00;37m\]][\[\e[0m\]\[\e[00;33m\]\w\[\e[0m\]\[\e[00;37m\]] \[\e[0m\]" export PS1="\[\e[00;37m\][\[\e[0m\]\[\e[00;31m\]\h\[\e[0m\]\[\e[00;37m\]][\[\e[0m\]\[\e[00;32m\]\u\[\e[0m\]\[\e[00;37m\]][\[\e[0m\]\[\e[00;33m\]\w\[\e[0m\]\[\e[00;37m\]] \[\e[0m\]"
 </code> </code>
 +
 +=== Colored ls output ===
 +
 +By default, the ls output is very bland and not very user friendly. Let's change that.
 +Add to your ''.bashrc'':
 +
 +<code>
 +alias l=‘ls -lap --color=auto’
 +alias ll=‘ls -lp --color=auto’

 +alias ls=‘ls -p --color=auto'
 +</code>
 +
 +The ''--color=auto'' ensures that directories are shown in blue, and executable files like scripts in green, while regular files are the standard color. The ''-p'' further adds trailing slashes to directories to highlight directories even more. ''-a'' toggles hidden files and ''-l'' toggles detailed view.
 +
 +=== Moving around efficiently ===
 +
 +Moving around on the filesystem can demand a lot of key strokes, especially if you need to type a very long cd command. I find it very useful to "mark" commonly visited locations in the filesystem, such as base directories of certain projects or directories where you store your git repositories or scripts by setting a number of aliases. Add these to your ''.bashrc'' :
 +
 +<code>
 +alias cdscripts='cd /path/to/scripts'
 +alias cdproj1='cd /path/to/proj1'
 +alias cdproj2='cd /path/to/proj2'
 +</code>
 +
 +In addition, invoking ''cd'' will take you to your home directory, and ''cd -'' takes you to the previous directory you were in
 +
 +=== Other useful aliases ===
 +
 +<code>
 +## editor shortcuts
 +alias e='emacs -nw'
 +alias v='vim'
 +
 +## common commands
 +alias a='source activate'
 +alias d='conda deactivate'
 +alias editb='emacs -nw ~/.bashrc'
 +alias loadb='source ~/.bashrc'
 +</code>
 +
 +
setting_up_your_terminal_environment.1620782543.txt.gz · Last modified: by 168.91.18.151