dotfiles helper, configs and stuff

This commit is contained in:
Ismo Vuorinen
2022-12-07 16:14:43 +02:00
parent 0f87411f65
commit a53d655fd7
13 changed files with 483 additions and 48 deletions

29
config/gh/gh-extensions.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Install GitHub CLI extensions
# GitHub CLI extension for reviewing Dependabot PRs.
gh extension install einride/gh-dependabot
# A GitHub CLI extension that provides summary pull request metrics.
gh extension install hectcastro/gh-metrics
# being an extension to view the overall health of an organization's use of actions
gh extension install rsese/gh-actions-status
# GitHub CLI extension for label management
gh extension install heaths/gh-label
# An opinionated GitHub Cli extension for creating
# changelogs that adhere to the keep a changelog specification.
gh extension install chelnak/gh-changelog
# Safely deletes local branches with no upstream and no un-pushed commits
gh extension install davidraviv/gh-clean-branches
# A beautiful CLI dashboard for GitHub 🚀
gh extension install dlvhdr/gh-dash
# A github-cli extension script to clone all repositories
# in an organization, optionally filtering by topic.
gh extension install matt-bartel/gh-clone-org
# GitHub CLI extension to generate montage from GitHub user avatars
gh extension install andyfeller/gh-montage
# Organisation specific extension for gh cli to retrieve different statistics
gh extension install VildMedPap/gh-orgstats
# GitHub CLI extension for generating a report on repository dependencies.
gh extension install andyfeller/gh-dependency-report
# gh cli extension to generate account/organization/enterprise reports
gh extension install stoe/gh-report

View File

@@ -1,7 +1,6 @@
[user]
name = Ismo Vuorinen
email = ismo.vuorinen@vincit.fi
signingkey = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDLyOvkr1nRqMVv3UAizmk6C+q40H4khvw7qIXXXyOyFmzjwYx/Cuxoi4uZVjX+q4qFYJ+c312uu6YXiEtfyoCao3wub8r1cLBQ3eIvuyWp2K8Ixcd9JmFmLmoeiENpJxqyr0WPZLDkrCWUZCsQQh8zzGFnfciUdUdTiZ7s21AEhhmFRSdFlVfQSlGMFxU321psg1YilcP80bDwFd1FsL4TssSkwlbgP/twqnpZ4436TTo7kp0UnH/RZkfRdDWScKHaWgncBG0CZeQxGWnRp8fvZn/7gDnthcZhvnDALVBE7QFuZ90GxqVw3IGpHryV0mFO6EGQ9Ke9YX7pKVZPUXZjeCN4SVKsqFdVJ6AjaSJ9K7nL98rYK7qNzndT3cKqPNgPteyXWRulH68A51ecQqHrjTttZcdN9hKt9uBHpzuXsby2QObT+VB4MNjZapa+YYF/WgwJCml4lzn2xMFg1vYZD78pfoJ9e5f2cL1MMlUSDb0TNxmEXfDQ77H/pRpKDz0=
email = ismo@ivuorinen.net
[core]
excludesfile = ~/.config/git/gitignore
@@ -51,10 +50,3 @@
deleted = red bold strike
untracked = cyan
branch = yellow black bold ul
[gpg]
format = ssh
[gpg "ssh"]
program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign
allowedSignersFile = ~/.ssh/allowed_signers
[commit]
gpgsign = true

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env bash
#
# Dotfiles and install helper
#
# Helper variables, override with ENVs like `VERBOSE=1 helpers.sh help`
: ${VERBOSE:=0}
: ${CP:=/bin/cp}
: ${LN:=/bin/ln}
: ${MKDIR:=/bin/mkdir}
: ${RM:=/bin/rm}
: ${DIRNAME:=/usr/bin/dirname}
case "$1" in
install)
echo "install stuff"
case "$2" in
*)
echo "-> $0 install [brew]"
esac
;;
brew)
echo "brew commands"
;;
dotfiles)
echo "dotfiles manager"
;;
other)
echo "Other commands"
;;
*)
echo $"Usage: $0 [install | brew | dotfiles | other]"
echo $" All commands have their own subcommands."
echo $" When in doubt run the subcommand to show list."
echo ""
exit 1
;;
esac

0
host-air/.gitkeep Normal file
View File

3
host-air/README.md Normal file
View File

@@ -0,0 +1,3 @@
# .dotfiles/host-air
This is my home computer.

0
host-v/.gitkeep Normal file
View File

3
host-v/README.md Normal file
View File

@@ -0,0 +1,3 @@
# .dotfiles/host-v
This is my work computer.

60
host-v/config/git/config Normal file
View File

@@ -0,0 +1,60 @@
[user]
name = Ismo Vuorinen
email = ismo.vuorinen@vincit.fi
signingkey = ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDLyOvkr1nRqMVv3UAizmk6C+q40H4khvw7qIXXXyOyFmzjwYx/Cuxoi4uZVjX+q4qFYJ+c312uu6YXiEtfyoCao3wub8r1cLBQ3eIvuyWp2K8Ixcd9JmFmLmoeiENpJxqyr0WPZLDkrCWUZCsQQh8zzGFnfciUdUdTiZ7s21AEhhmFRSdFlVfQSlGMFxU321psg1YilcP80bDwFd1FsL4TssSkwlbgP/twqnpZ4436TTo7kp0UnH/RZkfRdDWScKHaWgncBG0CZeQxGWnRp8fvZn/7gDnthcZhvnDALVBE7QFuZ90GxqVw3IGpHryV0mFO6EGQ9Ke9YX7pKVZPUXZjeCN4SVKsqFdVJ6AjaSJ9K7nL98rYK7qNzndT3cKqPNgPteyXWRulH68A51ecQqHrjTttZcdN9hKt9uBHpzuXsby2QObT+VB4MNjZapa+YYF/WgwJCml4lzn2xMFg1vYZD78pfoJ9e5f2cL1MMlUSDb0TNxmEXfDQ77H/pRpKDz0=
[core]
excludesfile = ~/.config/git/gitignore
[alias]
reset-origin = !git fetch origin && git reset --hard origin/master && git clean -f -d
reset-upstream = !git fetch upstream && git reset --hard upstream/master && git clean -f -d
nah = !git reset --hard && git clean -df
undo-commit = reset HEAD~ --soft
llog = log --pretty=fuller
logs = log --graph --pretty=format:'%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) %C(cyan)<%an>%Creset' --abbrev-commit
rl = reflog --format='%C(auto)%h %<|(20)%gd %C(blue)%cr%C(reset) %gs (%s)'
tagdate = log --date-order --graph --tags --simplify-by-decoration --pretty=format:\"%ai %h %d\"
branchbydate = for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)'
branchcolor = "!for ref in $(git for-each-ref --sort=-committerdate --format=\"%(refname)\" refs/heads/ refs/remotes ); do git log -n1 $ref --pretty=format:\"%Cgreen%cr%Creset %C(yellow)%d%Creset %C(bold blue)<%an>%Creset%n\" | cat ; done | awk '! a[$0]++'"
[diff]
tool = difftastic
[difftool]
prompt = false
[difftool "difftastic"]
cmd = difft "$LOCAL" "$REMOTE"
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[init]
defaultBranch = master
[pull]
rebase = false
[color]
ui = true
diff = auto
branch = auto
status = auto
[color "status"]
added = green bold
changed = yellow
deleted = red bold strike
untracked = cyan
branch = yellow black bold ul
[gpg]
format = ssh
[gpg "ssh"]
program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign
allowedSignersFile = ~/.ssh/allowed_signers
[commit]
gpgsign = true

View File

@@ -73,6 +73,7 @@ handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/gitignore" "/Users/ivuorin
handle_file_ln "/Users/ivuorinen/.dotfiles/config/wtf/config.yml" "/Users/ivuorinen/.config/wtf/config.yml"
handle_file_ln "/Users/ivuorinen/.dotfiles/git_profiles" "/Users/ivuorinen/.git_profiles"
handle_file_ln "/Users/ivuorinen/.dotfiles/huskyrc" "/Users/ivuorinen/.huskyrc"
handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/dotfiles" "/Users/ivuorinen/.local/bin/dotfiles"
handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/x-open-ports" "/Users/ivuorinen/.local/bin/x-open-ports"
handle_file_ln "/Users/ivuorinen/.dotfiles/rcrc" "/Users/ivuorinen/.rcrc"
handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/allowed_signers" "/Users/ivuorinen/.ssh/allowed_signers"

104
local/bin/dotfiles Executable file
View File

@@ -0,0 +1,104 @@
#!/usr/bin/env bash
#
# Dotfiles and install helper
# (c) Ismo Vuorinen <https://github.com/ivuorinen> 2022
# Licensed under MIT, see LICENSE
#
# Helper variables, override with ENVs like `VERBOSE=1 helpers.sh help`
: "${VERBOSE:=0}"
: "${DOTFILES:=$HOME/.dotfiles}"
: "${INSTALL_SCRIPT:=$DOTFILES/install.sh}"
: "${BREWFILE:=$DOTFILES/Brewfile}"
function usage() {
echo $"Usage: $0 [install | brew | dotfiles | other]"
echo $" All commands have their own subcommands."
echo $" When in doubt run the subcommand to show list."
}
function section_install() {
USAGE_PREFIX="Usage: $0 install"
case "$1" in
*)
echo "$USAGE_PREFIX [link | update]"
echo " * link: Use rcrc to update dotfile links"
echo " * update: Updates and upgrades brew packages"
echo " * updatebundle: Updates Brewfile with descriptions"
;;
esac
}
function section_brew() {
USAGE_PREFIX="Usage: $0 brew"
if ! command -v brew &> /dev/null; then
echo "brew could not be found, please install it first"
exit
fi
case "$1" in
install)
brew bundle install --file="$BREWFILE"; echo "🎉 Done!"
;;
update)
brew update && brew upgrade; echo "🎉 Done!"
;;
updatebundle)
# Updates .dotfiles/Brewfile with descriptions
brew bundle dump --force --file="$BREWFILE" --describe
echo "🎉 Done!"
;;
autoupdate)
brew autoupdate start 43200 --upgrade --cleanup --immediate
;;
*)
echo "$USAGE_PREFIX [install | update | updatebundle]"
echo " * install: Installs items defined in Brewfile"
echo " * update: Updates and upgrades brew packages"
echo " * updatebundle: Updates Brewfile with descriptions"
echo " * autoupdate: Setups brew auto-update and runs it immediately"
;;
esac
}
function section_dotfiles() {
USAGE_PREFIX="Usage: $0 dotfiles"
case "$1" in
link)
rcup -B "$HOSTNAME" -v && echo "🎉 Done!"
;;
update)
# Updates .dotfiles/install.sh and formats it
rcup -B 0 -g | \
tee "$INSTALL_SCRIPT" 1> /dev/null && \
shfmt -w -l "$INSTALL_SCRIPT" && \
echo "🎉 Done!"
;;
*)
echo "$USAGE_PREFIX [link | update]"
echo " * link: Use rcrc to update dotfile links"
echo " * update: Updates dotfile links, installs host specific overrides automatically"
;;
esac
}
function section_other() {
case "$1" in
*)
echo "section_other"
echo "$1"
;;
esac
}
# The main loop. first keyword after $0 triggers section, or help.
case "$1" in
install) section_install "$2" ;;
brew) section_brew "$2" ;;
dotfiles) section_dotfiles "$2" ;;
other) section_other "$2" ;;
*) usage; exit 1 ;;
esac

280
macos/set-defaults.sh Executable file
View File

@@ -0,0 +1,280 @@
#!/usr/bin/env bash
echo 'start osx/set-defaults.sh'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
###############################################################################
# General UI/UX #
###############################################################################
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "
# Menu bar: disable transparency
#defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
# Set sidebar icon size to medium
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
# Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Disable Resume system-wide
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
# Disable automatic termination of inactive apps
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
# Disable the crash reporter
#defaults write com.apple.CrashReporter DialogType -string "none"
# Reveal IP address, hostname, OS version, etc. when clicking the clock
# in the login window
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
# Disable smart quotes as theyre annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable smart dashes as theyre annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
###############################################################################
# SSD-specific tweaks #
###############################################################################
# Disable hibernation (speeds up entering sleep mode)
sudo pmset -a hibernatemode 0
# Disable the sudden motion sensor as its not useful for SSDs
sudo pmset -a sms 0
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
###############################################################################
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool Min (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Max" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Min" 80
# Enable full keyboard access for all controls
# (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Set language and text formats
# Note: if youre in the US, replace `EUR` with `USD`, `Centimeters` with
# `Inches`, `en_GB` with `en_US`, and `true` with `false`.
defaults write NSGlobalDomain AppleLanguages -array "en"
defaults write NSGlobalDomain AppleLocale -string "en_GB@currency=EUR"
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
defaults write NSGlobalDomain AppleMetricUnits -bool true
# Set the timezone; see `systemsetup -listtimezones` for other values
systemsetup -settimezone "Europe/Helsinki" > /dev/null
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Stop iTunes from responding to the keyboard media keys
#launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null
###############################################################################
# Screen #
###############################################################################
# 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
###############################################################################
# Finder #
###############################################################################
# Set Desktop as the default location for new Finder windows
# For other paths, use `PfLo` and `file:///full/path/here/`
defaults write com.apple.finder NewWindowTarget -string "PfDe"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
# Show icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
# Finder: show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Finder: allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool true
# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
# Disable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false
# Show the ~/Library folder
# chflags nohidden ~/Library
# Show the ~/Users folder
# chflags nohidden /Users
# Expand the following File Info panes:
# “General”, “Open with”, and “Sharing & Permissions”
defaults write com.apple.finder FXInfoPanesExpanded -dict \
General -bool true \
OpenWith -bool true \
Privileges -bool true
###############################################################################
# Screenshots #
###############################################################################
# Set default screenshot location
#defaults write com.apple.screencapture "location" -string "~/Documents/Screenshots"
# Exclude date and time in screenshot filenames
defaults write com.apple.screencapture "include-date" -bool false
# Change the default screenshot file name
defaults write com.apple.screencapture "name" -string "screenshot"
###############################################################################
# Dock, Dashboard, and hot corners #
###############################################################################
# Prevent applications from bouncing in Dock
defaults write com.apple.dock no-bouncing -bool true
# Set the icon size of Dock items to 72 pixels
defaults write com.apple.dock tilesize -int 72
# Hide indicator lights for open applications in the Dock
defaults write com.apple.dock show-process-indicators -bool false
# Wipe all (default) app icons from the Dock
# This is only really useful when setting up a new Mac, or if you dont use
# the Dock to launch apps.
defaults write com.apple.dock persistent-apps -array ""
# Disable Dashboard
defaults write com.apple.dashboard mcx-disabled -bool true
# Dont show Dashboard as a Space
defaults write com.apple.dock dashboard-in-overlay -bool true
# Dont automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
###############################################################################
# Safari & WebKit #
###############################################################################
# Enable Safaris debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Enable the Develop menu and the Web Inspector in Safari
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
# Dont display the annoying prompt when quitting iTerm
#defaults write com.googlecode.iterm2 PromptOnQuit -bool false
# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
###############################################################################
# Activity Monitor #
###############################################################################
# Show the main window when launching Activity Monitor
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true
# Visualize CPU usage in the Activity Monitor Dock icon
defaults write com.apple.ActivityMonitor IconType -int 5
# Show all processes in Activity Monitor
defaults write com.apple.ActivityMonitor ShowCategory -int 0
# Sort Activity Monitor results by CPU usage
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
defaults write com.apple.ActivityMonitor SortDirection -int 0
###############################################################################
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility #
###############################################################################
# Use plain text mode for new TextEdit documents
defaults write com.apple.TextEdit RichText -int 0
# Open and save files as UTF-8 in TextEdit
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
###############################################################################
# Messages #
###############################################################################
# Disable smart quotes as its annoying for messages that contain code
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
# Disable continuous spell checking
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
###############################################################################
# Kill affected applications #
###############################################################################
for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
"Dock" "Finder" "Mail" "Messages" "Safari" "SizeUp" "SystemUIServer" \
"Terminal" "Transmission" "Twitter" "iCal"; do
killall "${app}" > /dev/null 2>&1
done
echo "Done. Note that some of these changes require a logout/restart to take effect."

2
rcrc
View File

@@ -1,2 +1,2 @@
EXCLUDES="README.md install.sh Brewfile.lock.json Brewfile"
EXCLUDES="README.md install.sh Brewfile.lock.json Brewfile set-defaults.sh gh-extensions.sh"
HOSTNAME=$(hostname -s)

1
zshrc
View File

@@ -36,6 +36,7 @@ export NVM_AUTO_USE=true
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
[[ -f "$HOME/.dotfiles/alias" ]] && source "$HOME/.dotfiles/alias"
[[ -f "$HOME/.dotfiles/alias-$HOSTNAME" ]] && source "$HOME/.dotfiles/alias-$HOSTNAME"
# Try to load antigen, if present
[[ -f "$HOME/.config/antigen.zsh" ]] && source "$HOME/.config/antigen.zsh"