Tune Your Dot Files
Author: Stu FeeserAlta3 Research’s Stu Feeser explains the process:
Objectives:
- Make your environment easy for students to follow.
- Remove the irritating bell sounds that compete with the lesson and your sanity.
Tasks:
-
Make your bash prompt interesting (read gaudy). It’s helpful for my students to track a vivid prompt to delimit my activity. Go here to create the perfect bash prompt
My favorite:
export PS1="\[[33m\]\u\[[m\]\[[35m\]@\[[m\]\[[36m\]\h\[[m\]\[[35m\]:\[[m\]\[[32m\]\w\[[m\] \[[35m\]\$\[[m\] " -
Once you like what you see, save the prompt at the bottom of your
.bashrcfile like this::wqto save and quit, ORq!to quit without saving if you made a mistake.~ $vim .bashrcPS1="\[[33m\]\u\[[m\]\[[35m\]@\[[m\]\[[36m\]\h\[[m\]\[[35m\]:\[[m\]\[[32m\]\w\[[m\] \[[35m\]\$\[[m\] " -
Set vim as the default editor.
~ $sudo update-alternatives --config editor3Select option 3 -
Remove the irritating CLI BELL by editing the /etc/inputrc file. (Yes, this is repeated from the last lab).
~ $echo 'set bell-style none' | sudo tee -a /etc/inputrc -
Get rid of the vim bell. This creates a .vimrc as it will not be there on new installations.
~ $vim .vimrcset belloff=all
Create your Github Repository!
-
Click on Repositories at the top.
-
Click New on the right-hand side.
-
Fill in your Repository name, make it private, then click the checkbox to make a README file.
-
Now click Create Repository.
Backup your dotfiles!
-
Create a bare repository called
.dotfiles~ $mkdir $HOME/.dotfiles~ $git init --bare $HOME/.dotfiles -
Create an alias to issue git commands while NOT being inside the .dotfiles directory.
~ $alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' -
Add the dotfiles alias to your .bashrc.
vim .bashrcalias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' -
This is important for your understanding. From here on out, when you type
dotfilesit is like typing:git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' PLUS WHATEVER ELSE YOU TYPE -
Don’t show untracked files, as there will be too many in your $HOME directory!
dotfiles config --local status.showUntrackedFiles no -
Target your github account, NOT
sfeeser!dotfiles remote add origin git@github.com:sfeeser/.dotfiles.gitIf you accidentally run the command exactly as above, you can fix that with
dotfiles remote remove originand then update the command to your github account. -
Add the .bashrc file you just created.
~ $dotfiles add .bashrc -
Purely FYI, the above command =
git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME add .bashrc -
Tell github who your are.
~ $git config --global user.email "youremail@address"
~ $git config --global user.name "yourusername" -
Commit your change.
~ $dotfiles commit -m "add .bashrc" -
Push your changes.
~ $dotfiles push --set-upstream origin master
Recovery at a new machine
-
Pull down the
.dotfilesusing your account, not sfeeser.~ $git clone --separate-git-dir=$HOME/.dotfiles https://github.com/sfeeser/.dotfiles.git ~ -
If the command above doesn’t work, clone to a temp directory and use rsync to bring it all back. Use your account, not sfeeser.
~$git clone --separate-git-dir=$HOME/.dotfiles https://github.com/sfeeser/.dotfiles.git tmpdotfiles~$rsync --recursive --verbose --exclude '.git' tmpdotfiles/ $HOME/~$rm -r tmpdotfiles

