Literate Dotfiles

This org file contains my OSX dotfiles in a literate form. The dotfiles are generated by tangling this org file with (org-bable-tangle). This will create all the directories/files in the right locations with the configs specified here. To update a config file simply edit this file and then run (org-bable-tangle). Only files with changes will be updated as I have used :cache yes.

Warning header for tangled files

Include a header in all tangled files explaining that these files are generated with org-babel and should not be directly edited. It can be included in other files by including it in other blocks with <<boilerplate-file-header>>.

Templates

# WARNING: DO NOT EDIT THIS FILE
# This file was generated from a literate org config (~/.dotfiles/README.org).
# This file should not be directly edited. Instead edit ~/.dotfiles/README.org
# and then tangle the file.

;; WARNING: DO NOT EDIT THIS FILE
;; This file was generated from a literate org config (~/.dotfiles/README.org).
;; This file should not be directly edited. Instead edit ~/.dotfiles/README.org
;; and then tangle the file.

Add template to .zshrc

<<boilerplate-file-header>>

Add template to .zprofile

<<boilerplate-file-header>>

Add template to .zshenv

<<boilerplate-file-header>>

Ascii art/quote at stlolcat

Add a ascii art and a quote when .zshrc is sourced. For example, when a new terminal is opened.

fortune -s computers | cowsay -f dragon | lolcat

Paths

Set the paths for my dotfiles and configs

export HOME_CONFIG_DIR="$HOME/.config"
export HOME_CONFIG_DOTFILE_DIR="$HOME/.dotfiles"

sqlite

Need sqlite for Emacs’ docsets

export PATH="/Users/scannea1/Homebrew/opt/sqlite/bin:$PATH"

Emacs

I use Doom Emacs so let’s start by adding doom to path.

export PATH="$HOME_CONFIG_DIR/emacs/bin:$PATH"
export PATH="/Users/scannea1/Homebrew/opt/icu4c/bin:$PATH"
export PATH="/Users/scannea1/Homebrew/opt/icu4c/sbin:$PATH"
export PATH="/Users/scannea1/Homebrew/share/emacs/site-lisp/mu/mu4e:$PATH"
# export PATH="/opt/local/libexec/gnubin:$PATH"

Emacs profiles

I use Doom Emacs to manage multiple Emacs configs. See here for more details.

<<emacs-boilerplate-file-header>>

;; ((doom           . ((user-emacs-directory . "~/.config/doomemacs")
((doom           . ((user-emacs-directory . "~/.config/emacs")
                    (env . (("DOOMDIR" . "~/.dotfiles/doom.d")))))

 ;; (doom-literate  . ((user-emacs-directory . "~/.config/doomemacs")
 (doom-literate  . ((user-emacs-directory . "~/.config/emacs")
                    (env . (("DOOMDIR" . "~/.dotfiles/doom-literate.d"))))))

My literature doom config is <~/.dotfiles/doom-literate.d>. Doom autmatically tangles this file when starting.

Set default profile

Set up emacs to use my literate doom config by default.

export EMACSDIR=~/.config/emacs
export DOOM_EMACS=~/.config/emacs
export DOOMDIR=~/.dotfiles/doom-literate.d

Set EDITOR to use Emacs

Set my editor to be emacs in GUI, emacsclient in terminal and to use vim if they fail.

export EDITOR="~/Homebrew/opt/emacs-mac/bin/emacsclient"
export VISUAL="~/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs"
export ALTERNATE_EDITOR="vim"

Aliases for Emacs/eamcsclient

Add aliases for calling emacs and emacsclient

alias te="emacsclient -c "
alias emacs="~/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs"

Aliases for ranger/dired

Alias ranger and dired to open dired in emacsclient.

alias dired="te --eval '(dired \".\")'"
alias ranger=dired

Homebrew

Add Homebrew path to zprofile

export PATH=$PATH:/Users/scannea1/Homebrew/bin
# export PATH=$PATH:/Users/scannea1/Homebrew/bin
export PATH="/Users/scannea1/Homebrew/bin:$PATH"
export PATH="/Users/scannea1/Homebrew/sbin:$PATH"

Anaconda

# Add conda to path
# export PATH="/Users/scannea1/anaconda3/bin:$PATH"

pyenv

eval "$(pyenv init --path)"
if command -v pyenv 1>/dev/null 2>&1; then
    eval "$(pyenv init -)"
fi

Prompt: powerlevel10k

Powerlevel10k is configured on command line using:

p10k configure
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

Oh my zsh

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="powerlevel10k/powerlevel10k"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates
# zstyle ':omz:update' mode auto      # update automatically without asking
# zstyle ':omz:update' mode reminder  # just remind me to update when it's time

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
  dash
  direnv
  vi-mode
  thefuck
  hitchhiker
  # iterm2
  # python
  # poetry
  # pip
  #github
  # osx
  # emacs
  # docker
  # zsh-trash
)

source $ZSH/oh-my-zsh.sh

.zshrc general

# User configuration
# You may need to manually set your language environment
export LANG=en_US.UTF-8
# this stop perl errors in Emacs

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

Set up ruby (needed for Jekyll)

export PATH="/Users/scannea1/Homebrew/opt/ruby/bin:$PATH"
source /Users/scannea1/Homebrew/opt/chruby/share/chruby/chruby.sh

Enable auto-switching of Rubies specified by .ruby-version files

source /Users/scannea1/Homebrew/opt/chruby/share/chruby/auto.sh

Set ruby version

chruby ruby-3.1.2

gitconfig

<<boilerplate-file-header>>

[user]
    email = scannell.aidan@gmail.com
    name = Aidan Scannell

Yabai

#!/usr/bin/env sh
<<boilerplate-file-header>>

# see this wiki page for information:
#  - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)

Global settings

#!/usr/bin/env sh

#
# for this to work you must configure sudo such that
# it will be able to run the command without password
#
# see this wiki page for information:
#  - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)#configure-scripting-addition
#
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa
#

# global settings
yabai -m config                                 \
    mouse_follows_focus          off            \
    focus_follows_mouse          off            \
    window_origin_display        default        \
    window_placement             second_child   \
    window_zoom_persist          on             \
    window_topmost               off            \
    window_shadow                on             \
    window_animation_duration    0.0            \
    window_animation_frame_rate  120            \
    window_opacity_duration      0.0            \
    active_window_opacity        1.0            \
    normal_window_opacity        0.90           \
    window_opacity               off            \
    insert_feedback_color        0xffd75f5f     \
    active_window_border_color   0xff775759     \
    normal_window_border_color   0xff555555     \
    window_border_width          4              \
    window_border_radius         12             \
    window_border_blur           off            \
    window_border_hidpi          on             \
    window_border                off            \
    split_ratio                  0.50           \
    split_type                   auto           \
    auto_balance                 off            \
    top_padding                  12             \
    bottom_padding               12             \
    left_padding                 12             \
    right_padding                12             \
    window_gap                   06             \
    layout                       bsp            \
    mouse_modifier               fn             \
    mouse_action1                move           \
    mouse_action2                resize         \
    mouse_drop_action            swap

echo "yabai configuration loaded.."

General space settings

Config loaded message

echo "yabai configuration loaded.."

skhd

<<boilerplate-file-header>>

Config

# open iTerm
# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2 --single-instance -d ~
# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2 --single-instance -d ~
# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2 --single-instance -d "/Users/scannea1/Homebrew/opt/emacs-mac/bin/emacsclient -c -e '(vterm)' '(doom/window-maximize-buffer)'"
# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2 --single-instance -d ~
# "/Users/scannea1/Homebrew/opt/emacs-mac/bin/emacsclient -c -e '(vterm)' '(doom/window-maximize-buffer)'"
# cmd - return : /Users/scannea1/Homebrew/opt/emacs-mac/bin/emacsclient -c -e '(vterm)' '(doom/window-maximize-buffer)'
# cmd - return : /Users/scannea1/Homebrew/opt/emacs-mac/bin/emacsclient -c -e '(vterm)' '(doom/window-maximize-buffer)'
cmd - return : /Users/scannea1/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs --eval '(vterm)'


# open org capture in emacs
#cmd - o : ~/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs --eval '(+org-capture/open-frame)'

cmd - d : /Users/scannea1/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs --eval '(dired "~/")'
#cmd - d : /usr/local/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs.sh --eval '(dired ~/)'

# open brave browser
cmd + shift - return : /Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --single-instance
cmd - i : /Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --single-instance --incognito
# cmd - i : /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --single-instance --incognito

# open a new GUI instance of emacs
cmd - g : /Users/scannea1/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs

# open a instance of emacs and
# cmd + shift - e : ger
# cmd + shift - e : /usr/local/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs
# cmd + shift - e : ~/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs.sh
# cmd + shift - e : gemacs
# cmd + shift - e : ~/.emacs.d/emacs-client-server
# cmd + shift - e : ~/.emacs.config/emacs-client-server
# cmd + e : ~/Homebrew/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs.sh
# cmd + e : ~/Homebrew/opt/emacs-mac/bin/emacsclient -nw

# open mail in a new terminal instance of emacs
# cmd + shift - m : emacs --eval '(mu4e)'
# cmd + shift - m : ge --eval '(mu4e)'

# This shell script opens a new instance of emacs and starts a server if one isn't already running.
# If an emacs server is already running then it uses emacsclient and connects to it.
# cmd - e : ge
# cmd - e : ~/.emacs.d/emacs-client-server
# similarly but opens mail
# cmd - m : ge --eval '(mu4e)'



# focus window
alt - h : yabai -m window --focus west
alt - j : yabai -m window --focus south
alt - k : yabai -m window --focus north
alt - l : yabai -m window --focus east

# swap window
shift + alt - h : yabai -m window --swap west
shift + alt - j : yabai -m window --swap south
shift + alt - k : yabai -m window --swap north
shift + alt - l : yabai -m window --swap east

# move window
shift + cmd - h : yabai -m window --warp west
shift + cmd - j : yabai -m window --warp south
shift + cmd - k : yabai -m window --warp north
shift + cmd - l : yabai -m window --warp east

# balance size of window
# shift + alt - 0 : yabai -m space --balance

# make floating window fill screen
# shift + alt - up     : yabai -m window --grid 1:1:0:0:1:1

# make floating window fill left-half of screen
# shift + alt - left   : yabai -m window --grid 1:2:0:0:1:1

# make floating window fill right-half of screen
# shift + alt - right  : yabai -m window --grid 1:2:1:0:1:1

# create desktop, move window and follow focus - uses jq for parsing json (brew install jq)
shift + cmd - n : yabai -m space --create && \
                  index="$(yabai -m query --spaces --display | jq 'map(select(."native-fullscreen" == 0))[-1].index')" && \
                  yabai -m window --space "${index}" && \
                  yabai -m space --focus "${index}"

# create desktop and follow focus - uses jq for parsing json (brew install jq)
cmd + alt - n : yabai -m space --create && \
                index="$(yabai -m query --spaces --display | jq 'map(select(."native-fullscreen" == 0))[-1].index')" && \
                yabai -m space --focus "${index}"

# destroy desktop
cmd + alt - w : yabai -m space --destroy

# fast focus desktop
# cmd + alt - x : yabai -m space --focus recent
cmd + alt - x : yabai tiling::desktop --focus $(chunkc get _last_active_desktop)
cmd + alt - z : yabai -m space --focus prev
cmd + alt - c : yabai -m space --focus next
cmd + alt - 1 : yabai -m space --focus 1
cmd + alt - 2 : yabai -m space --focus 2
cmd + alt - 3 : yabai -m space --focus 3
cmd + alt - 4 : yabai -m space --focus 4
cmd + alt - 5 : yabai -m space --focus 5
cmd + alt - 6 : yabai -m space --focus 6
cmd + alt - 7 : yabai -m space --focus 7
cmd + alt - 8 : yabai -m space --focus 8
cmd + alt - 9 : yabai -m space --focus 9
cmd + alt - 0 : yabai -m space --focus 10

# send window to desktop and follow focus
shift + cmd - x : yabai -m window --space recent; yabai -m space --focus recent
shift + cmd - z : yabai -m window --space prev; yabai -m space --focus prev
shift + cmd - c : yabai -m window --space next; yabai -m space --focus next
shift + cmd - 1 : yabai -m window --space  1; yabai -m space --focus 1
shift + cmd - 2 : yabai -m window --space  2; yabai -m space --focus 2
shift + cmd - 3 : yabai -m window --space  3; yabai -m space --focus 3
shift + cmd - 4 : yabai -m window --space  4; yabai -m space --focus 4
shift + cmd - 5 : yabai -m window --space  5; yabai -m space --focus 5
shift + cmd - 6 : yabai -m window --space  6; yabai -m space --focus 6
shift + cmd - 7 : yabai -m window --space  7; yabai -m space --focus 7
shift + cmd - 8 : yabai -m window --space  8; yabai -m space --focus 8
shift + cmd - 9 : yabai -m window --space  9; yabai -m space --focus 9
shift + cmd - 0 : yabai -m window --space 10; yabai -m space --focus 10

# focus monitor
ctrl + alt - x  : yabai -m display --focus recent
ctrl + alt - z  : yabai -m display --focus prev
ctrl + alt - c  : yabai -m display --focus next
ctrl + alt - 1  : yabai -m display --focus 1
ctrl + alt - 2  : yabai -m display --focus 2
ctrl + alt - 3  : yabai -m display --focus 3

# send window to monitor and follow focus
ctrl + cmd - x  : yabai -m window --display recent; yabai -m display --focus recent
ctrl + cmd - z  : yabai -m window --display prev; yabai -m display --focus prev
ctrl + cmd - c  : yabai -m window --display next; yabai -m display --focus next
ctrl + cmd - 1  : yabai -m window --display 1; yabai -m display --focus 1
ctrl + cmd - 2  : yabai -m window --display 2; yabai -m display --focus 2
ctrl + cmd - 3  : yabai -m window --display 3; yabai -m display --focus 3

# move window
shift + ctrl - a : yabai -m window --move rel:-20:0
shift + ctrl - s : yabai -m window --move rel:0:20
shift + ctrl - w : yabai -m window --move rel:0:-20
shift + ctrl - d : yabai -m window --move rel:20:0

# increase window size
shift + alt - a : yabai -m window --resize left:-20:0
shift + alt - s : yabai -m window --resize bottom:0:20
shift + alt - w : yabai -m window --resize top:0:-20
shift + alt - d : yabai -m window --resize right:20:0

# decrease window size
shift + cmd - a : yabai -m window --resize left:20:0
shift + cmd - s : yabai -m window --resize bottom:0:-20
shift + cmd - w : yabai -m window --resize top:0:20
shift + cmd - d : yabai -m window --resize right:-20:0

# set insertion point in focused container
ctrl + alt - h : yabai -m window --insert west
ctrl + alt - j : yabai -m window --insert south
ctrl + alt - k : yabai -m window --insert north
ctrl + alt - l : yabai -m window --insert east

# rotate tree
alt - r : yabai -m space --rotate 90

# mirror tree y-axis
alt - y : yabai -m space --mirror y-axis

# mirror tree x-axis
alt - x : yabai -m space --mirror x-axis

# toggle desktop offset
alt - a : yabai -m space --toggle padding; yabai -m space --toggle gap

# toggle window parent zoom
alt - d : yabai -m window --toggle zoom-parent

# toggle window fullscreen zoom
alt - f : yabai -m window --toggle zoom-fullscreen

# toggle window native fullscreen
shift + alt - f : yabai -m window --toggle native-fullscreen

# toggle window border
shift + alt - b : yabai -m window --toggle border

# toggle window split type
alt - e : yabai -m window --toggle split

# float / unfloat window and center on screen
alt - t : yabai -m window --toggle float;\
          yabai -m window --grid 4:4:1:1:2:2

# toggle sticky (show on all spaces)
# alt - s : yabai -m window --toggle sticky

# toggle topmost (keep above other windows)
# alt - o : yabai -m window --toggle topmost

# toggle sticky(+float), topmost, border and picture-in-picture
# alt - p : yabai -m window --toggle sticky;\
          # yabai -m window --toggle topmost;\
          # yabai -m window --toggle border;\
          # yabai -m window --toggle pip

# change layout of desktop
# ctrl + alt - a : yabai -m space --layout bsp
# ctrl + alt - d : yabai -m space --layout float

Mbsynrc

<<boilerplate-file-header>>
IMAPStore gmail-remote
Host imap.gmail.com
SSLType IMAPS
AuthMechs LOGIN
User scannell.aidan@gmail.com
PassCmd "pass email/scannell.aidan@gmail.com"

MaildirStore gmail-local
Path ~/Mail/gmail/
Inbox ~/Mail/gmail/INBOX
Subfolders Verbatim

Channel gmail
Master :gmail-remote:
Slave :gmail-local:
Create Both
Expunge Both
Patterns * !"[Gmail]/All Mail" !"[Gmail]/Important" !"[Gmail]/Starred" !"[Gmail]/Bin"
SyncState *
Next