Skip to content

Commit

Permalink
make scripts work on macos again
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkna committed Dec 21, 2020
1 parent bd2f9d7 commit 2e93f32
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 107 deletions.
53 changes: 23 additions & 30 deletions run_once_10_install.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
###
# Repos
###
{{- if eq .chezmoi.os "linux" }}

{{- if eq .chezmoi.osRelease.name "Fedora" }}

Expand All @@ -30,24 +31,19 @@ echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com
# Tailscale
sudo dnf config-manager --add-repo https://pkgs.tailscale.com/stable/fedora/tailscale.repo

{{- end }}

{{- if and (eq .chezmoi.os "darwin") (eq .chezmoi.arch "amd64") }}
brew bundle --global
{{- end }}

{{- if eq .chezmoi.osRelease.name "Arch Linux" }}
{{- else if eq .chezmoi.osRelease.name "Arch Linux" }}
sudo pacman -S --needed --noconfirm flatpak
{{- end }}

{{- if eq .chezmoi.os "linux" }}
# Flathub
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
{{- end }}

{{- end}}

###
# Install
###
{{- if eq .chezmoi.os "linux" }}

{{- if eq .chezmoi.osRelease.name "Fedora" }}
# DNF packages
Expand All @@ -64,9 +60,12 @@ sudo dnf install -y \
# DNF groups
sudo dnf groupinstall "Development Tools" "C Development Tools and Libraries" -y

{{- end }}
# Flatpaks
sudo flatpak install -y flathub com.bitwarden.desktop
sudo flatpak install -y flathub com.discordapp.Discord


{{- if eq .chezmoi.osRelease.name "Arch Linux" }}
{{- else if eq .chezmoi.osRelease.name "Arch Linux" }}
if [[ ! -x "$(command -v paru)" ]]; then
git clone https://aur.archlinux.org/paru.git ~/Quellen/paru
makepkg --noconfirm -si ~/Quellen/paru
Expand All @@ -80,11 +79,10 @@ paru -S --needed --noconfirm \
lsd npm tailscale bitwarden-cli bitwarden-bin bat direnv git-delta
{{- end }}

{{- else if and (eq .chezmoi.os "darwin") (eq .chezmoi.arch "amd64") }}

brew bundle --global

{{- if eq .chezmoi.osRelease.name "Fedora" }}
# Flatpaks
sudo flatpak install -y flathub com.bitwarden.desktop
sudo flatpak install -y flathub com.discordapp.Discord
{{- end }}

# Vim Plug
Expand All @@ -97,35 +95,30 @@ if [[ ! -d ~/.zinit ]]; then
git clone https://github.com/zdharma/zinit.git ~/.zinit/bin
fi

# Fonts
{{- if eq .chezmoi.os "linux" }}
if [[ ! -f '/usr/share/fonts/TTF/Caskaydia Cove Regular Nerd Font Complete.ttf' ]]; then
curl -Lo '/tmp/Caskaydia Cove Regular Nerd Font Complete.ttf' https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/CascadiaCode/complete/Caskaydia%20Cove%20Regular%20Nerd%20Font%20Complete.ttf?raw=true
sudo install -Dm644 -t /usr/share/fonts/TTF '/tmp/Caskaydia Cove Regular Nerd Font Complete.ttf'
sudo fc-cache -f
fi
{{- end }}

# Rust utils
if [[ ! -x "$(command -v rustup)" ]]; then
{{- if and (ne .chezmoi.os "darwin") (ne .chezmoi.arch "arm64") }}
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y
{{- else }}
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path --default-toolchain beta -y
{{- end }}
fi

test -f ~/.cargo/env && source ~/.cargo/env
export PATH=~/.cargo/bin:"$PATH"

if [[ ! -x ~/.cargo/bin/lolcow-fortune ]]; then
cargo install --features mimalloc lolcow-fortune
if [[ ! -x "$(command -v lolcow-fortune)" ]]; then
cargo install lolcow-fortune
lolcow-fortune download
fi

if [[ ! -x ~/.cargo/bin/cargo-install-update ]]; then
if [[ ! -x "$(command -v cargo-install-update)" ]]; then
cargo install cargo-update
fi

if [[ ! -x "$(command -v topgrade)" ]]; then
if [[ ! -x "$(command -v topgrade)" ]]; then
cargo install topgrade
fi

if [[ ! -x "$(command -v hexyl)" ]]; then
if [[ ! -x "$(command -v hexyl)" ]]; then
cargo install hexyl
fi
80 changes: 3 additions & 77 deletions run_once_20_settings.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ bash -c "$(curl -fsSL https://raw.githubusercontent.com/denysdovhan/one-gnome-te

# Tailscale
sudo systemctl enable --now tailscaled
{{- end }}

# Shell
sudo chsh -s $(which zsh) $(whoami)

# HiDPI
{{- if eq .chezmoi.os "linux" }}
gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"
{{- end }}

{{- if eq .chezmoi.os "darwin" }}
{{- else if eq .chezmoi.os "darwin" }}

# based on:
# ~/.macos — https://mths.be/macos

Expand All @@ -65,15 +63,6 @@ defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true
# Disable the crash reporter
defaults write com.apple.CrashReporter DialogType -string "none"

###############################################################################
# Screenshots #
###############################################################################

# 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)
defaults write com.apple.screencapture type -string "png"

###############################################################################
# Finder #
Expand All @@ -94,18 +83,6 @@ defaults write com.apple.finder AppleShowAllFiles -bool true
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true

# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true

# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true

# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true

# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"

Expand Down Expand Up @@ -135,9 +112,6 @@ defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# 11: Launchpad
# 12: Notification Center
# 13: Lock Screen
# Top left screen corner → Mission Control
defaults write com.apple.dock wvous-tl-corner -int 2
defaults write com.apple.dock wvous-tl-modifier -int 0
# Top right screen corner → Desktop
defaults write com.apple.dock wvous-tr-corner -int 4
defaults write com.apple.dock wvous-tr-modifier -int 0
Expand Down Expand Up @@ -175,48 +149,6 @@ defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool true
# Update extensions automatically
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true

###############################################################################
# Spotlight #
###############################################################################

# Change indexing order and disable some search results
# Yosemite-specific search results (remove them if you are using macOS 10.9 or older):
# MENU_DEFINITION
# MENU_CONVERSION
# MENU_EXPRESSION
# MENU_SPOTLIGHT_SUGGESTIONS (send search queries to Apple)
# MENU_WEBSEARCH (send search queries to Apple)
# MENU_OTHER
defaults write com.apple.spotlight orderedItems -array \
'{"enabled" = 1;"name" = "APPLICATIONS";}' \
'{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
'{"enabled" = 1;"name" = "DIRECTORIES";}' \
'{"enabled" = 1;"name" = "PDF";}' \
'{"enabled" = 1;"name" = "FONTS";}' \
'{"enabled" = 0;"name" = "DOCUMENTS";}' \
'{"enabled" = 0;"name" = "MESSAGES";}' \
'{"enabled" = 0;"name" = "CONTACT";}' \
'{"enabled" = 0;"name" = "EVENT_TODO";}' \
'{"enabled" = 0;"name" = "IMAGES";}' \
'{"enabled" = 0;"name" = "BOOKMARKS";}' \
'{"enabled" = 0;"name" = "MUSIC";}' \
'{"enabled" = 0;"name" = "MOVIES";}' \
'{"enabled" = 0;"name" = "PRESENTATIONS";}' \
'{"enabled" = 0;"name" = "SPREADSHEETS";}' \
'{"enabled" = 0;"name" = "SOURCE";}' \
'{"enabled" = 0;"name" = "MENU_DEFINITION";}' \
'{"enabled" = 0;"name" = "MENU_OTHER";}' \
'{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
'{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
'{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
'{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
# Load new settings before rebuilding the index
killall mds > /dev/null 2>&1
# Make sure indexing is enabled for the main volume
sudo mdutil -i on / > /dev/null
# Rebuild the index from scratch
sudo mdutil -E / > /dev/null

###############################################################################
# Terminal & iTerm 2 #
###############################################################################
Expand All @@ -233,13 +165,6 @@ defaults write com.apple.terminal StringEncodings -array 4
# See: https://security.stackexchange.com/a/47786/8918
defaults write com.apple.terminal SecureKeyboardEntry -bool true

###############################################################################
# Time Machine #
###############################################################################

# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true

###############################################################################
# Activity Monitor #
###############################################################################
Expand Down Expand Up @@ -295,4 +220,5 @@ defaults write com.apple.commerce AutoUpdate -bool true

# Allow the App Store to reboot machine on macOS updates
defaults write com.apple.commerce AutoUpdateRestartRequired -bool true

{{- end }}

0 comments on commit 2e93f32

Please sign in to comment.