commit 45c2f7bb6f0a38f182215d3067507490c4eda2ff Author: juan Date: Tue Jun 29 12:23:39 2021 -0500 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4dd2363 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# For more information visit http://editorconfig.org/ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.go,.gitmodules,Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e5da8f --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +/zsh/antibody +local.sh + +# Created by https://www.gitignore.io/api/emacs + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4cc32bb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "tmux/tpm/tmux-current-pane-hostname"] + path = tmux/tpm/tmux-current-pane-hostname + url = https://github.com/soyuka/tmux-current-pane-hostname +[submodule "tmux/tpm/tmux-prefix-highlight"] + path = tmux/tpm/tmux-prefix-highlight + url = https://github.com/tmux-plugins/tmux-prefix-highlight +[submodule "tmux/tpm/tmux-sensible"] + path = tmux/tpm/tmux-sensible + url = https://github.com/tmux-plugins/tmux-sensible +[submodule "tmux/tpm/tmux-yank"] + path = tmux/tpm/tmux-yank + url = https://github.com/tmux-plugins/tmux-yank +[submodule "tmux/tpm/tpm"] + path = tmux/tpm/tpm + url = https://github.com/tmux-plugins/tpm diff --git a/.stow-local-ignore b/.stow-local-ignore new file mode 100644 index 0000000..24da5fc --- /dev/null +++ b/.stow-local-ignore @@ -0,0 +1,13 @@ +.*\.sh +.*\.example +\.DS_Store +^/README\..* +^/install +^/Alpine +^/Brewfile +^/Debian +^/Ubuntu +^/Void +^/antibody +^/bin +^/tpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6444dc6 --- /dev/null +++ b/Makefile @@ -0,0 +1,90 @@ +MAKEFLAGS+=--no-builtin-rules +SHELL:=/usr/bin/env bash + +# Default list of exclude modules +ifndef EXCLUDE + # EXCLUDE:=go,java +endif + +# Functions +packages_from_file=\ + $(patsubst %/$1,%$(if $2,/$2,),\ + $(filter $(wildcard */$1),$(addsuffix /$1,$(packages)))) + +# Search for packages, ensuring that OS packages are first with any filters +# http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html +# [backup] http://archive.is/XYuEV +,:=, +space:=$(null) $(null) +$(space):= +$(space)+= +os:=$(shell source helpers && echo $$OS) +gui:=$(shell source helpers && echo $$GUI) +os_packages:=macos manjaro ubuntu +packages:=\ + $(filter $(os_packages),$(os))\ + $(filter-out $(os_packages),$(subst /,,$(wildcard */))) +ifdef EXCLUDE + packages:=$(filter-out $(subst $(,),$( ),$(EXCLUDE)),$(packages)) +endif +ifdef INCLUDE + packages:=$(filter $(subst $(,),$( ),$(INCLUDE)),$(packages)) +endif + +# Search for specific files based on package +installers:=$(call packages_from_file,install) +stows:=$(call packages_from_file,.stow-local-ignore) +envs:=\ + $(foreach p,$(packages),\ + $(sort\ + $(patsubst %/,%,$(dir\ + $(wildcard $p/*.sh))))) + +# Establish rules +installer_rules:=$(addsuffix /install,$(installers)) + +.PHONY: help clean auto install symlink update $(installer_rules) +.SUFFIXES: + +# +# Tasks +# https://blog.sneawo.com/blog/2017/06/13/makefile-help-target/ +# [backup] http://archive.is/XFLAz +# +help: + @echo + @echo '=== OS' + @echo "$(os)" + @echo + @echo '=== Packages' + @echo "Install - $(sort $(installers))" + @echo "Symlink - $(sort $(stows))" + @echo "Shell - $(sort $(envs))" + @echo + @echo '=== Variables' + @echo 'INCLUDE - Packages to only include: $(INCLUDE)' + @echo 'EXCLUDE - Packages to exclude: $(EXCLUDE)' + @echo + @echo '=== Commands' + @egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*## / - /' + @echo +clean: ## Clean up + @printf '==> ' + stow -D $(stows) +auto: update install symlink ## Run update, install, and symlink +install: $(installer_rules) ## Install required dependencies +symlink: ## Symlink configuration files + @printf '==> ' + stow --target="$$HOME" $(stows) +update: ## Update dotfiles + @printf '==> ' + git pull --rebase --autostash + @printf '==> ' + git submodule update --init --remote + +# +# Internal tasks +# +$(installer_rules): %/install: + @printf '==> ' + $@ diff --git a/common/.config/alacritty/alacritty.yml b/common/.config/alacritty/alacritty.yml new file mode 100644 index 0000000..ab8bfe8 --- /dev/null +++ b/common/.config/alacritty/alacritty.yml @@ -0,0 +1,31 @@ +colors: + primary: + background: '#282c34' + foreground: '#abb2bf' + cursor: + text: CellBackground + cursor: '#528bff' + selection: + text: CellForeground + background: '#3e4451' + normal: + black: '#5c6370' + red: '#e06c75' + green: '#98c379' + yellow: '#e5c07b' + blue: '#61afef' + magenta: '#c678dd' + cyan: '#56b6c2' + white: '#828997' + +font: + normal: + family: VictorMono Nerd Font + size: 14.0 + +window: + dynamic_padding: true + decorations: none + padding: + x: 6 + y: 6 diff --git a/common/.editorconfig b/common/.editorconfig new file mode 120000 index 0000000..38d9a0c --- /dev/null +++ b/common/.editorconfig @@ -0,0 +1 @@ +../.editorconfig \ No newline at end of file diff --git a/common/.stow-local-ignore b/common/.stow-local-ignore new file mode 120000 index 0000000..78a4393 --- /dev/null +++ b/common/.stow-local-ignore @@ -0,0 +1 @@ +../.stow-local-ignore \ No newline at end of file diff --git a/common/aliases.sh b/common/aliases.sh new file mode 100644 index 0000000..d33e93c --- /dev/null +++ b/common/aliases.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env false + +# Add color highlighting +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' + +# Customized greps +alias hgrep='history 0 | grep' +alias psgrep='ps aux | grep -v grep | grep -i -e VSZ -e' + +# Additional helpers +alias la='ls -lah' +alias mkdir='mkdir -pv' +alias path='echo -e ${PATH//:/\\n}' + +function dotf { (cd $DOTFILES && "$@"); } + +function touch { mkdir $(dirname "$1") && command touch "$1" } diff --git a/common/install b/common/install new file mode 100755 index 0000000..71ad6e2 --- /dev/null +++ b/common/install @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" +source ../helpers + +mkdir -p "$HOME/.config" diff --git a/git/.gitconfig b/git/.gitconfig new file mode 100644 index 0000000..5728263 --- /dev/null +++ b/git/.gitconfig @@ -0,0 +1,19 @@ +[apply] + whitespace = fix +[core] + excludesfile = ~/.gitignore + editor = vim +[difftool] + prompt = false +[help] + autocorrect = 1 +[include] + path = ~/.gitconfig.local +[mergetool] + keepBackup = false +[push] + default = simple +[remote] + pushDefault = origin +[status] + submoduleSummary = true diff --git a/git/.gitignore b/git/.gitignore new file mode 100644 index 0000000..30f543b --- /dev/null +++ b/git/.gitignore @@ -0,0 +1,195 @@ +_minted-* + +# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,emacs,macos,windows,sublimetext,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,linux,emacs,macos,windows,sublimetext,visualstudiocode + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### SublimeText ### +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/vim,linux,emacs,macos,windows,sublimetext,visualstudiocode diff --git a/git/.gitignore.local.example b/git/.gitignore.local.example new file mode 100644 index 0000000..0cc654f --- /dev/null +++ b/git/.gitignore.local.example @@ -0,0 +1,11 @@ +# -*- mode: gitconfig -*- + +[user] + name = USER_NAME + email = USER_EMAIL +[credential] + helper = CREDENTIAL_HELPER +[github] + user = USER_NAME +# [url "git@github.com:"] +# pushInsteadOf = https://github.com/ diff --git a/git/.stow-local-ignore b/git/.stow-local-ignore new file mode 120000 index 0000000..78a4393 --- /dev/null +++ b/git/.stow-local-ignore @@ -0,0 +1 @@ +../.stow-local-ignore \ No newline at end of file diff --git a/git/install b/git/install new file mode 100755 index 0000000..d9a92af --- /dev/null +++ b/git/install @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" +source ../helpers + +if [[ -f $HOME/.gitconfig.local ]]; then exit; fi + +echo '--- Gathering localized Git configuration data' +credential_helper=cache +if [[ "$OS" == macos ]]; then + credential_helper=osxkeychain +fi +printf '[git] user.name: ' +read -e user_name +printf '[git] user.email: ' +read -e user_email + +echo '--- Building .gitconfig.local' +sed \ + -e "s/USER_NAME/$user_name/g" \ + -e "s/USER_EMAIL/$user_email/g" \ + -e "s/CREDENTIAL_HELPER/$credential_helper/g" \ + .gitconfig.local.example > $HOME/.gitconfig.local diff --git a/helpers b/helpers new file mode 100755 index 0000000..d05918e --- /dev/null +++ b/helpers @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +unset GUI +if [[ "$(uname -s 2>/dev/null)" == Darwin ]]; then + OS=macos + GUI=1 +elif [[ "$(lsb_release -i -s 2>/dev/null)" == Ubuntu ]]; then + OS=ubuntu + if dpkg -l ubuntu-desktop &>/dev/null; then GUI=1; fi +elif [[ "$(lsb_release -i -s 2>/dev/null)" == ManjaroLinux ]]; then + OS=manjaro + if dpkg -l ubuntu-desktop &>/dev/null; then GUI=1; fi +elif [[ "$(lsb_release -i -s 2>/dev/null)" == Debian ]]; then + OS=debian + # TODO detect GUI support in debian here +else + OS=unknown +fi + +# Install dependencies based on file system +function install_deps { + # For macOS, just use Homebrew + if [[ "$OS" == macos ]]; then + if [[ -f Brewfile ]]; then + echo '--- Installing dependencies via Homebrew' + brew bundle + fi + return + fi + + # Read dependencies + local deps + case "$OS" in + debian) + if [[ ! -f Debian ]]; then return; fi + mapfile -t deps < Debian + ;; + ubuntu) + if [[ ! -f Ubuntu ]]; then return; fi + mapfile -t deps < Ubuntu + ;; + *) + echo "!!! Unsupported OS to install dependencies: $OS" + return 1 + ;; + esac + + # Filter dependencies based on criteria + local exclude + local cleanup + if [[ -n "$GUI" ]]; then + exclude=NOGUI + cleanup=GUI + else + exclude=GUI + cleanup=NOGUI + fi + deps=${deps[*]//*\($exclude\)/} + deps=${deps//\($cleanup\)/} + + # Execute + case $OS in + debian | ubuntu) + if ! dpkg-query -s $deps &>/dev/null; then + echo '--- Installing dependencies via apt' + sudo apt -y install $deps + fi + ;; + esac + if [[ $? -ne 0 ]]; then + echo '!!! Failed to install dependencies' + exit 1 + fi +} + +# Remove functions used only for installation +function cleanup_helpers { + unset -f cleanup_helpers + unset -f install_deps +} diff --git a/macos/.config/karabiner/karabiner.json b/macos/.config/karabiner/karabiner.json new file mode 100644 index 0000000..6dfab8b --- /dev/null +++ b/macos/.config/karabiner/karabiner.json @@ -0,0 +1,877 @@ +{ + "global": { + "check_for_updates_on_startup": true, + "show_in_menu_bar": true, + "show_profile_name_in_menu_bar": true + }, + "profiles": [ + { + "complex_modifications": { + "parameters": { + "basic.simultaneous_threshold_milliseconds": 50, + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500, + "mouse_motion_to_scroll.speed": 100 + }, + "rules": [ + { + "description": "Change caps_lock to control if pressed with other keys, to escape if pressed alone.", + "manipulators": [ + { + "from": { + "key_code": "caps_lock", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_control" + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + } + ] + }, + { + "description": "Change Control+Shift+h/j/k/l to Arrows", + "manipulators": [ + { + "from": { + "key_code": "h", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "left_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "j", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "down_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "k", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "up_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "l", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "right_arrow" + } + ], + "type": "basic" + } + ] + } + ] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "consumer_key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "consumer_key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "key_code": "mission_control" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "launchpad" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "key_code": "illumination_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "key_code": "illumination_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "consumer_key_code": "rewind" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "consumer_key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "consumer_key_code": "fastforward" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "consumer_key_code": "mute" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "consumer_key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "consumer_key_code": "volume_increment" + } + } + ], + "name": "Default", + "parameters": { + "delay_milliseconds_before_open_device": 1000 + }, + "selected": true, + "simple_modifications": [ + { + "from": { + "key_code": "backslash" + }, + "to": { + "key_code": "delete_or_backspace" + } + }, + { + "from": { + "key_code": "delete_or_backspace" + }, + "to": { + "key_code": "backslash" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "country_code": 0, + "keyboard_type": "ansi", + "mouse_key_xy_scale": 100 + } + }, + { + "complex_modifications": { + "parameters": { + "basic.simultaneous_threshold_milliseconds": 50, + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500, + "mouse_motion_to_scroll.speed": 100 + }, + "rules": [] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "consumer_key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "consumer_key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "key_code": "mission_control" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "launchpad" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "key_code": "illumination_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "key_code": "illumination_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "consumer_key_code": "rewind" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "consumer_key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "consumer_key_code": "fastforward" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "consumer_key_code": "mute" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "consumer_key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "consumer_key_code": "volume_increment" + } + } + ], + "name": "Ergodox", + "parameters": { + "delay_milliseconds_before_open_device": 1000 + }, + "selected": false, + "simple_modifications": [ + { + "from": { + "key_code": "f16" + }, + "to": { + "consumer_key_code": "scan_previous_track" + } + }, + { + "from": { + "key_code": "f17" + }, + "to": { + "consumer_key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f18" + }, + "to": { + "consumer_key_code": "scan_next_track" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "country_code": 0, + "keyboard_type": "ansi", + "mouse_key_xy_scale": 100 + } + }, + { + "complex_modifications": { + "parameters": { + "basic.simultaneous_threshold_milliseconds": 50, + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500, + "mouse_motion_to_scroll.speed": 100 + }, + "rules": [ + { + "description": "Change control to escape if pressed alone.", + "manipulators": [ + { + "from": { + "key_code": "left_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_control" + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + } + ] + }, + { + "description": "Change Control+Shift+h/j/k/l to Arrows", + "manipulators": [ + { + "from": { + "key_code": "h", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "left_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "j", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "down_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "k", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "up_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "l", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "right_arrow" + } + ], + "type": "basic" + } + ] + } + ] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "consumer_key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "consumer_key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "key_code": "mission_control" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "launchpad" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "key_code": "illumination_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "key_code": "illumination_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "consumer_key_code": "rewind" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "consumer_key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "consumer_key_code": "fastforward" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "consumer_key_code": "mute" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "consumer_key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "consumer_key_code": "volume_increment" + } + } + ], + "name": "HHKB", + "parameters": { + "delay_milliseconds_before_open_device": 1000 + }, + "selected": false, + "simple_modifications": [ + { + "from": { + "key_code": "escape" + }, + "to": { + "key_code": "grave_accent_and_tilde" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "country_code": 0, + "keyboard_type": "ansi", + "mouse_key_xy_scale": 100 + } + }, + { + "complex_modifications": { + "parameters": { + "basic.simultaneous_threshold_milliseconds": 50, + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 1000, + "basic.to_if_held_down_threshold_milliseconds": 500, + "mouse_motion_to_scroll.speed": 100 + }, + "rules": [ + { + "description": "Change caps_lock to control if pressed with other keys, to escape if pressed alone.", + "manipulators": [ + { + "from": { + "key_code": "caps_lock", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_control" + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + } + ] + }, + { + "description": "Change Control+Shift+h/j/k/l to Arrows", + "manipulators": [ + { + "from": { + "key_code": "h", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "left_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "j", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "down_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "k", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "up_arrow" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "l", + "modifiers": { + "mandatory": [ + "left_control", + "left_shift" + ] + } + }, + "to": [ + { + "key_code": "right_arrow" + } + ], + "type": "basic" + } + ] + } + ] + }, + "devices": [], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "consumer_key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "consumer_key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "key_code": "mission_control" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "launchpad" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "key_code": "illumination_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "key_code": "illumination_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "consumer_key_code": "rewind" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "consumer_key_code": "play_or_pause" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "consumer_key_code": "fastforward" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "consumer_key_code": "mute" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "consumer_key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "consumer_key_code": "volume_increment" + } + } + ], + "name": "Model M", + "parameters": { + "delay_milliseconds_before_open_device": 1000 + }, + "selected": false, + "simple_modifications": [ + { + "from": { + "key_code": "backslash" + }, + "to": { + "key_code": "delete_or_backspace" + } + }, + { + "from": { + "key_code": "delete_or_backspace" + }, + "to": { + "key_code": "backslash" + } + }, + { + "from": { + "key_code": "left_option" + }, + "to": { + "key_code": "left_command" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "country_code": 0, + "keyboard_type": "ansi", + "mouse_key_xy_scale": 100 + } + } + ] +} diff --git a/macos/.config/skhd/skhdrc b/macos/.config/skhd/skhdrc new file mode 100755 index 0000000..cb2ddce --- /dev/null +++ b/macos/.config/skhd/skhdrc @@ -0,0 +1,59 @@ +# -*- mode: conf -*- + +# +# General +# +shift + cmd - r : skhd -r; launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai" + +# +# Applications +# +shift + cmd - space : alacritty + +# +# Window management +# + +# https://github.com/koekeishiya/yabai/issues/113#issuecomment-511055425 +cmd - space : yabai -m window --focus "$(yabai -m query --windows | jq -re "sort_by(.display, .space, .frame.x, .frame.y, .id) | map(select(.subrole != \"AXUnknown\")) | reverse | nth(index(map(select(.focused == 1))) - 1).id")" +ctrl + cmd - space : yabai -m window --focus "$(yabai -m query --windows | jq -re "sort_by(.display, .space, .frame.x, .frame.y, .id) | map(select(.subrole != \"AXUnknown\")) | nth(index(map(select(.focused == 1))) - 1).id")" + +cmd - return : yabai -m window --toggle zoom-fullscreen +cmd - h : yabai -m window --focus west +cmd - j : yabai -m window --focus south +cmd - k : yabai -m window --focus north +cmd - l : yabai -m window --focus east + +ctrl + cmd - h : yabai -m window --warp west +ctrl + cmd - j : yabai -m window --warp south +ctrl + cmd - k : yabai -m window --warp north +ctrl + cmd - l : yabai -m window --warp east + +shift + cmd - h : yabai -m window --swap west +shift + cmd - j : yabai -m window --swap south +shift + cmd - k : yabai -m window --swap north +shift + cmd - l : yabai -m window --swap east + +# +# Space management +# +cmd - 1 : yabai -m space --focus 1 +cmd - 2 : yabai -m space --focus 2 +cmd - 3 : yabai -m space --focus 3 +cmd - 4 : yabai -m space --focus 4 +cmd - 5 : yabai -m space --focus 5 +cmd - 6 : yabai -m space --focus 6 +cmd - 7 : yabai -m space --focus 7 +cmd - 8 : yabai -m space --focus 8 +cmd - 9 : yabai -m space --focus 9 +cmd - 0 : yabai -m space --focus recent + +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 diff --git a/macos/.config/yabai/yabairc b/macos/.config/yabai/yabairc new file mode 100755 index 0000000..01331f9 --- /dev/null +++ b/macos/.config/yabai/yabairc @@ -0,0 +1,38 @@ +#!/usr/bin/env sh + +# scripting-addition +sudo yabai --load-sa +yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa" + +# global settings +yabai -m config mouse_follows_focus off +yabai -m config focus_follows_mouse off +yabai -m config window_placement second_child +yabai -m config window_topmost off +yabai -m config window_shadow off +yabai -m config window_opacity on +yabai -m config window_opacity_duration 0.0 +yabai -m config active_window_opacity 1.0 +yabai -m config normal_window_opacity 0.75 +yabai -m config window_border on +yabai -m config window_border_width 6 +yabai -m config active_window_border_color 0xff828997 +yabai -m config normal_window_border_color 0xff282c34 +yabai -m config insert_feedback_color 0xffd75f5f +yabai -m config split_ratio 0.50 +yabai -m config auto_balance on +yabai -m config mouse_modifier cmd +yabai -m config mouse_action1 move +yabai -m config mouse_action2 resize +yabai -m config mouse_drop_action swap + +# general space settings +yabai -m config layout bsp +yabai -m config top_padding 24 +yabai -m config bottom_padding 24 +yabai -m config left_padding 24 +yabai -m config right_padding 24 +yabai -m config window_gap 12 + +# Floating applications +yabai -m rule --add app="System Preferences" manage=off diff --git a/macos/.stow-local-ignore b/macos/.stow-local-ignore new file mode 120000 index 0000000..78a4393 --- /dev/null +++ b/macos/.stow-local-ignore @@ -0,0 +1 @@ +../.stow-local-ignore \ No newline at end of file diff --git a/macos/Brewfile b/macos/Brewfile new file mode 100644 index 0000000..2bca74d --- /dev/null +++ b/macos/Brewfile @@ -0,0 +1,50 @@ +# -*- mode: ruby -*- + +tap 'homebrew/command-not-found' +tap 'homebrew/cask-fonts' +tap 'koekeishiya/formulae' + +brew 'git' +brew 'gnupg2' +brew 'jq' +brew 'mas' +brew 'skhd' +brew 'stow' +brew 'trash' +brew 'tree' +brew 'vim' +brew 'yabai' + +brew 'font-pt-sans-narrow' +brew 'font-victor-mono-nerd-font' + +# GNU tools +# https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da +brew 'autoconf' +brew 'bash' +brew 'coreutils' +brew 'diffutils' +brew 'findutils' +brew 'flex' +brew 'gawk' +brew 'gnu-indent' +brew 'gnu-sed' +brew 'gnu-tar' +brew 'gnu-which' +brew 'gpatch' +brew 'grep' +brew 'gzip' +brew 'less' +brew 'm4' +brew 'make' +brew 'watch' +brew 'wdiff' +brew 'wget' + +cask_args appdir: '~/Applications' +cask 'alacritty' +cask 'android-file-transfer' +cask 'cursorcerer' +cask 'iterm2' +cask 'karabiner-elements' +cask 'librewolf' diff --git a/macos/cleanup.sh b/macos/cleanup.sh new file mode 100644 index 0000000..edc9539 --- /dev/null +++ b/macos/cleanup.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env false + +if [[ "$OS" == macos ]] && type /usr/local/bin/brew &>/dev/null; then + # Restore + unset -f /usr/libexec/path_helper +fi diff --git a/macos/env.sh b/macos/env.sh new file mode 100644 index 0000000..a29d3e0 --- /dev/null +++ b/macos/env.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env false + +if [[ "$OS" == macos ]] && type /usr/local/bin/brew &>/dev/null; then + eval `/usr/libexec/path_helper -s` + brew_prefix="$(/usr/local/bin/brew --prefix)" + for p in $brew_prefix/opt/*/libexec/gnubin; do + export PATH="$p:$PATH" + done + unset brew_prefix + export PATH="/usr/local/sbin:$PATH" + export HOMEBREW_CASK_OPTS="--appdir=~/Applications" + + # MacOS calls this in zprofile, temporarily hijack it + function /usr/libexec/path_helper {} +fi diff --git a/macos/install b/macos/install new file mode 100755 index 0000000..6317ce4 --- /dev/null +++ b/macos/install @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" +source ../helpers + +if [[ "$OS" != macos ]]; then + echo '!!! This script is only available for macOS' + exit 1 +fi + +if ! type brew &>/dev/null; then + echo '--- Installing Homebrew' + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if ! type brew &>/dev/null; then + echo '!!! Failed to install Homebrew' + exit 1 + fi +fi +brew analytics off + +install_deps + +# https://eclecticlight.co/2019/08/15/global-defaults-in-macos-mojave/ +echo '--- Setting OS X preferences' +chflags nohidden ~/Library +defaults write -g ApplePressAndHoldEnabled -bool false +defaults write -g KeyRepeat -int 0 +defaults write -g InitialKeyRepeat -int 0 +defaults write -g NSAutomaticCapitalizationEnabled -bool false +defaults write -g NSAutomaticDashSubstitutionEnabled -bool false +defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false +defaults write -g NSAutomaticQuoteSubstitutionEnabled -bool false +defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false +defaults write -g NSAutomaticTextCompletionEnabled -bool false +defaults write -g NSDocumentSaveNewDocumentsToCloud -bool false +defaults write -g WebAutomaticSpellingCorrectionEnabled -bool false +defaults write -g WebKitDeveloperExtras -bool true +defaults write -g com.apple.sound.beep.flash -bool false +defaults write -g com.apple.swipescrolldirection -bool false +defaults write com.apple.Finder FXPreferredViewStyle Nlsv +defaults write com.apple.screencapture disable-shadow true +defaults write com.apple.Safari ShowFavoritesBar -bool false +defaults write com.apple.Safari IncludeInternalDebugMenu -bool true +defaults write com.apple.Safari IncludeDevelopMenu -bool true +defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true +defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true + +if [[ ! -e "$HOME/iCloud" ]]; then + echo '--- Adding symlink to iCloud' + ln -s "$HOME/Library/Mobile Documents/com~apple~CloudDocs" "$HOME/iCloud" +fi diff --git a/ssh/.ssh/config b/ssh/.ssh/config new file mode 100644 index 0000000..4843f29 --- /dev/null +++ b/ssh/.ssh/config @@ -0,0 +1,6 @@ +Host * + ControlMaster auto + ControlPath ~/.ssh/socket/%r@%h:%p + ControlPersist 5s + +Include ~/.ssh/config.local diff --git a/ssh/.stow-local-ignore b/ssh/.stow-local-ignore new file mode 120000 index 0000000..78a4393 --- /dev/null +++ b/ssh/.stow-local-ignore @@ -0,0 +1 @@ +../.stow-local-ignore \ No newline at end of file diff --git a/ssh/Brewfile b/ssh/Brewfile new file mode 100644 index 0000000..a713534 --- /dev/null +++ b/ssh/Brewfile @@ -0,0 +1,3 @@ +# -*- mode: ruby -*- + +brew 'keychain' diff --git a/ssh/install b/ssh/install new file mode 100755 index 0000000..8b2cb77 --- /dev/null +++ b/ssh/install @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" +source ../helpers + +install_deps + +# Set up .ssh and permissions +mkdir -p "$HOME/.ssh/socket" +chmod 700 "$HOME/.ssh" diff --git a/tmux/.stow-local-ignore b/tmux/.stow-local-ignore new file mode 120000 index 0000000..78a4393 --- /dev/null +++ b/tmux/.stow-local-ignore @@ -0,0 +1 @@ +../.stow-local-ignore \ No newline at end of file diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..ce5a0cf --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,122 @@ +# +# General +# +set -g mouse on +set -g base-index 1 +set -g pane-base-index 1 +set -g renumber-windows on + +# +# Keybinds +# +set -sg escape-time 0 +set -g repeat-time 500 +bind r source-file ~/.tmux.conf + +# Undo keybinds +unbind '$' +unbind '"' +unbind d +unbind ( +unbind ) +unbind & +unbind % +unbind o +unbind [ +unbind ] +unbind z +unbind C-b + +# Change prefix key +set -g prefix C-f +bind C-f set status + +# Pane/window manipulation +bind -r h select-pane -L +bind -r j select-pane -D +bind -r k select-pane -U +bind -r l select-pane -R +bind -r H resize-pane -L 2 +bind -r J resize-pane -D 2 +bind -r K resize-pane -U 2 +bind -r L resize-pane -R 2 +bind n new-window +bind N new-session +bind X kill-window +bind m resize-pane -Z +bind -r C-j next-window +bind -r C-k previous-window +bind s split-window -v -c '#{pane_current_path}' +bind S split-window -v -f -c '#{pane_current_path}' +bind v split-window -h -c '#{pane_current_path}' +bind V split-window -h -f -c '#{pane_current_path}' + +# Vim settings +set -g mode-keys vi +bind c copy-mode +bind p paste-buffer +bind \; command-prompt +bind -T copy-mode-vi Escape send -X cancel +bind -T copy-mode-vi 'v' send -X begin-selection +bind -T copy-mode-vi 'y' send -X copy-selection-and-cancel + +# +# Appearance +# +set -g allow-rename off +set -g status-position top +set -g status-left ' ' +set -g status-right '#{prefix_highlight} ' +set -g window-status-format ' #I ' +set -g window-status-current-format '[#I]' +set -g status-style bold +set -g status-fg default +set -g status-bg default +set -g message-style reverse + +# +# Remote sessions support +# https://medium.freecodecamp.org/tmux-in-practice-local-and-nested-remote-tmux-sessions-4f7ba5db8795 +# +bind -T root F12 \ + set prefix None \;\ + set key-table off \;\ + set status-attr default \;\ + set status-fg colour242 \;\ + if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ + refresh-client -S +bind -T off F12 \ + set -u prefix \;\ + set -u key-table \;\ + set status-attr bold \;\ + set status-fg default \;\ + refresh-client -S + +# +# TPM plugins +# +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-prefix-highlight' +set -g @prefix_highlight_copy_prompt 'COPY' +set -g @prefix_highlight_prefix_prompt 'TMUX' +set -g @prefix_highlight_show_copy_mode 'on' +if-shell '[[ "$OS" != macos ]]' \ + 'set -g @plugin "tmux-plugins/tmux-yank"' +if-shell '[ -z "$SSH_CONNECTION" ] || [ -n "$SSH_ROOT" ]' \ + '\ + set -g status-position bottom ;\ + set -g status-right "#{prefix_highlight} #U@#H " ;\ + set -g @plugin "soyuka/tmux-current-pane-hostname" ;\ + ' + +# +# Custom configuration +# +if-shell '[ -f ~/.tmux.conf.local ]' \ + 'source-file ~/.tmux.conf.local' + +# +# TPM bootstrap +# +run '$TMUX_PLUGIN_MANAGER_PATH/tpm/tpm' diff --git a/tmux/Brewfile b/tmux/Brewfile new file mode 100644 index 0000000..8eda798 --- /dev/null +++ b/tmux/Brewfile @@ -0,0 +1,4 @@ +# -*- mode: ruby -*- + +brew 'reattach-to-user-namespace' +brew 'tmux' diff --git a/tmux/aliases.sh b/tmux/aliases.sh new file mode 100644 index 0000000..e25c273 --- /dev/null +++ b/tmux/aliases.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env false + +if [[ -n "$TMUX" ]]; then + function tmuxn { tmux new-window "$*"; } + function tmuxs { tmux split-window -v -c '#{pane_current_path}' "$*"; } + function tmuxsf { tmux split-window -v -f -c '#{pane_current_path}' "$*"; } + function tmuxv { tmux split-window -h -c '#{pane_current_path}' "$*"; } + function tmuxvf { tmux split-window -h -f -c '#{pane_current_path}' "$*"; } +fi diff --git a/tmux/env.sh b/tmux/env.sh new file mode 100644 index 0000000..812eb61 --- /dev/null +++ b/tmux/env.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env false + +export TMUX_PLUGIN_MANAGER_PATH="$DOTFILES/tmux/tpm" diff --git a/tmux/install b/tmux/install new file mode 100755 index 0000000..b6efda3 --- /dev/null +++ b/tmux/install @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" +source ../helpers + +install_deps diff --git a/tmux/tpm/tmux-current-pane-hostname b/tmux/tpm/tmux-current-pane-hostname new file mode 160000 index 0000000..6bb3c95 --- /dev/null +++ b/tmux/tpm/tmux-current-pane-hostname @@ -0,0 +1 @@ +Subproject commit 6bb3c95250f8120d8b072f46a807d2678ecbc97c diff --git a/tmux/tpm/tmux-prefix-highlight b/tmux/tpm/tmux-prefix-highlight new file mode 160000 index 0000000..15acc61 --- /dev/null +++ b/tmux/tpm/tmux-prefix-highlight @@ -0,0 +1 @@ +Subproject commit 15acc6172300bc2eb13c81718dc53da6ae69de4f diff --git a/tmux/tpm/tmux-sensible b/tmux/tpm/tmux-sensible new file mode 160000 index 0000000..989d092 --- /dev/null +++ b/tmux/tpm/tmux-sensible @@ -0,0 +1 @@ +Subproject commit 989d09249e9389604a68d281c999978f6231431b diff --git a/tmux/tpm/tmux-yank b/tmux/tpm/tmux-yank new file mode 160000 index 0000000..1b1a436 --- /dev/null +++ b/tmux/tpm/tmux-yank @@ -0,0 +1 @@ +Subproject commit 1b1a436e19f095ae8f825243dbe29800a8acd25c diff --git a/tmux/tpm/tpm b/tmux/tpm/tpm new file mode 160000 index 0000000..108f76b --- /dev/null +++ b/tmux/tpm/tpm @@ -0,0 +1 @@ +Subproject commit 108f76b628a0df927df142036f1fdec829a5ff00 diff --git a/zsh/.stow-local-ignore b/zsh/.stow-local-ignore new file mode 120000 index 0000000..78a4393 --- /dev/null +++ b/zsh/.stow-local-ignore @@ -0,0 +1 @@ +../.stow-local-ignore \ No newline at end of file diff --git a/zsh/.zlogout b/zsh/.zlogout new file mode 100644 index 0000000..5b4f8bb --- /dev/null +++ b/zsh/.zlogout @@ -0,0 +1 @@ +clear diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..c3e9054 --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,17 @@ +export DOTFILES=$(cd "$(dirname "$HOME/$(readlink $HOME/.zshenv)")" && cd .. && pwd) +source "$DOTFILES/helpers" + +cleanup_helpers + +# Load env files +typeset -U config_files +config_files=($DOTFILES/**/*.sh) +for file in ${(M)config_files:#*/env.sh}; do + source "$file" +done +unset config_files + +# Load .local file at the end for post configurations +if [ -e "$HOME/.zshenv.local" ]; then + source "$HOME/.zshenv.local" +fi diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..ec9db64 --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,67 @@ +# Start tmux if not running already, plus verify it works +if (( $+commands[tmux] )) && [[ -z "$TMUX" ]] && ! [[ -z "$RUN_TMUX" ]]; then + tmux -V >/dev/null + if [[ $? -eq 0 ]]; then + session=default + if [[ -n "$SSH_CONNECTION" ]]; then + session=ssh + elif [[ -n "$DISPLAY" ]]; then + session=gui + fi + exec tmux -2 new-session -A -s $session + exit + fi +fi + +# Set up antibody +if (( $+commands[antibody] )); then + autoload -Uz compinit + compinit + export ANTIBODY_HOME="$DOTFILES/zsh/antibody" + antibody_script="$DOTFILES/zsh/local.sh" + antibody_plugins="$ANTIBODY_HOME/plugins" + antibody_local="$HOME/.antibody" + if ! [[ -f "$antibody_script" ]]; then + antibody_init=1 + elif [[ "$antibody_plugins" -nt "$antibody_script" ]]; then + antibody_init=1 + elif ! [[ -f "$antibody_local" ]]; then + unset antibody_init + elif [[ "$antibody_local" -nt "$antibody_script" ]]; then + antibody_init=1 + else + unset antibody_init + fi + if [[ -n "$antibody_init" ]]; then + antibody bundle < "$antibody_plugins" > "$antibody_script" + if [[ -f "$antibody_local" ]]; then + antibody bundle < "$antibody_local" >> "$antibody_script" + fi + fi +fi + +# Load additional zsh files +typeset -U config_files +config_files=($DOTFILES/*/*.sh) +for file in ${config_files:#*/env.sh}; do + source "$file" +done +unset config_files + +# Additional ZSH options +setopt histreduceblanks +setopt histignorealldups +setopt histignorespace +setopt interactivecomments + +# Remap autosuggest-accept +bindkey '^ ' autosuggest-accept +bindkey '\C-j' down-line-or-search +bindkey '\C-k' up-line-or-search +bindkey '^[[A' up-line-or-search +bindkey '^[[B' down-line-or-search + +# Load .local file at the end for post configurations +if [ -e "$HOME/.zshrc.local" ]; then + source "$HOME/.zshrc.local" +fi diff --git a/zsh/Brewfile b/zsh/Brewfile new file mode 100644 index 0000000..ae4d3d9 --- /dev/null +++ b/zsh/Brewfile @@ -0,0 +1,4 @@ +# -*- mode: ruby -*- + +brew 'antibody' +brew 'zsh' diff --git a/zsh/antibody/plugins b/zsh/antibody/plugins new file mode 100644 index 0000000..42bb6ab --- /dev/null +++ b/zsh/antibody/plugins @@ -0,0 +1,18 @@ +# Base +yous/vanilli.sh + +# Theme +agkozak/agkozak-zsh-prompt + +# Vim +zsh-users/zsh-autosuggestions +zdharma/fast-syntax-highlighting +softmoth/zsh-vim-mode + +# Extras +chrissicool/zsh-256color +hlissner/zsh-autopair +robbyrussell/oh-my-zsh path:plugins/colored-man-pages +robbyrussell/oh-my-zsh path:plugins/command-not-found +zakariaGatter/markgate +zsh-users/zsh-history-substring-search diff --git a/zsh/env.sh b/zsh/env.sh new file mode 100644 index 0000000..3229cee --- /dev/null +++ b/zsh/env.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env false + +export AGKOZAK_MULTILINE=0 diff --git a/zsh/install b/zsh/install new file mode 100755 index 0000000..bec82c1 --- /dev/null +++ b/zsh/install @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" +source ../helpers + +install_deps + +if ! which zsh &>/dev/null; then + echo '!!! ZSH is not available' + exit +fi + +if [[ "$OS" == macos ]] && ! (cat /etc/shells | grep "$(which zsh)" &>/dev/null); then + echo '--- Adding Homebrew zsh to /etc/shells' + echo "$(which zsh)" | sudo tee -a /etc/shells >/dev/null +fi + +if ! echo $SHELL | grep zsh$ &>/dev/null; then + echo '--- Changing shell to zsh' + chsh -s "$(cat /etc/shells | grep zsh | tail -n 1)" >/dev/null +fi + +if ! which antibody &>/dev/null; then + echo '--- Installing antibody' + curl -sL https://git.io/antibody | bash -s +fi