The Linux environment allows for much customization, all of which can be done through configuration/dotfiles files.
As a quick start/reference, you can obtain dotfiles for bash, vim, and tmux at this Github page. This repository can be download by doing a git clone https://github.com/mattpotok/dotfiles.git. When you cd
into the dotfile directory, you won't actually be able to see the files because the preceding '.' makes the files hidden. To view them you can do a ls -a
.
After downloading the repository, you can hide the directory by renaming it with a preceding .
as follows: mv dotfiles .dotfiles
. This will hide the directory when you do an ls
, but it can be displayed with an ls -a
.
If you are on a personal Linux machine, then you can run sudo ./install.sh
. This will run the packages that were deemed necessary, link the dotfiles, and configure vim. There is also an option to generate ssh-keys in the case that you will require them.
If you are on a EWS machine, you don't have sudo access and won't be able to run the script. In this case, you will either have to manually copy or link the necessary dotfiles from the clones repository to you home directory. This can be achieved by doing the following:
cp <dotfilePath>/<dotfile> ~/<dotfile>
OR
ln -sf <dotfilePath>/<dotfile> ~/<dotfile>
OR
ln -f <dotfilePath>/<dotfile> ~/<dotfile>
where the first command copies the file, the second creates a soft link and the third creates a hard link. To understand the difference between hard and soft links, you should read this article. (The install script uses soft links). The recommended dotfiles to copy/link are: .bash_aliases
, .bashrc
, .tmux.conf
, .vim
, and .vimrc
. In addition to this, you will need to install the the Vundle plugin for Vim because is defined in the .vimrc
file and each time you open Vim, it will complain that it can't locate the plugins. To do so just run the following two commands:
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
These are the files that personalize the shell. The files and there functions are listed below:
.bashrc:
this file controls the looks of the shell and is executed for interactive non-login shells. At the top, there is a list of colors that can be used to personalize messages such as the one at the very bottom of the file. You can redefine a few of the environmental variable to suit your needs as well as the PS1 variable which controls how your username is displayed before each command. Although the PS1 looks rather complicated, it is actually rather straight-forward if you follow along with this guide. You can also define custom functions such as 'mkcd' which creates a directory and cd's into it in one command.
.bash_aliases:
this files allows you to define an alias for a command such as aliasing 'cd ../../
' with '...
' which is much shorter and simpler to type out.
.bash_profile:
this is the file launched for a login shell and simply sources the .bashrc
file instead of redefining the contents of .bashrc
.profile:
similar to the .bash_profile
but isn't bash specific.
Vim is a wonderful command line editor that is highly recommended. Although it has a rather steep learning curve, it will allow you to navigate and edit the file very quickly and efficiently. The vim configuration is controlled by the .vimrc
file and .vim
directory. The .vimrc
file makes use of the Vundle plugin manager which allows for the installation of plugins to extend the usability of Vim. To learn the Vim shortcuts, it is recommended that you complete the exercises in vimtutor
(simply type that in the terminal and it will take you to a tutorial) and look at the many cheat sheets available online.
.vimrc:
controls Vim settings and any Vundle plugins. You can find the descriptions for all these settings at the Vim wiki pages.
.vim:
contains the source code the Vundle plugins as well as the colorscheme. The color scheme can be changed by copying a *.vim
file into the color directory and specifying the *.vim
file in the .vimrc. Alternatively, you can edit the oceannight.vim
file.
Tmux is a terminal multiplexer which allows you to open multiple windows in a single in a single shell instead of having to open up multiple shells. The following page contains a list of tmux shortcuts. Note however, that the .tmux.conf
file in the dotfile directory has remapped some of the keys so that the prefix is Ctrl-space instead of Ctrl-b and splits are |
for vertical and -
for horizontal. Please take a look at the configuration file itself to see any other changes in the shortcuts.