Skip to content

Instantly share code, notes, and snippets.

@agzam
Last active September 30, 2025 15:31
Show Gist options
  • Select an option

  • Save agzam/bf7d4e7276d41b669c66ce54c11c5d81 to your computer and use it in GitHub Desktop.

Select an option

Save agzam/bf7d4e7276d41b669c66ce54c11c5d81 to your computer and use it in GitHub Desktop.
Dotfile boostrap script
# This is my personal script to deal with initial bottleneck of boostrapping new system
# My source of truth for dotfiles is a single .org file in a private repo
# This script installs gh, Emacs, clones the repo and org-babel tangles everything in a batch mode
# To run:
# curl --location https://gist.githubusercontent.com/agzam/bf7d4e7276d41b669c66ce54c11c5d81/raw/bootstrap.sh | bash
if [[ "$OSTYPE" == "darwin"* ]]; then
# "Set a blazingly fast keyboard repeat rate, "
defaults write NSGlobalDomain KeyRepeat -int 1
# "Set a shorter Delay until key repeat"
defaults write NSGlobalDomain InitialKeyRepeat -int 9
# Disable long-press accents
defaults write -g ApplePressAndHoldEnabled -bool false
# Increase the Dock show/hide speed
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-time-modifier -float 0.5
killall Dock
# 'Are you sure you want to open this application?'
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Unnatural mouse scrolling
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
# Mouse speed
defaults write NSGlobalDomain com.apple.mouse.scaling -float 1.5
defaults write -g com.apple.trackpad.scaling -float 2
# TODO: figure this out. I'm not sure this works
defaults write com.apple.AppleMultitouchTrackpad "TrackpadThreeFingerDrag" -bool "true"
# Disable default Spotlight shortcut
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 64 "
<dict>
<key>enabled</key>
<false/>
</dict>"
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
fi
if ! command -v gh &> /dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
echo "Homebrew is already installed"
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(brew shellenv)"
fi
echo "Installing bitwarden"
brew install bitwarden-cli
echo "Installing gh via homebrew"
brew install gh
elif [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
case $OS in
ubuntu)
echo "Detected Ubuntu, installing gh via wget"
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
;;
arch)
echo "Detected Arch, installing gh via pacman"
sudo pacman -S github-cli
;;
*)
echo "Unknown system"
;;
esac
fi
fi
if ! gh auth status &>/dev/null; then
echo "Not logged in to GitHub CLI. Logging in..."
gh auth login
else
echo "Already authenticated with GitHub CLI"
fi
# here we need to install Emacs
if ! command -v emacs &> /dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew tap d12frosted/emacs-plus
brew install emacs-plus@31 --with-xwidgets --with-modern-papirus-icon --verbose
elif [ -f /etc/os-release ]; then
case $OS in
ubuntu)
sudo apt update -yyy
sudo apt install autoconf build-essential \
texinfo libtree-sitter-dev libgnutls28-dev pkg-config \
libgccjit-$(gcc -dumpversion | cut -d'.' -f1)-dev \
zlib1g-dev libdbus-1-dev libncurses-dev -yyy
;;
arch)
sudo pacman -S libgccjit
;;
esac
case $OS in
ubuntu|arch)
echo "Installing Emacs on $OS"
git clone git://git.sv.gnu.org/emacs.git ~/emacs-src
cd ~/emacs-src
./autogen.sh && \
./configure \
--with-tree-sitter \
--with-json \
--with-modules \
--without-x \
--with-toolkit-scroll-bars \
--without-imagemagick \
--without-mailutils \
--with-dbus \
# --with-native-compilation=aot \
# --without-xwidgets \
# --with-x-toolkit=lucid \
# --with-cairo \
# --with-xft \
# --with-xinput2 \
--verbose \
CFLAGS="-O2 -mtune=native -march=native -fomit-frame-pointer" \
&& \
make && \
sudo make install
;;
esac
fi
fi
if command -v emacs &> /dev/null; then
cd ~
rm -rf ~/GitHub/agzam/dotfile.org
gh repo clone agzam/dotfile.org ~/GitHub/agzam/dotfile.org
cd ~/GitHub/agzam/dotfile.org
emacs --batch -l org dotfile.org --eval '(load-file "./dotfile-scripts.el")' -f org-babel-tangle
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment