From abe3e307ece54ef74e129f5668d77fe363a32115 Mon Sep 17 00:00:00 2001 From: Martim Lobao Date: Sun, 3 Nov 2024 01:49:56 +0000 Subject: [PATCH 1/2] chore: Cleanup and small app updates - uninstall Dropover and PastePal - remove deprecated cowsay - install syntax-highlight - add delete-squashed git alias - enable sudo in starship - script tweaks --- apps.toml | 4 +--- install.sh | 22 +++++++++++++--------- local.sh | 6 +++--- mackup/.config/starship.toml | 4 ++++ mackup/.gitconfig | 3 +++ 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/apps.toml b/apps.toml index 4517bcb..e6e76dc 100644 --- a/apps.toml +++ b/apps.toml @@ -76,8 +76,6 @@ rocket = "cask" # Emoji picker optimised for blind people the-unarchiver = "cask" # Unpacks archive files transmission = "cask" # Open-source BitTorrent client 937984704 = "mas" # Amphetamine: Powerful keep-awake utility -1355679052 = "mas" # Dropover - Easier Drag & Drop: Speed up your workflow -1503446680 = "mas" # Clipboard Manager - PastePal: Copy Paste Keyboard History [utilities] chromedriver = "cask" # Automated testing of webapps for Google Chrome @@ -85,6 +83,7 @@ qlmarkdown = "cask" # Quick Look generator for Markdown files qlstephen = "cask" # Quick Look plugin for plaintext files without an extension qlvideo = "cask" # Thumbnails, static previews, cover art and metadata for video files quicklook-json = "cask" # Quick Look plugin for JSON files +syntax-highlight = "cask" # Quicklook extension for source files webpquicklook = "cask" # Quick Look plugin for webp files [shell-tools] @@ -131,7 +130,6 @@ wget = "formula" # Internet file retriever yq = "formula" # Process YAML, JSON, XML, CSV and properties documents from the CLI yt-dlp = "formula" # Feature-rich command-line audio/video downloader # Fun stuff -cowsay = "formula" # Configurable talking characters in ASCII art lolcat = "formula" # Rainbows and unicorns in your console! # Newer versions of system binaries bash = "formula" # Bourne-Again SHell, a UNIX command interpreter diff --git a/install.sh b/install.sh index fec11d4..2a4c4a4 100755 --- a/install.sh +++ b/install.sh @@ -9,6 +9,11 @@ source "$(dirname "$0")/bash_traceback.sh" echo -e "šŸ“² \033[1;36mInstalling apps and packages...\033[0m" +# Ensure yq is installed to parse the apps.toml file +if ! command -v yq &> /dev/null; then + brew install yq +fi + # Initialize arrays to store installed apps installed_casks=() installed_formulas=() @@ -135,7 +140,7 @@ uv_sync() { echo -e "ā—ļø \033[1;31mThe following uv-installed apps are missing from apps.toml:\033[0m" # shellcheck disable=SC2001 echo "$missing_uv_apps" | sed 's/^/ /' - read -rp $'ā“ \e[1;31mDo you want to uninstall these apps? (y/n \e[0m ' choice + read -rp $'ā“ \e[1;31mDo you want to uninstall these apps? (y/n)\e[0m ' choice if [[ "$choice" == "y" ]]; then for app in $missing_uv_apps; do uv tool uninstall "$app" @@ -189,11 +194,6 @@ mas_sync() { fi } -# Ensure yq is installed -if ! command -v yq &> /dev/null; then - brew install yq -fi - # Populate the arrays with installed apps populate_installed_apps @@ -222,9 +222,13 @@ echo -e "\nšŸ”¼ \033[1;35mUpdating existing apps and packages...\033[0m" brew update brew upgrade uv tool upgrade --all -read -rp $'ā“ \e[1;31mUpdate Mac App Store apps (may be slightly buggy)? (y/n)\e[0m ' choice -if [[ "$choice" == "y" ]]; then - mas upgrade +if mas outdated | grep -q .; then + echo -e "ā—ļø \033[1;31mThe following Mac App Store apps are outdated:\033[0m" + mas outdated + read -rp $'ā“ \e[1;31mUpdate Mac App Store apps (may be slightly buggy)? (y/n)\e[0m ' choice + if [[ "$choice" == "y" ]]; then + mas upgrade + fi fi # Remove outdated versions from the cellar diff --git a/local.sh b/local.sh index 78aacdb..3436f54 100755 --- a/local.sh +++ b/local.sh @@ -54,11 +54,11 @@ fi # iStat Menus if [[ -z "$(defaults read com.bjango.istatmenus license6 2>/dev/null || echo '')" ]]; then echo -e "šŸ“ \033[1;34mRegistering iStat Menus...\033[0m" - defaults write com.bjango.istatmenus _modelid -string "$(sysctl hw.model | sed 's/hw.model: //')" - defaults write com.bjango.istatmenus installDateV6 -int "$(date -v +14d +%s)" - ISTAT_EMAIL=$(op read "op://Private/iStat Menus 6/registered email") ISTAT_KEY=$(op read "op://Private/iStat Menus 6/license key") + + defaults write com.bjango.istatmenus _modelid -string "$(sysctl hw.model | sed 's/hw.model: //')" + defaults write com.bjango.istatmenus installDateV6 -int "$(date -v +14d +%s)" /usr/libexec/PlistBuddy -c "Add :license6 dict" ~/Library/Preferences/com.bjango.istatmenus.plist /usr/libexec/PlistBuddy -c "Add :license6:email string $ISTAT_EMAIL" ~/Library/Preferences/com.bjango.istatmenus.plist /usr/libexec/PlistBuddy -c "Add :license6:serial string $ISTAT_KEY" ~/Library/Preferences/com.bjango.istatmenus.plist diff --git a/mackup/.config/starship.toml b/mackup/.config/starship.toml index 6eb4958..eec4e62 100644 --- a/mackup/.config/starship.toml +++ b/mackup/.config/starship.toml @@ -6,6 +6,7 @@ add_newline = true [directory] truncation_length = 5 +truncation_symbol = "ā€¦/" truncate_to_repo = false [git_branch] @@ -18,6 +19,9 @@ symbol = "ā˜•ļø" style_user = "bold dimmed blue" show_always = false +[sudo] +disabled = false + # Disable these modules, they're noisy [aws] disabled = true diff --git a/mackup/.gitconfig b/mackup/.gitconfig index 437d87e..f5f1044 100644 --- a/mackup/.gitconfig +++ b/mackup/.gitconfig @@ -56,6 +56,9 @@ # Generate a default gitgnore file (e.g. `git ignore ruby c > .gitignore`). # Defaults to Python, macOS, Pants, and Visual Studio Code. ignore = "!gi() { curl -sL https://www.toptal.com/developers/gitignore/api/${@:-macos,visualstudiocode,python,pants} ;}; gi" + # Delete all squashed branches. + # https://github.com/not-an-aardvark/git-delete-squashed#sh + delete-squashed = "!f() { local targetBranch=${1:-main} && git checkout -q $targetBranch && git branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d && git for-each-ref refs/heads/ \"--format=%(refname:short)\" | while read branch; do mergeBase=$(git merge-base $targetBranch $branch) && [[ $(git cherry $targetBranch $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == \"-\"* ]] && git branch -D $branch; done; }; f" [pager] stash = false From 41530bb1e92cbd6cbf1dd5a07d6d99ec3fb3ee51 Mon Sep 17 00:00:00 2001 From: Martim Lobao Date: Sun, 3 Nov 2024 01:56:29 +0000 Subject: [PATCH 2/2] fix workflows --- .github/workflows/lint_pr.yaml | 30 +++++++++--------------------- .github/workflows/validate_pr.yaml | 22 +++++++++++++--------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/.github/workflows/lint_pr.yaml b/.github/workflows/lint_pr.yaml index 6411d5c..3e9e48d 100644 --- a/.github/workflows/lint_pr.yaml +++ b/.github/workflows/lint_pr.yaml @@ -1,35 +1,23 @@ --- name: Lint PR on: # yamllint disable-line rule:truthy - pull_request_target: - types: - - opened - - edited - - synchronize - - reopened - -permissions: - pull-requests: read + pull_request: + branches: [main] jobs: - main: - name: Validate PR title - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} shellcheck: - name: shellcheck + name: Run shellcheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Display shellcheck version - run: shellcheck --version - name: shellcheck - run: shellcheck -x **/*.sh + uses: ludeeus/action-shellcheck@master + env: + SHELLCHECK_OPTS: -x + with: + ignore_names: .zshrc .zprofile yamllint: - name: yamllint + name: Run yamllint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/validate_pr.yaml b/.github/workflows/validate_pr.yaml index 7377eed..1bad9fe 100644 --- a/.github/workflows/validate_pr.yaml +++ b/.github/workflows/validate_pr.yaml @@ -1,17 +1,21 @@ --- name: Validate Pull Request on: # yamllint disable-line rule:truthy - pull_request: - branches: [main] + pull_request_target: + types: + - opened + - edited + - synchronize + - reopened + +permissions: + pull-requests: read jobs: - shellcheck: + main: + name: Validate PR title runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: shellcheck - uses: ludeeus/action-shellcheck@master + - uses: amannn/action-semantic-pull-request@v5 env: - SHELLCHECK_OPTS: -x - with: - ignore_names: .zshrc .zprofile + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}