Kwask94 / startup-config

Dot-files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"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:

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, Karabiner-Elements is used for the following:

  • Make Caps Lock serve as Backspace (when tapped) and Left Control (when chorded with another key). When held down alone, Caps Lock fires repeated Backspace events.
  • Make Return serve as Return (when tapped) and Right Control (when chorded with another key). When held down alone, Return fires repeated Return events.
  • Maps Control-I to F6 (only in MacVim and the terminal) so that it can be mapped independently from Tab in Vim.
  • Toggle Caps Lock on by tapping both Shift keys simultaneously.
  • Makes the function keys on my external Realforce keyboard behave like the "media" keys on Apple's keyboards.
  • Swap Option and Command keys on my external Realforce keyboard.
  • Make the "application" key (extra modifier key on right-hand side) behave as "fn" on Realforce keyboard.
  • Make "pause" (at far-right of function key row) behave as "power" (effectively, sleep) on Realforce keyboard.
  • 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.

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).
  • 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:

  • A "generic" (A.K.A. "application") keychain items (that is, without protocols, only hostnames):
    • "Keychain Item Name": example.net (corresponds to the "host" field in ~/.msmtprc, and "Host" field in ~/.mbsyncrc).
    • "Account Name": username+mutt@example.net (corresponds to the "user" field in ~/.msmtprc, and "PassCmd" field in ~/.mbsynrc).

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:

  • t: Toggle selection on entire thread (see also x).
  • A: Show alternate MIME-type in MIME-multipart messages.
  • O: Save original message.
  • S: Search all using Xapian query syntax (notmuch-specific reference documentation):
    • +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" (two consecutive words), subject:(one two) (two words anywhere in subject), subject:one AND subject:two (two words anywhere in subject).
    • subject:/some regex.*/
    • from:john, from:me@example.com
    • to:john, to:me@example.com
    • folder:Sent (prefix search)
    • date:today
    • date:yesterday
    • date:3d (exactly 3 days ago)
    • date:14d..7d (a week ago)
    • date:10d.. (since 10 days ago)
    • date:..3d (until 3 days ago)
    • date:"last week" (preceding Monday through Sunday)
    • date:"this week" or date:this_week or date:this-week (Monday to present day)
    • date:"last year" (also works with years, months, hours/hrs, minutes/mins, seconds/secs etc).
    • date:june
    • date:2018-06-01
    • is:unread
  • l: Limit listed messages:
    • ~f bob (from bob)
    • ~s foo (subject contains "foo"; "Foo" would search case-sensitively)
    • ~s foo.+bar (subject contains pattern)
    • !~s foo (subject does not contain "foo")
    • ~d >1m (messages more than 1 month old)
  • \u: Open list of URLs in message (via urlview).
  • b: Toggle (mailboxes) sidebar.
  • m: Move message(s).

Other stuff:

  • <Tab> autocompletes addresses from the lbdb database.
  • <C-t> autocompletes aliases.

Attachment menu bindings:

  • S: Save all attachments.

To have mailto links open up in mutt in iTerm:

  1. In iTerm2PreferencesProfilesGeneral, select the "Mutt" profile.
  2. 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.
  • Neovim or 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.
  • Ruby.
  • Adobe Source Code Pro or any other fixed-width font that includes the Powerline glyphs.

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

Or alternatively:

env http_proxy=http://fwdproxy:8080 https_proxy=http://fwdproxy:8080 git clone --recursive https://github.com/wincent/wincent

Install

./install          # Installs everything on the local machine.
./install --help   # Info on installing specific roles, force-installing etc.
./install dotfiles # Just install dotfiles.

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.

Again, if you're behind a firewall, you may need to make use of a proxy during the initial run:

env http_proxy=http://fwdproxy:8080 https_proxy=http://fwdproxy:8080 ./install

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.

Warning: Beware of the .gitconfig, you need to change for your user name and email address:

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

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

Broken Unicode in Vim (Linux)

If Unicode symbols appear missing or corrupted in Vim, first ensure that your terminal emulator supports UTF-8. Then, check to see if you've properly configured your system-wide UTF-8 support.

Issue this test command:

export LC_ALL=en_US.UTF-8

Then run vim. Unicode in the statusline should be working.

To persist this LC_* variable binding, edit your locale accordingly:

/etc/locale.conf

LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

See also

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 <greg@hurrell.net> Other contributors that have submitted patches include, in alphabetical order:

  • Joe Lencioni
  • Mark Stenglein
  • Victor Igor
  • Zac Collier

This list produced with:

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

About

Dot-files

License:The Unlicense


Languages

Language:Vim Script 49.0%Language:Python 18.8%Language:Shell 14.4%Language:Lua 7.0%Language:Ruby 5.2%Language:JavaScript 3.7%Language:Perl 1.8%