Code Monkey home page Code Monkey logo

wincent's Introduction

"dotfiles" and system configuration

  • Target platforms: macOS and Red Hat-like Linuxes (eg. CentOS).
  • Set-up method: Beautiful and intricate snowflake incredibly over-engineered Ansible orchestration.
  • Visible in the screenshot:
    • Tomorrow Night color scheme.
    • Adobe Source Code Pro (Light) font.
    • Vim, running inside tmux, inside iTerm2, on macOS "El Capitan".

Features

Dotfiles

A set of dotfiles that I've been tweaking and twiddling since the early 2000s (under version control since 2009). Characteristics include:

  • Sane Vim pasting via bracketed paste mode.
  • Write access to local clipboard from local and remote hosts, inside and outside of tmux (via Clipper).
  • Full mouse support (pane/split resizing, scrolling, text selection) in Vim and tmux.
  • Focus/lost events for Vim inside tmux.
  • Cursor shape toggles on entering Vim.
  • Italics in the terminal.
  • Bundles a (not-excessive) number of useful Vim plug-ins.
  • Conservative Vim configuration (very few overrides of core functionality; most changes are unobtrusive enhancements; some additional functionality exposed via <Leader> and <LocalLeader> mappings.
  • Relatively restrained Zsh config, Bash-like but with a few Zsh perks, such as right-side prompt, auto-cd hooks, command elapsed time printing and such.
  • Unified color-handling (across iTerm2 and Vim) via Base16 Shell.
  • Encrypted versioning of files with sensitive content (via git-cipher).
  • Comprehensive Hammerspoon config.

Homebrew

On macOS, the homebrew role installs a bunch of useful software.

Keyboard customization

On macOS, Hammerspoon is used to provide the functionality previously provided in the keyboard role via Karabiner:

  • Make Caps Lock serve as Backspace (when tapped), repeated Backspace (when pressed and held), and Left Control (when chorded with another key).
  • Make Return serve as Return (when tapped), repeated Return (when pressed and held), and Right Control (when chorded with another key).
  • Maps Control-I to F6 in the terminal so that it can be mapped independently from Tab in Vim.

Other functionality that used to come via Karabiner isn't (yet) supported because Karabiner itself doesn't support macOS Sierra, and its successor, Karabiner-Elements, still has a pretty primitive feature set:

  • Adds a "SpaceFN" layer that can be activated by holding down Space while hitting other keys; I use this to make the cursor keys available on or near the home row in any app.
  • Turn Caps Lock on by tapping both Shift keys simultaneously (turn it off by tapping either Shift key on its own).
  • Make the YubiKey work with the Colemak keyboard layout.
  • Makes the function keys on my external Realforce keyboard behave like the "media" keys on Apple's keyboards. F13 serves as a sticky "fn" key, and F15 as Power.

Mutt

A number of tools are used to provide command-line access to Gmail and Office IMAP accounts.

  • mutt: For reading email.
  • isync: For maintaining a local cache of messages for offline access.
  • notmuch: For fast search.
  • msmtp: For sending email.
  • elinks: For viewing HTML emails.
  • urlview: For opening URLs from inside mutt.
  • terminal-notifier: For notifications.
  • lbdb: Contact autocompletion drawing from a number of sources, such as previous messages, aliases, and macOS Contacts (which can be configured to synchronize Google contacts as well).
  • reattach-to-user-name-space: So that lbdb can query the macOS Contacts, and terminal-notifier can do its thing, even inside tmux.
  • imapfilter: For filtering.
  • passage: For mediating interaction with the macOS keychain.

In order for all this to work, a few items have to be stored in the macOS keychain:

  • Four "generic" (A.K.A. "application") keychain items (that is, without protocols, only hostnames):
    • For sending mail:
      • An item with (for Gmail):
        • "Keychain Item Name": smtp.gmail.com (corresponds to the "host" field in ~/.msmtprc).
        • "Account Name": [email protected] (corresponds to the "user" field in ~/.msmtprc).
      • An item with (for Office):
        • "Keychain Item Name": smtp.office365.com (corresponds to the "host" field in ~/.msmtprc).
        • "Account Name": [email protected] (corresponds to the "user" field in ~/.msmtprc).
    • For receiving mail:
      • An item with (for Gmail):
        • "Keychain Item Name": imap.gmail.com (corresponds to the "Host" field in ~/.mbsyncrc).
        • "Account Name": [email protected] (corresponds to the "PassCmd" field in ~/.mbsyncrc).
      • An item with (for Office):

The following Gmail-like/Vim-like bindings are configured:

  • e: Archive (but note: leaves copy of mail in mailbox until next sync; force an immediate sync with $).
  • #: Trash mail.
  • !: Mark as spam.
  • gi: Go to inbox.
  • ga: Go to archive.
  • gt: Go to sent mail.
  • gd: Go to drafts.
  • gs: Go to starred mail.
  • gl: Go to a label (folder).
  • x: Toggle selection on entry (see also t).
  • c: Compose new message.
  • s: Toggle star.
  • *a: Select all.
  • *n: Deselect all (mnemonic: "select none").
  • *r: Select read messages.
  • *u: Select unread messages.
  • Shift-U: Mark as unread.
  • Shift-I: Mark as read.

Standard mutt stuff:

  • v: View attachments (including alternate parts for a multipart message).

Non-Gmail extensions:

  • gh: Go to home account (mnemonic: "[g]o [h]ome!").
  • gw: Go to work account (mnemonic: "[g]et to [w]ork!".
  • t: Toggle selection on entire thread (see also x).
  • A show alternate MIME-type in MIME-multipart messages.
  • S: Search all using Xapian query syntax:
    • +foo: Must include "foo".
    • -bar: Must not include "bar".
    • AND, OR, NOT, XOR: Self-evident.
    • foo NEAR bar: "foo" within 10 words of "bar" (order-independent).
    • foo ADJ bar: Like NEAR, but "foo" must appear earlier than "bar".
    • "foo bar": Match entire phrase.
    • foo*: Match "foo", "food", "foobar" etc.
    • subject:this, subject:"one two"
    • {from,to}:john, {from,to}:[email protected]
    • folder:Home/Home (prefix search)
    • date:today, date:7d (and much more)
    • is:unread
  • \u: Open list of URLs in message (via urlview).
  • b: Toggle (mailboxes) sidebar.
  • m: Move message(s).

To have mailto links open up in mutt in iTerm:

  1. In iTerm2PreferencesProfilesGeneral, create a copy of your default profile by clicking on Other Actions... and selecting Duplicate Profile.
  2. Name the copy something identifying, like "Mutt".
  3. Under Command, select the Command radio button and enter /usr/bin/env MAILTO=$$URL$$ /usr/local/bin/zsh -ic "/usr/local/bin/mutt -- $MAILTO":
  4. Under URL SchemesSchemes handled:, select mailto.

Notes:

  • $$URL$$ is documented here.
  • The convoluted use of env and zsh is required to get terminal colors working correctly.

Dependencies

  • tmux 2.3 or later.
  • Vim 8.0 or later with Ruby and Python support (although there's a reasonable amount of feature detection in order to degrade gracefully).
  • Relatively recent Zsh.
  • Relatively recent Git.
  • Clipper for transparent access to the local system clipboard.
  • On macOS, iTerm2. Additionally, only the latest version of macOS (currently Sierra) gets actively tested.
  • Python to perform setup via the included install command.

Installation

Clone

git clone --recursive https://github.com/wincent/wincent.git

Note that if you're behind a firewall you may need to set up a temporary ~/.gitconfig with appropriate proxy configuration with a format such as:

[http]
	proxy = fwdproxy:8080

Install

./install        # installs everything on the local machine
./install --help # info on installing specific roles, force-installing etc

This sets up a local Python environment using the bundled virtualenv, bootstraps Ansible, and then uses Ansible to copy the dotfiles and configure the machine.

As a fallback strategy, in case the install script fails, you can symlink the dotfiles by hand with a command like the following:

for DOTFILE in $(find roles/dotfiles/files -maxdepth 1 -name '.*' | tail -n +2); do
  ln -sf $PWD/$DOTFILE ~
done

Note: The ln -sf command will overwrite existing files, but will fail to overwrite existing directories. <<<<<<< 51f1316db75803af914478df9a7e35b70f78ee3d

If PyCrypto causes the install to fail at:

src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found

then open a new terminal session and try:

export https_proxy=fwdproxy:8080						# configure temporary proxy (as per the install prompt)
brew install gmp								
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto		
./install --force --verbose

||||||| merged common ancestors

Troubleshooting

pycrypto install fails with "'gmp.h' file not found"

If pycrypto causes the install to fail at:

src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found

due to a missing GMP dependency, try:

brew install gmp
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto

And then installing again:

./install --force

License

Unless otherwise noted, the contents of this repo are in the public domain. See the LICENSE for details.

Authors

The repo is written and maintained by Greg Hurrell <[email protected]> Other contributors that have submitted patches include, in alphabetical order:

  • Joe Lencioni
  • Zac Collier

This list produced with:

:read !git shortlog -s | grep -v 'Greg Hurrell' | cut -f 2-3 | sed -e 's/^/- /'

Pulled in README changes

wincent's People

Contributors

wincent avatar zacacollier avatar lencioni avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.