diff --git a/init_private_resources.sh b/init_private_resources.sh index 8611cde..d841d0e 100755 --- a/init_private_resources.sh +++ b/init_private_resources.sh @@ -1,10 +1,33 @@ #!/bin/bash -CUR_OS=$(uname) - -if ! brew bundle --no-lock --no-upgrade --file=~/.local/share/chezmoi/setup/Brewfile.personal; then - echo "Filed to install packages" +error() { + echo "[ERROR] $1" exit 1 +} + +cur_os=$(uname) + +assets_dir="$HOME/.config/assets" + +# Install packages +if [ "$cur_os" = "Darwin" ]; then + font_dir=~/Library/Fonts/ + brewfile="$HOME/.local/share/chezmoi/setup/Brewfile.personal" + if ! brew bundle --no-lock --no-upgrade --file="$brewfile"; then + error "Filed to install packages" + fi + + source ~/.local/share/chezmoi/setup/macos-setup.sh && all +elif [ "$cur_os" = "Linux" ]; then + font_dir=~/.local/share/fonts/ +fi + +if ! command -v op; then + error "1Password not found" +fi + +if ! op whoami 2>/dev/null; then + error "Your 1Password account is not signed in please signin." fi op read "op://Personal/SSH Github xvzc/public key" >~/.ssh/xvzc.pub && @@ -13,22 +36,15 @@ op read "op://Personal/SSH Github xvzc/public key" >~/.ssh/xvzc.pub && op read "op://Personal/SSH Arch Linux/public key" >~/.ssh/arch.pub && chmod 600 ~/.ssh/arch.pub -ASSETS_DIR="$HOME/.config/assets" -if [ -d "$ASSETS_DIR/.git" ]; then - echo "'$ASSETS_DIR/.git' already exists." - git --git-dir "$ASSETS_DIR/.git" remote set-url origin git@xvzc.github.com:xvzc/assets.git +if [ -d "$assets_dir/.git" ]; then + echo "'$assets_dir/.git' already exists." + git --git-dir "$assets_dir/.git" remote set-url origin git@xvzc.github.com:xvzc/assets.git else - git clone git@xvzc.github.com:xvzc/assets.git $ASSETS_DIR + git clone git@xvzc.github.com:xvzc/assets.git "$assets_dir" fi -# Install fonts -if [ "$CUR_OS" = "Darwin" ]; then - cp ~/.config/assets/fonts/hesalche/ttf/hesalche-Light.ttf ~/Library/Fonts/ - cp ~/.config/assets/fonts/hesalche/ttf/hesalche-Regular.ttf ~/Library/Fonts/ -elif [ "$CUR_OS" = "Linux" ]; then - cp ~/.config/assets/fonts/hesalche/ttf/hesalche-Light.ttf ~/.local/share/fonts/ - cp ~/.config/assets/fonts/hesalche/ttf/hesalche-Regular.ttf ~/.local/share/fonts/ -fi +cp ~/.config/assets/fonts/hesalche/ttf/hesalche-Light.ttf "$font_dir" +cp ~/.config/assets/fonts/hesalche/ttf/hesalche-Regular.ttf "$font_dir" # install cargo curl https://sh.rustup.rs -sSf | sh diff --git a/install.sh b/install.sh index 4df832f..6079712 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,11 @@ #!/bin/bash # vim:ft=sh ts=2 sw=2 +error() { + echo "[ERROR] $1" + exit 1 +} + require-sudo() { if [ -n "$1" ]; then sudo -v --prompt "Administrator privilege required. Please type your local password: " @@ -27,8 +32,7 @@ check-or-install-brew() { fi if [ $? -ne 0 ]; then - echo "Filed to install brew" - exit 1 + error "Failed to install brew" fi } @@ -46,7 +50,7 @@ if type chezmoi >/dev/null 2>&1; then echo "Found chezmoi at $(whereis chezmoi). Skipping install." else echo "chezmoi not found. installing.." - sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin + sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin" export PATH="$HOME/.local/bin:$PATH" fi @@ -55,10 +59,9 @@ chezmoi apply if [ "$machine" == "Mac" ]; then check-or-install-brew - brewfile_path="$HOME/.local/share/chezmoi/setup/Brewfile.essential" - if ! brew bundle --no-lock --no-upgrade --file="$brewfile_path"; then - echo "Filed to install packages" - exit 1 + brewfile="$HOME/.local/share/chezmoi/setup/Brewfile.essential" + if ! brew bundle --no-lock --no-upgrade --file="$brewfile"; then + error "Filed to install packages" fi elif [ "$machine" == "Linux" ]; then echo "Installing Linux packages.." @@ -74,6 +77,5 @@ elif [ "$machine" == "Linux" ]; then # # ################################################################# else - echo "Cannot determine operation system." - exit 1 + error "Cannot determine operating system." fi diff --git a/setup/Brewfile.essential b/setup/Brewfile.essential index 4248720..7ef0d30 100644 --- a/setup/Brewfile.essential +++ b/setup/Brewfile.essential @@ -15,5 +15,6 @@ brew "git" brew "tmux" brew "tmuxinator" brew "tree" +brew "mas" cask "font-jetbrains-mono-nerd-font" cask "wezterm" diff --git a/setup/Brewfile.personal b/setup/Brewfile.personal index 1521224..0b78514 100644 --- a/setup/Brewfile.personal +++ b/setup/Brewfile.personal @@ -13,6 +13,8 @@ brew "ranger" brew "ripgrep" brew "terraform" brew "wakeonlan" +mas "KakaoTalk ", id: 869223134 +mas "Gifski ", id: 1351639930 cask "1password" cask "1password-cli" cask "google-chrome" diff --git a/setup/Default.bttpreset b/setup/Default.bttpreset index 103f18d..cd633b0 100644 --- a/setup/Default.bttpreset +++ b/setup/Default.bttpreset @@ -53,7 +53,7 @@ "BTTTpFourFingerSwipeSensitivity" : 0.40000000000000002, "BSTMoveTreshold" : 2, "BTTHideFomControlStripWhenOpen" : false, - "BTTNumberOfStarts" : 3, + "BTTNumberOfStarts" : 6, "BTTForceNormalClickPressure3F" : 150, "showSiriRemoteTab" : true, "SIRIScrollSpeed" : 1, @@ -159,20 +159,15 @@ "BTTNotchBarNotchMenubarModeHideRightScrollable" : true, "BSTSnapAreaDefaultPictoDistanceFromLeft" : 0.10000000149011612 }, - "BTTPresetUUID" : "33AD11E6-BEF8-4E13-8123-ADAA23FA50B6", + "BTTPresetUUID" : "6464A11A-BEE2-453B-8324-BAFE00C2D339", "BTTPresetContent" : [ - { - "BTTAppBundleIdentifier" : "com.apple.finder", - "BTTAppName" : "Finder", - "BTTAppAutoInvertIcon" : 1, - "BTTTriggers" : [ - - ] - }, { "BTTAppBundleIdentifier" : "BT.G", "BTTAppName" : "Global", "BTTAppAutoInvertIcon" : 1, + "BTTAppSpecificSettings" : { + "BTTDisableGlobalTriggers" : false + }, "BTTTriggers" : [ { "BTTLastUpdatedAt" : 1704437819.182636, @@ -188,7 +183,7 @@ "BTTOrder" : 0, "BTTAdditionalActions" : [ { - "BTTLastUpdatedAt" : 1704437823.9116421, + "BTTLastUpdatedAt" : 1704438634.0507588, "BTTTriggerType" : -1, "BTTTriggerParentUUID" : "90E5B6F5-59E7-41CE-82C5-93E82F39AEAE", "BTTIsPureAction" : true, @@ -203,6 +198,14 @@ ] } ] + }, + { + "BTTAppBundleIdentifier" : "com.apple.finder", + "BTTAppName" : "Finder", + "BTTAppAutoInvertIcon" : 1, + "BTTTriggers" : [ + + ] } ], "BTTPresetSnapAreas" : [ diff --git a/setup/macos-setup.sh b/setup/macos-setup.sh index 77c99c1..e523c85 100644 --- a/setup/macos-setup.sh +++ b/setup/macos-setup.sh @@ -2,71 +2,73 @@ # Reference https://github.com/wookayin/dotfiles/blob/master/etc/macos-setup.sh require-sudo() { - sudo -v --prompt "Administrator privilege required. Please type your local password: " - - # 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 & + sudo -v --prompt "Administrator privilege required. Please type your local password: " + + # 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 & } - _ignore_error() { return 0; } _set_hostname() { - local hostname=$1 - require-sudo - sudo scutil --set ComputerName "$hostname" - sudo scutil --set HostName "$hostname" - sudo scutil --set LocalHostName "$hostname" - sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$hostname" + local hostname=$1 + require-sudo + sudo scutil --set ComputerName "$hostname" + sudo scutil --set HostName "$hostname" + sudo scutil --set LocalHostName "$hostname" + sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$hostname" } - configure_general() { - # Faster key repeat - defaults write NSGlobalDomain InitialKeyRepeat -int 15 - defaults write NSGlobalDomain KeyRepeat -int 1 + # Faster key repeat + defaults write NSGlobalDomain InitialKeyRepeat -int 15 + defaults write NSGlobalDomain KeyRepeat -int 1 - # Always show scrollbars (`WhenScrolling`, `Automatic` and `Always`) - defaults write NSGlobalDomain AppleShowScrollBars -string "Automatic" + # Always show scrollbars (`WhenScrolling`, `Automatic` and `Always`) + defaults write NSGlobalDomain AppleShowScrollBars -string "Automatic" - # Do not use OSX credential store for git - git config --system --unset credential.helper || _ignore_error; + # Do not use OSX credential store for git + git config --system --unset credential.helper || _ignore_error } configure_keyboard() { - # Check out the current keymap with the command below - # ┌──────────────────────────────────────────┐ - # │ defaults read com.apple.symbolichotkeys │ - # └──────────────────────────────────────────┘ + # Check out the current keymap with the command below + # ┌──────────────────────────────────────────┐ + # │ defaults read com.apple.symbolichotkeys │ + # └──────────────────────────────────────────┘ - # F1, F2, etc. behave as standard function keys. - defaults write NSGlobalDomain com.apple.keyboard.fnState -bool true + # F1, F2, etc. behave as standard function keys. + defaults write NSGlobalDomain com.apple.keyboard.fnState -bool true - # Use key repeat instead of the accents menu when holding a key - defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false + # Use key repeat instead of the accents menu when holding a key + defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false - # disable previous input source - defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 60 " + # disable previous input source + defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 60 " enabled " - # disable spotlight - defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 64 " + # disable spotlight + defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 64 " enabled " - # disable spotlight finder search - defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 65 " + # disable spotlight finder search + defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 65 " enabled " - # disable mission control - defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 36 " + # disable mission control + defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 36 " enabled " - # Map next input source to option + space - defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 61 " + # Map next input source to option + space + defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 61 " enabled value @@ -81,8 +83,8 @@ configure_keyboard() { " - # Map Copy picture of selected area to the clipboard to Ctrl + Cmd + s - defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 31 " + # Map Copy picture of selected area to the clipboard to Ctrl + Cmd + s + defaults write com.apple.symbolichotkeys.plist AppleSymbolicHotKeys -dict-add 31 " enabled value @@ -97,78 +99,90 @@ configure_keyboard() { " - # Replace "₩" to "`" in korean keyboard - mkdir -p ~/Library/KeyBindings - echo '{ "₩" = ("insertText:", "`"); }' > ~/Library/KeyBindings/DefaultkeyBinding.dict + # Map caps lock to control + defaults -currentHost write -g com.apple.keyboard.modifiermapping.0-0-0 -array " + + HIDKeyboardModifierMappingDst30064771300 + HIDKeyboardModifierMappingSrc30064771129 + + " + + # Replace "₩" to "`" in korean keyboard + mkdir -p ~/Library/KeyBindings + echo '{ "₩" = ("insertText:", "`"); }' >~/Library/KeyBindings/DefaultkeyBinding.dict } configure_dock() { - # Make dock auto-hide/show instantly (no animation!) - # https://apple.stackexchange.com/questions/33600/how-can-i-make-auto-hide-show-for-the-dock-faster - defaults write com.apple.dock autohide -int 1 - defaults write com.apple.dock autohide-delay -float 0.0 - defaults write com.apple.dock autohide-time-modifier -float 0.4 - defaults write com.apple.dock "orientation" -string "left" - defaults write com.apple.dock "show-recents" -bool "false" - defaults write com.apple.dock "mineffect" -string "scale" - defaults write com.apple.dock "tilesize" -int "36" - - #defaults write com.apple.dock magnification -int 1 - killall Dock + # Make dock auto-hide/show instantly (no animation!) + # https://apple.stackexchange.com/questions/33600/how-can-i-make-auto-hide-show-for-the-dock-faster + defaults write com.apple.dock autohide -int 1 + defaults write com.apple.dock autohide-delay -float 0.0 + defaults write com.apple.dock autohide-time-modifier -float 0.4 + defaults write com.apple.dock "orientation" -string "left" + defaults write com.apple.dock "show-recents" -bool "false" + defaults write com.apple.dock "mineffect" -string "scale" + defaults write com.apple.dock "tilesize" -int "36" + + #defaults write com.apple.dock magnification -int 1 + killall Dock } configure_finder() { - # Finder: show status bar - defaults write com.apple.finder ShowStatusBar -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 + # Finder: show path bar + defaults write com.apple.finder ShowPathbar -bool true - # Always show file extensions - defaults write NSGlobalDomain AppleShowAllExtensions -bool true + # Always show file extensions + defaults write NSGlobalDomain AppleShowAllExtensions -bool true - # Disable the warning when changing a file extension - defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false + # Disable the warning when changing a file extension + defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false - # View style (list) - defaults write com.apple.finder "FXPreferredViewStyle" -string "Nlsv" - # keep folders on top - defaults write com.apple.finder "_FXSortFoldersFirst" -bool "true" - killall Finder + # View style (list) + defaults write com.apple.finder "FXPreferredViewStyle" -string "Nlsv" + # keep folders on top + defaults write com.apple.finder "_FXSortFoldersFirst" -bool "true" + killall Finder } configure_menubar() { - defaults write com.apple.menuextra.clock "DateFormat" -string "\"EEE MMM d HH:mm\"" + defaults write com.apple.menuextra.clock "DateFormat" -string "\"EEE MMM d HH:mm\"" + + # Remove spotlight + defaults -currentHost write com.apple.Spotlight " + MenuItemHidden1 + " } configure_trackpad() { - # Double tap to drag - defaults write com.apple.AppleMultitouchTrackpad "Dragging" -bool "true" + # Double tap to drag + defaults write com.apple.AppleMultitouchTrackpad "Dragging" -bool "true" - # enable three finder swipe - defaults write com.apple.AppleMultitouchTrackpad "TrackpadThreeFingerHorizSwipeGesture" -int 1 + # enable three finder swipe + defaults write com.apple.AppleMultitouchTrackpad "TrackpadThreeFingerHorizSwipeGesture" -int 1 } configure_textedit() { - # disable smartquotes - defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false - defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false - defaults write com.apple.TextEdit "SmartQuotes" -bool "false" - defaults write com.apple.TextEdit "SmartDashes" -bool false + # disable smartquotes + defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false + defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false + defaults write com.apple.TextEdit "SmartQuotes" -bool "false" + defaults write com.apple.TextEdit "SmartDashes" -bool false - killall TextEdit + killall TextEdit } all() { - require-sudo; - configure_general - configure_dock - configure_finder - configure_menubar - configure_trackpad - configure_textedit - configure_keyboard - /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u + require-sudo + configure_general + configure_dock + configure_keyboard + configure_finder + configure_menubar + configure_trackpad + configure_textedit + /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u } -