curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh
brew install chezmoi
curl -sfL https://git.io/chezmoi | sh
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
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"
sudo pacman -S chezmoi --noconfirm
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"
PARU_PATH=/tmp/paru
git clone https://aur.archlinux.org/paru.git $PARU_PATH
(cd $PARU_PATH && makepkg -si)
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"
ZPLUG_PATH="$HOME/.zplug"
if [ ! -d "$ZPLUG_PATH" ]; then
git clone https://github.com/zplug/zplug "$ZPLUG_PATH"
fi
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
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
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
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
Some of this configurations are from this link.
ansi --green "Always show scrollbars"
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
ansi --green "Save to disk and not in iCloud by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
ansi --green "Quit printer app when jobs are completed"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
ansi --green "Disable the “Are you sure you want to open this application?” dialog"
defaults write com.apple.LaunchServices LSQuarantine -bool false
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
ansi --green "Increase sound quality for Bluetooth headphones/headsets"
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
ansi --green "Set a blazingly fast keyboard repeat rate"
defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
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
ansi --green "Save screenshots to the desktop"
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
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
ansi --green "Finder: show all filename extensions"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
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
ansi --green "Set to check daily instead of weekly"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
ansi --green "Set default clock format"
defaults write com.apple.menuextra.clock DateFormat -string "EEE d MMM h:mm:ss a"
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}"
ansi --green "Killing Finder.."
killall Finder
ansi --green "Killing SystemUIServer"
killall SystemUIServer
ansi --green "Build Locate Database"
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
ansi --green "Enable firewall"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
ansi --green "Set Clock Using Network Time"
sudo systemsetup setusingnetworktime on
General Linux commands
- Speed up keyboard
xset r rate 180 40
Archlinux related configuration.
find /etc -regextype posix-extended -regex ".+\.pac(new|save)"
pacman -Qqen
pacman -Qqem
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
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 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
- Allow Docker runs with non-root user.
sudo usermod -aG docker $USER
newgrp docker
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
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 700 ~/.gnupg/*
chmod 700 ~/.gnupg
Change the $HOME/dotfiles
directory
chezmoi init -S $HOME/dotfiles
mkdir -pv $HOME/mail
mkdir -pv $HOME/mail/.attachments
mkdir -pv $HOME/workspace/opt
mkdir -pv $HOME/workspace/go
chezmoi apply -v
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 -}}
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 -}}
Variables are then passed to the data
section
...
data:
secrets: {{ $secrets }}
headless: {{ $headless }}
email: {{ $email }}
...
If secrets is true
, then apply bitwarden
’s item ids
{{- if $secrets }}
bitwarden:
jira: 8c7e36c5-a859-4fe6-a0c2-acb500c08fff
...
{{- end -}}
Finally, from the previous Chezmoi section, this is the generated configuration file.
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 }}
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 }}
The final configuration
...
The following in my Wakatime configuration. The API key is set automatically by Chezmoi, see Chezmoi secrets configuration.
The following enables autocomplete when on a standard python interpreter and keeps history around sessions.
Create Xresources
file with Gruvbox as default theme.
Create xinitrc
which gets called by =xsession=.
Start i3wm
automatically on Xsession
The following is Gitmux’s configuration file.
The tmux.conf
requires TPM to work.
- 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} "
This enables autocomplete for any program that uses readline
and enabled vi
keybinding.
Sets OSX keybindings
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 aspyenv
anddircolors
.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
For performance, this first checks if the generated plugin bundle is in
$HOME/.zsh_plugins.sh
. If not, it will generate upon start.
The user
section is auto generated with Chezmoi.
I keep a few Git templates, which are applied on git init
or on clone
.
Note: The new line at the beginning is important.
The following configuration requires both all plugins to be install and VimPlug.
This allows nvim
to read vim
’s configuration.
The following are snippets that are automatically applied on a new file.
The following scripts is a compilation of all the previous commands, together
with some extra OS
checks and a custom echo
with colored output.
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.