Skip to content

sinewalker/dotfiles

 
 

Repository files navigation

Dotfiles

Linux and macOS dotfiles. Forked from Cowboy's dotfiles, by way of ASharpe's dotfiles. A more detailed background is in HISTORY.


Note: This project is currently Mastered at GitHub and Pulled to GitLab


About this project

A single command, dotfiles, to "bootstrap" a new ${HOME} directory and pull down personal dotfiles and config's, as well as install the tools I commonly use.

dotfiles may be re-executed at any time to synchronize anything that might have changed (e.g. after a git pull of this repo, or to install a new tool listed in one of the Init steps).

Additionally, having this on a central github repo makes it easy to re-integrate changes back in (via git push) so that other machines can be updated by re-synchronizing.

How the "dotfiles" command works

When dotfiles is run for the first time, it does a few things:

  1. If necessary, git is installed via the native OS package manager
  2. This repo is cloned into your ${HOME} directory (~/), under ${DOTFILES} (~/.dotfiles/, unless you change it in dotfiles).
  3. Files in copy/ are copied into ~/. (read more)
  4. Files in link/ are symlinked into ~/. (read more)
  5. You are prompted to choose scripts in init/ to be executed. The installer attempts to only select relevant scripts, based on the detected OS and the script filename.
  6. Your chosen init scripts are executed (in alphanumeric order, hence the funky names). (read more)

On subsequent runs, step 1 is skipped, step 2 just updates the already-existing repo, and step 5 remembers what you selected the last time. The other steps are the same.

Other subdirectories

  • The ansible directory contains Playbooks and other settings for installing applications on Linux systems
  • The backups/ directory gets created when necessary. Any files in ~/ that would have been overwritten by files in copy/ or link/ get backed up here.
  • The bin/ directory contains executable shell scripts (including the dotfiles script) and symlinks to executable shell scripts. This directory is added to the $PATH.
  • The caches/ directory contains cached files, used by some scripts or functions.
  • The config/ directory contains configurations for applications, linked to the user config directory (~/.config, or whichever is specified by $XDG_CONFIG)
  • The lib/ directory contains environment libraries, such as Vagrant, or Node, linked into ~/lib -- so that heavy runtimes like Vagrant Boxes are not stored within ~/.dotfiles/lib/ and difficult to find.
  • The misc/ directory just exists. If a config file doesn't need to go in ~/, reference it from the misc/ directory.
  • The source/ directory contains files that are sourced whenever a new shell is opened (in alphanumeric order, hence the funky names).
  • The test/ directory contains unit tests for especially complicated bash functions.
  • The vendor/ directory contains third-party libraries.

The "copy" step

Any file in the copy/ subdirectory will be copied into ~/. Any file that needs to be modified with personal or private information (like copy/.gitconfig which contains an email address and private key) should be copied into ~/, and then updated manually to add the private information. Because the file you'll be editing is a copy and no longer in ~/.dotfiles/, it's less likely to be accidentally committed into your public dotfiles repo.

The "link" step

Any file in the link/ subdirectory gets symlinked into ~/ with ln -s. Edit one or the other, and you change the file in both places. Don't link files containing sensitive data, or you might accidentally commit those data! If you're linking a directory that might contain sensitive data (like ~/.ssh/) add the sensitive files to your .gitignore file!

The "init" step

Scripts in the init/ subdirectory will be executed whenever dotfiles is executed. A whole bunch of things will be installed, but only if they aren't already.

macOS (OS X)

Ubuntu

All systems

Hacking dotfiles

Because the dotfiles script is completely self-contained, you should be able to delete everything else from your dotfiles repo fork, and it will still work. The only thing it really cares about are the copy/, link/ and init/ subdirectories, which will be ignored if they are empty or don't exist.

If you modify things and notice a bug or an improvement, file an issue or a pull request and let Cowboy know (better that you fork from Cowboy's repo than mine as well, by the way).

Also, before installing, be sure to read the gently-worded note.

Installation

macOS Notes

You need to have XCode or, at the very minimum, the XCode Command Line Tools, which are available as a much smaller download.

The easiest way to install the XCode Command Line Tools in OSX 10.9+ is to open up a terminal, type xcode-select --install and follow the prompts.

Tested in OSX 10.10

Ubuntu Notes

You might want to set up your ubuntu server like Cowboy does it, but then again, you might not.

Either way, you should at least update/upgrade APT with sudo apt-get -qq update && sudo apt-get -qq dist-upgrade first.

Tested in Ubuntu 14.04 LTS

Heed this critically important warning before you install

If you're not me, please do not install dotfiles directly from this repo!

Why? Because I often completely break this repo while updating. Which means that if I do that and you run the dotfiles command, your home directory will burst into flames, and you'll have to go buy a new computer. No, not really, but it will be very messy.

Actual installation (for you)

  1. Read the gently-worded note
  2. Fork Cowboy's dotfiles
  3. Open a terminal/shell and do this:
export github_user=YOUR_GITHUB_USER_NAME

bash -c "$(curl -fsSL https://raw.github.com/$github_user/dotfiles/master/bin/dotfiles)" && source ~/.bashrc

Since you'll be using the dotfiles command on subsequent runs, you'll only have to export the github_user variable for the initial install.

There's a lot of stuff that requires admin access via sudo, so be warned that you might need to enter your password here or there.

There's an optional step you can do after installing: you can add this repo as a git remote, so that you can look at my own changes which are different to Cowboy's, and cherry pick commits or just copy in the parts you like:

git remote add sinewalker git@github.com:sinewalker/dotfiles.git

(There are other remotes that you may find interesting too, see remotes.txt, which was produced from the following git command)

git remote -v > remotes.txt

Actual installation (for me)

  1. Download dotfiles and source it:
bash -c "$(curl -fsSL https://goo.gl/PR0ocr)" && source ~/.bashrc
  1. Add my git remotes to the new clone, swapping the https origin push for gits:
cd ${DOTFILES}
git remote remove origin
awk '/fetch/{print "git remote add " $1 " " $2}' < remotes.txt | bash
  1. Edit copied files (see ${DOTFILES}/copy for which files in ${HOME} will require edits). Or restore these from a private backup.

Aliases and Functions

To keep things easy, the ~/.bashrc and ~/.bash_profile files are extremely simple, and should never need to be modified. Instead, aliases, functions, settings, etc are sourced from one of the files in the source/ subdirectory. They're all automatically sourced when a new shell is opened. Take a look, there are a lot of aliases and functions. There is even a fancy prompt that shows the current directory, time and current git/svn repo status.

Scripts

In addition to the dotfiles script, there are a few other bin scripts. This includes nave, which is a git submodule.

  • dotfiles - (re)initialize dotfiles. It might ask for your password (for sudo).
  • src - (re)source all files in source/ directory
  • Look through the bin subdirectory for a few more.

Prompt

My monster bash prompt builds upon Cowboy's awesome prompt:

  • It shows git and svn repo status, a timestamp, error exit codes, and even changes color depending on how you've logged in.

    • Git repos display as [branch:flags] where flags are:

      ? untracked files
      ! changed (but unstaged) files
      + staged files

    • SVN repos display as [rev1:rev2] where rev1 and rev2 are:

      rev1 last changed revision
      rev2 revision

  • The prompt also shows GNU screen window numbers, activated python/conda environments and how many running background jobs you have.

  • It optionally can include command history recall numbers and directory size and file counts

  • It includes a title bar setting for xterm/rxvt/konsole/iTerm windows

  • It adapts when you're running Midnight Commander to show only one line of detail, and a different title bar.

  • If all of this is too much for the computer to handle, you can quickly switch back to a more simple prompt

Inspiration

https://github.com/gf3/dotfiles
https://github.com/mathiasbynens/dotfiles
(and 15+ years of accumulated crap)

License

Copyright © 2014,2016 "Cowboy" Ben Alman Licensed under the [MIT license][LICENSE-MIT]. [LICENSE-MIT]: LICENSE-MIT

Identified Portions Copyright © 2005,2007-2009,2013,2014,2016-2017 Michael Lockhart Licensed under the Creative Commons CC-by-4.0 License

About

OS X / Linux dotfiles.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 79.3%
  • Lua 8.4%
  • Perl 4.9%
  • Ruby 4.3%
  • Python 2.8%
  • CSS 0.3%