Skip to content

Latest commit

 

History

History
686 lines (603 loc) · 22 KB

notes.org

File metadata and controls

686 lines (603 loc) · 22 KB

Notes

Development notes

System dependencies

Installing Homebrew

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh

Installing Chezmoi with Homebrew

brew install chezmoi

Installing chezmoi without Homebrew

curl -sfL https://git.io/chezmoi | sh

Install Homebrew packages

brew bundle requires either Brewfile to be defined at the HOMEBREW_BUNDLE_FILE’s env, or passed with --file= flag or be at the same directory the command is ran.

brew bundle

Install mute app

curl https://github.com/pixel-point/mute-me/releases/download/v2.0.0-rc2/mute-me-v2.0.0-rc2.zip \
        -L -o /tmp/muteme.zip

unzip -o /tmp/muteme.zip -d /tmp/
mv "/tmp/Mute Me.app" "$HOME/Applications/Mute Me.app"

Installing Chezmoi with Pacman

sudo pacman -S chezmoi --noconfirm

Installing Pacman packages

For an example of a Pacman package file, see Pacfile. The following, assumes Pacfile is set in an env variable called PACMAN_BUNDLE_FILE.

sudo pacman -Syy
sudo pacman -S --noconfirm --needed - <"$PACMAN_BUNDLE_FILE"

Install Paru (AUR wrapper)

PARU_PATH=/tmp/paru

git clone https://aur.archlinux.org/paru.git $PARU_PATH
(cd $PARU_PATH && makepkg -si)

Install AUR packages

For an example of a AUR package file, see Aurfile. The following, assumes Aurfile is set in an env variable called AUR_BUNDLE_FILE.

paru -S --nouseask - <"$AUR_BUNDLE_FILE"

Install Git repositories

Install Zplug

ZPLUG_PATH="$HOME/.zplug"
if [ ! -d "$ZPLUG_PATH" ]; then
	git clone https://github.com/zplug/zplug "$ZPLUG_PATH"
fi

Install Tmux TPM

TMUX_TPM_PATH="$HOME/.tmux/plugins/tpm"
if [ ! -d "$TMUX_TPM_PATH" ]; then
	mkdir -p "$TMUX_TPM_PATH"
	git clone https://github.com/tmux-plugin/tpm "$TMUX_TPM_PATH"
fi

Install Vim Plug

VIM_PLUG_PATH="$HOME/.vim/autoload"
if [ ! -d "$VIM_PLUG_PATH" ]; then
	curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
		https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

	if ! [ -x "$(command -v nvim)" ]; then
		nvim +PlugInstall +qall --headless
		nvim +UpdateRemotePlugins +qall --headless
	fi
fi

Install Base-16

BASE16_PATH="$HOME/.config/base16-shell"
if [ ! -d "$BASE16_PATH" ]; then
	mkdir -p "$BASE16_PATH"
	git clone https://github.com/chriskempson/base16-shell "$BASE16_PATH"
fi

Install Emacs Doom

EMACS_PATH="$HOME/.emacs.d"
if [ ! -d "$EMACS_PATH" ]; then
	mkdir -p "$EMACS_PATH"
	git clone --depth 1 https://github.com/hlissner/doom-emacs "$EMACS_PATH"
	"$EMACS_PATH"/bin/doom -y install
else
	"$EMACS_PATH"/bin/doom -y sync -e
fi

System configuration

OSX

Some of this configurations are from this link.

Always show scrollbar

ansi --green "Always show scrollbars"
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"

Don’t save to iCloud by default, use disk instead

ansi --green "Save to disk and not in iCloud by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false

Quit printer when all jobs complete

ansi --green "Quit printer app when jobs are completed"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

Disable the “Are you sure you want to open this app?” dialog

ansi --green "Disable the “Are you sure you want to open this application?” dialog"
defaults write com.apple.LaunchServices LSQuarantine -bool false

Enable trackpad tap to click for this user and for the login screen

ansi --green "Trackpad: enable tap to click for this user and for the login screen"
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1

Increase sound quality for Bluetooth headphones

ansi --green "Increase sound quality for Bluetooth headphones/headsets"
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

Set fast keyboard repeat rate

ansi --green "Set a blazingly fast keyboard repeat rate"
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10

Require password immediately after sleep or screen saver

ansi --green "Require password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0

Save screenshots to the desktop

ansi --green "Save screenshots to the desktop"
defaults write com.apple.screencapture location -string "${HOME}/Desktop"

Save screenshots in PNG format

Other options: BMP, GIF, JPG, PDF, TIFF

ansi --green "Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)"
defaults write com.apple.screencapture type -string "png"

Show hidden files in Finder by default

ansi --green "Finder: show hidden files by default"
defaults write com.apple.finder AppleShowAllFiles -bool true

Show all filename extensions in Finder

ansi --green "Finder: show all filename extensions"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true

Avoid creating .DS_Store files on network or USB volumes

ansi --green "Avoid creating .DS_Store files on network or USB volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Check for daily for software updates

ansi --green "Set to check daily instead of weekly"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

Set default clock format

ansi --green "Set default clock format"
defaults write com.apple.menuextra.clock DateFormat -string "EEE d MMM h:mm:ss a"

Set default Finder location to $HOME

ansi --green "Set Default Finder Location to Home Folder"
defaults write com.apple.finder NewWindowTarget -string "PfLo" &&
	defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"

Kill Finder to apply defaults

ansi --green "Killing Finder.."
killall Finder

Kill SystemUIServer for UI defaults

ansi --green "Killing SystemUIServer"
killall SystemUIServer

Enable locate database

ansi --green "Build Locate Database"
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Enable firewall

ansi --green "Enable firewall"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

Set network clock sync

ansi --green "Set Clock Using Network Time"
sudo systemsetup setusingnetworktime on

Linux

General Linux commands

  • Speed up keyboard
xset r rate 180 40

Archlinux

Archlinux related configuration.

Find all *.pacnew files in /etc

find /etc -regextype posix-extended -regex ".+\.pac(new|save)"

List pacman packages ignoring foreign packages (AUR, etc).

pacman -Qqen

Get list of foreing (AUR, etc) packages with pacman.

pacman -Qqem

Pacman conf

This enables color, total downloads, check space and sets verbose PKG list when running pacman.

sudo sed -i '/Color$/s/^#//g' /etc/pacman.conf
sudo sed -i '/TotalDownload$/s/^#//g' /etc/pacman.conf
sudo sed -i '/CheckSpace$/s/^#//g' /etc/pacman.conf
sudo sed -i '/VerbosePkgLists$/s/^#//g' /etc/pacman.conf

Set timezone

Enable ntp sync, set timezone to Sao Paulo and sync hardware clock.

sudo timedatectl set-ntp true
sudo ln -sf /usr/share/zoneinfo/Ameriaca/Sao_Paulo /etc/localtime
sudo hwclock --systohc

Set locale

Set locale to en_US.UTF-8 by default and generate the locale file.

sudo sed -i '/en_US.UTF-8$/s/^#//g' /etc/pacman.conf
sudo locale-gen

Docker

  • Allow Docker runs with non-root user.
sudo usermod -aG docker $USER
newgrp docker

Set SSH permissions

chmod 755 "$HOME"/.ssh
[[ -f "$HOME/.ssh/id_rsa" ]] && chmod 600 "$HOME"/.ssh/id_rsa
[[ -f "$HOME/.ssh/id_rsa.pub" ]] && chmod 600 "$HOME"/.ssh/id_rsa.pub

Set GNUPG permissions

chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 700 ~/.gnupg/*
chmod 700 ~/.gnupg

Initialize chezmoi

Change the $HOME/dotfiles directory

chezmoi init -S $HOME/dotfiles

Ensure important directories

mkdir -pv $HOME/mail
mkdir -pv $HOME/mail/.attachments
mkdir -pv $HOME/workspace/opt
mkdir -pv $HOME/workspace/go

Apply Chezmoi config files

chezmoi apply -v

Dotfiles configuration

Chezmoi

Configuration

Chezmoi default variables

When secret is set to true (default), it will apply all template files which requires any secret to be applied. If chezmoi is running in a CI environment, set secret to false by default.

{{- $secrets := true -}}
...

{{- if (env "CI") -}}
{{- $secrets = false -}}
...
{{- end -}}
Chezmoi prompts

If the ASK env is defined (ASK=1 chezmoi init -S <dotfiles-dir>), Chezmoi will prompt for the default variables.

{{- if (env "ASK") }}
{{- $secrets := promptBool "secrets" -}}
{{- $name := promptString "full name" -}}
...
{{- end -}}
Chezmoi data configuration

Variables are then passed to the data section

...
data:
  secrets: {{ $secrets }}
  headless: {{ $headless }}
  email: {{ $email }}
  ...
Chezmoi secrets configuration

If secrets is true, then apply bitwarden’s item ids

{{- if $secrets }}
  bitwarden:
    jira: 8c7e36c5-a859-4fe6-a0c2-acb500c08fff
    ...
{{- end -}}
Chezmoi final configuration

Finally, from the previous Chezmoi section, this is the generated configuration file.

Chezmoi ignore

Ignore by distribution

Since Chezmoi allows multiple platforms, we can handle which files we want Chezmoi to ignore based on the OS type.

# Don't copy the following files if OS is OSX
{{- if ne .chezmoi.os "linux" }}
.xinitrc
.xsession
...
{{- end }}

# Don't copy the following files if OS is Linux
{{- if ne .chezmoi.os "darwin" }}
.skhdrc
...
{{- end }}
Ignore if secrets is not set

Remember the secret variable set in default variables? Since this dotfiles is ran on a CI, we don’t want to apply any configuration file that contains any secret. Since the CI environment variable is set, secrets defaults to false .

{{- if not .secrets }}
.mbsyncrc
.config/msmtp
.wakatime.cfg
...
{{- end }}
Chezmoi final .chezmoiignore

The final configuration

Archive
Defaults to ignore
...

Wakatime

The following in my Wakatime configuration. The API key is set automatically by Chezmoi, see Chezmoi secrets configuration.

Pythonrc

The following enables autocomplete when on a standard python interpreter and keeps history around sessions.

Xorg

xmodmap

XResources

Create Xresources file with Gruvbox as default theme.

xinitrc

Create xinitrc which gets called by =xsession=.

xsession

Start i3wm automatically on Xsession

Tmux

Gitmux

The following is Gitmux’s configuration file.

Tmux conf

The tmux.conf requires TPM to work.

Archive

CANCELED Tmux base16 gruvbox theme
  • State “CANCELED” from [2021-02-27 Sat 22:56]

This isn’t needed as I am now using Alkindi42/tmux-bitwarden.

The following configures theme defaults for tmux

# from: https://github.com/LawAbidingCactus/tmux-gruvbox-truecolor
### theme settings ###

# window separators
set-option -wg window-status-separator ""

# monitor window changes
set-option -wg monitor-activity on
set-option -wg monitor-bell on

# set statusbar update interval
set-option -g status-interval 1

### colorscheme ###

# change window screen colors
set-option -wg mode-style bg="#FE8019",fg="#3C3836"

# default statusbar colors (terminal bg should be #282828)
set-option -g status-style bg=terminal,fg="#A89984"

# default window title colors
set-option -wg window-status-style bg="#3C3836",fg="#7C6F64"

# colors for windows with activity
set-option -wg window-status-activity-style bg="#3C3836",fg="#A89984"

# colors for windows with bells
set-option -wg window-status-bell-style bg="#3C3836",fg="#FE8019"

# active window title colors
set-option -wg window-status-current-style bg="#FE8019",fg="#3C3836"

# pane border
set-option -g pane-active-border-style fg="#FE8019"
set-option -g pane-border-style fg="#3C3836"

# message info
set-option -g message-style bg="#FE8019",fg="#3C3836"

# writing commands inactive
set-option -g message-command-style bg="#A89984",fg="#3C3836"

# pane number display
set-option -g display-panes-active-colour "#FE8019"
set-option -g display-panes-colour "#3C3836"

# clock
set-option -wg clock-mode-colour "#FE8019"

# copy mode highlighting
%if #{>=:#{version},3.2}
    set-option -wg copy-mode-match-style "bg=#A89984,fg=#3C3836"
    set-option -wg copy-mode-current-match-style "bg=#FE8109,fg=#3C3836"
%endif

set -g status-right-length 150

# statusbar formatting
# "#fe8019" MUST be in lowercase here (conflicts with statusline alias otherwise)
set-option -g status-left "#{session_name} "
set-option -g status-right "#{prefix_highlight} #{battery_icon} #{battery_percentage} | %d-%m-%Y %H:%M:%S | Online: #{online_status}| #{weather} | #(gitmux -cfg ~/.gitmux.conf '#{pane_current_path}') "

set-option -wg window-status-current-format " #{window_index} #{window_name} "
set-option -wg window-status-format " #{window_index} #{window_name} "

Dircolors

Curl

Inputrc

This enables autocomplete for any program that uses readline and enabled vi keybinding.

Editorconfig

Skhdrc

Sets OSX keybindings

Zsh

My zsh setup if organized as following:

  • .zshrc includes all zsh files related to the configuration
  • .zsh/aliases.zsh holds all aliases I use
  • .zsh/evals.zsh holds all async evaluations, such as pyenv and dircolors
  • .zsh/exports.zsh holds all exported variables
  • .zsh/git_aliases.zsh holds all git related aliases
  • .zsh/gpg_agent.zsh handles GnuPG agent
  • .zsh/history.zsh configures how command history is saved
  • .zsh/init.zsh handles all important initialization that requires everything to work
  • .zsh/keys.zsh keybindings
  • .zsh/plugins.txt plugins that are managed with Antibody
  • .zsh/stack.zsh configures shell stack related configuration

plugins.txt

keys.zsh

stack.zsh

history.zsh

gpg-agent.zsh

exports.zsh

aliases.zsh

git_aliases.zsh

init.zsh

evals.zsh

.zshrc

For performance, this first checks if the generated plugin bundle is in $HOME/.zsh_plugins.sh. If not, it will generate upon start.

Git

Git config

The user section is auto generated with Chezmoi.

Git templates

I keep a few Git templates, which are applied on git init or on clone.

Show a small reminder of commits when running git commit

Note: The new line at the beginning is important.

Vim

vimrc

The following configuration requires both all plugins to be install and VimPlug.

plugins.vim

nvimrc

This allows nvim to read vim’s configuration.

Emacs

Snippets

The following are snippets that are automatically applied on a new file.

Org template
Python template

Scripts

The following scripts is a compilation of all the previous commands, together with some extra OS checks and a custom echo with colored output.

Script base

This gets the current path the script is running, which should be scripts/ and allows sourcing any file in this directory.

Source the base.sh script which includes script helpers.

Source =ansi= for pretty echo.

Source buildcheck for exiting when running on CI.

Homebrew install final script

Chezmoi install final script

Install packages final script

Install AUR packages final script

Install Git packages final script

Configure OSX final script

Configure Archlinux final script

Configure system final script

SSH permission final script

GNUPG permission final script

Ensure directory final script