Skip to content

cursley/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Alec’s dotfiles

This file includes configuration for:

This configuration is presented in a literate programming style, combining code (in this case, configuration) and documentation. Configuration syntax can be quite terse, so this is an interesting way to add rationale and extra notes.

I aim to keep this configuration lightweight. These are all well-designed tools, and their default behaviour generally works well for me.

I use this configuration on macOS.

Installation

This file has metadata that Org mode uses to combine (“tangle”) the source code blocks into the relevant configuration files.

To install this configuration, overwriting existing files:

  1. Open this file in Emacs
  2. Run the org-babel-tangle command (bound to C-c C-v C-t by default)

or, from the command line:

emacs README.org --batch --eval '(org-babel-tangle)'

Z shell

Enable completion:

autoload compinit && compinit

Use the completion menu:

zstyle ':completion:*' menu select

Tab selects the next candidate in the completion menu. Use shift+tab to select the previous candidate:

bindkey '^[[Z' reverse-menu-complete

Change directories by typing the directory name:

setopt AUTO_CD

Push all directory changes onto a stack:

setopt AUTO_PUSHD

Use popd to go back to the previous working directory.

Save plenty of history in a .zsh_history file:

HISTFILE=$HOME/.zsh_history
HISTSIZE=SAVEHIST=10000
setopt HIST_IGNORE_DUPS
setopt HIST_REDUCE_BLANKS
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY

Use Emacs key bindings:

bindkey -e

Search through history using the arrow keys:

bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search

Delete forwards, backspace backwards:

bindkey '^?' backward-delete-char # backspace deletes backwards
bindkey "^[[3~" delete-char # delete deletes forwards

Use alt+left and alt+right to move between words:

bindkey '^[[1;3C' forward-word
bindkey '^[[1;3D' backward-word

Set a simple prompt:

export PROMPT='%1~%# '

Make searches in less case-insensitive (--ignore-case). Pass ANSI colour escape sequences to the terminal (-R) to show colourful git output correctly.

export LESS='-R --ignore-case'

Source a local zshrc if available:

[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local

zprofile

Source the .profile file.

source $HOME/.profile

Profile

Don’t use control+S and control+Q for flow control:

stty start undef
stty stop undef

Use Homebrew:

eval "$(/opt/homebrew/bin/brew shellenv)"

Enable colour in ls:

export CLICOLOR=1

Use vim as the default editor:

export EDITOR=vim

Add ~/.bin to PATH:

export PATH="$HOME/.bin:$PATH"

Use vi to launch vim:

alias vi=vim

Use g for a compact git status:

alias g='git status --short --branch'

Have mkdir always create intermediate directories:

alias mkdir='mkdir -p'

Use emacs to run Emacs in the terminal:

alias emacs='emacs --no-window-system'

Set up nodenv and rbenv if installed:

whence nodenv &> /dev/null && eval "$(nodenv init -)"
whence rbenv &> /dev/null && eval "$(rbenv init -)"

Source a local profile if available:

[[ -f ~/.profile.local ]] && source ~/.profile.local

Git

[user]
name = Alec Cursley

Look for an email address in the current repository or gitconfig.local only:

useConfigOnly = true

Include local git configuration:

[include]
path = ~/.gitconfig.local
[push]
default = simple

When running git push on a local branch with no remote branch, automatically create a remote branch with the same name as the local branch:

autoSetupRemote = true

Use main as the default branch name:

[init]
defaultBranch = main

Set up some muscle-memory aliases:

[alias]
aa = add --all
ci = commit
co = checkout
ds = diff --staged
pf = push --force-with-lease
tree = log --graph --pretty=oneline --decorate --abbrev-commit
unstage = reset HEAD

Global ignore file

Ignore files created by macOS:

.DS_Store

Vim

vi - but better!

set nocompatible

Swap ; and ::

noremap ; :
noremap : ;

Use H and L as super-=H= and super-=L=:

nnoremap H ^
nnoremap L $

Hide the welcome message:

set shortmess+=I

Enable off-screen buffers:

set hidden

Keep at least two screen lines above and below the cursor:

set scrolloff=2

Display tabs as two spaces:

set tabstop=2
set shiftwidth=2

Use spaces for indentation:

set expandtab

Round indents to a multiple of two spaces:

set shiftround

Use case-insensitive search when the search pattern has only lowercase characters:

set smartcase

Search while typing:

set incsearch

Highlight search matches:

set hlsearch

Press return to clear search highlighting:

nnoremap <cr> :nohlsearch<cr>:echo<cr>

Substitution patterns are global by default:

set gdefault

Wrap lines:

set wrap

Don’t use swap files:

set noswapfile

Enable completion:

set wildmenu

Use control+S to save:

inoremap <c-s> <esc>:w<cr>

Automatically re-read changed files:

set autoread

Source a local vimrc if available:

if filereadable($HOME . "/.vimrc.local")
  source ~/.vimrc.local
endif

About

Configuration for command-line tools.

Resources

License

Stars

Watchers

Forks