Name: simple-dotfiles
Owner: Cornell CS 2043
Description: A relatively minimal set of useful aliases, examples for bash_profile but none that we will use yet.
Created: 2016-02-08 12:49:20.0
Updated: 2017-10-21 16:44:19.0
Pushed: 2016-10-14 06:56:01.0
Homepage: null
Size: 22
Language: VimL
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A relatively minimal set of useful aliases, examples for bash_profile but none that we will use yet, and a sultry vimrc and colors.
Inspiration drawn from dotfiles I received from the instructor (Hussam Abu-Libdeh) when I was a student in this class, as well as from Adam Stewart's dotfiles.
I have created a minimal version to mirror what we are learning in class.
Adam's dotfiles
repository does a lot of really fancy things that I will not cover. You are welcome to use his instead, but please do note that it affects a lot more and I will not go through what all of it is doing.
The colors included in this bashrc are only amenable to dark terminal background.
cd ~
git clone https://github.com/cs2043-sp16/simple-dotfiles.git
cd simple-dotfiles/
I had originally included a script to do this, but the script was bad in that if you ran it more than once, you would have lost your original dotfiles.
mkdir ~/dotfiles_backup
ke backups of the bash dotfiles
mkdir ~/dotfiles_backup/bash_backups
cp ~/.bashrc ~/dotfiles_backup/bash_backups/ORIG_BASHRC
cp ~/.bash_profile ~/dotfiles_backup/bash_backups/ORIG_BASH_PROFILE
ke backups of the vimrc, if applicable
mkdir ~/dotfiles_backup/vim
cp ~/.vimrc ~/dotfiles_backup/vim/ORIG_VIMRC
ke a backup of the ~/.profile if it exists
cp ~/.profile ~/dotfiles_backup/profile
Note that if you did not already have a ~/.bashrc
, then cp
will tell you so. Don't worry, this is not there on OSX. Similarly, unless you already had a ~/.vimrc
there is nothing to backup.
Replace the contents of the bashrc file:
cat bash_addons/bashrc > ~/.bashrc
Replace the contents of the bash_profile file:
cat bash_addons/bash_profile > ~/.bash_profile
Replace the vimrc contents, and create the colors directory for vim to behave correctly with the provided vimrc.
ke the vimrc have the right contents
cat vim_addons/vimrc > ~/.vimrc
eate the appropriate directory structure for colors, put the monokai theme there
mkdir -p ~/.vim/colors/
cp vim_addons/colors/monokai.vim ~/.vim/colors/
Because we are using bash
in this class, we want to source our .bash_profile
from the .profile
. This is the appropriate way to do it, even though you often see people sourcing it from the bashrc
. You can accomplish this by simply doing
cat profile >> ~/.profile
Noting that I have two » characters! That says “append to the end of the file”, where a single > will overwrite the entire thing. Depending on what distribution you are running, there may be a lot more in that file that you want to leave alone.
Assuming you have made the backups, simply cat
the backup file you made from your desktop and redirect that to the designated file. For example, if I wanted to restore the original bashrc
, then I would just do
cat ~/dotfiles_backup/bash_backups/ORIG_BASHRC > ~/.bashrc
to restore it to the original. This is particularly meaningful with the Ubuntu virtual machine, as they had different ls
aliases than I do. Note again that I am now using a single > to say overwrite the entire file.
Aside from this prompting the extended directions, I have included a folder ORIGINAL with an Ubuntu and Fedora folder inside. Neither of these come with a .vimrc
by default, and none of the files we just made / modified existed in OSX.
This is because we just modified some important files!
Changes to the ~/.vimrc
get reloaded everytime you launch a new instance of vim.
Changes to the ~/.bashrc
can be loaded in if you execute this in your terminal
source ~/.bashrc
which is the same thing as
. ~/.bashrc
Changes to the ~/.bash_profile
and ~/.profile
only show up after you log out and then log in. Not quit terminal and restart it, but completely log out and log back in. You can also source ~/.profile
to load them both, but that will only take effect for the current terminal session, as well as if and when you do have things defined in your ~/.bash_profile
that have meaning, there are often other programs that may need those definitions other than your terminal. What and when and why depend entirely on what you are doing…
Lastly, these all need to be in your HOME directory, which is referenced by ~
. They must all also start with a .
, which will be true if you were copy pasting my commands above. So if you do ls -al ~
you should see .bashrc
, .bash_profile
, etc. If you see bashrc
without a .
in front of it, that is why it is not working.
Inside the bash_addons
directory are a bashrc and a bash_profile, that contain some useful shortcuts as well as the terminal colors that I use. These colors are best used on a dark background, but you are more than welcome to choose your own!
To include your own, you need to determine what they will be first. This website is great for helping you do that:
http://geoff.greer.fm/lscolors/
It will help you get a reasonable idea of what they will look like. When you look inside of the bash_addons/bashrc
, you will see something similar to
(uname)
"$OS" in
'Darwin')
export LSCOLORS='FxFxBxDxCxegedabagacad'
;;
'Linux')
export LS_COLORS='di=1;35;40:ln=1;35;40:so=1;31;40:pi=1;33;40:ex=1;32;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
;;
*)
echo "Unknown OS: $OS"
;;
You will need to change the LSCOLORS
for Darwin
(Mac) and LS_COLORS
for Linux
, noting that the format (including the variable name) is quite different for the two. The website linked above gives you both formats! But it doesn't always get it perfect. If you have this in your ~/.bashrc
, your terminal will complain if the value in LS_COLORS
is not formatted properly.
The colors presented in the example bashrc
are only appealing on a dark background (mine is a semi-transparent monokai black). You will need to change the background of your terminal now.
There are many different configurations you can use, but since I very much approve of what Adam has done, I just stole his. The original version (including comment styling) came from the dotfiles I received when I was a student, but Adam has been actively updating and modifying it to an almost unhealthy degree. It will set some pretty incredible features such as code folding, better syntax highlighting, and much much more. Read the vimrc file to see what is there.