Skip to content

Commit

Permalink
several improvements (#38)
Browse files Browse the repository at this point in the history
- add apps: Linear, Rocket, Dropover, PastePal
- add apps to dock: Linear, Slack, Cursor
- add functions: weather, jc (cursor jump and open)
- remove outdated parts in readme
- clean up: install.sh, local.sh
- change emoji for nodejs in starship
- change default GOPATH
- use custom aws.cfg for mackup to not include cache data
- don't upgrade apps by default in mas because of false positives
- add another vault to SSH config for 1Password
- use autoSetupRemote in gitconfig
- add ssorefresh alias

## Summary by Sourcery

Add new applications and functions, update dock configuration, and clean
up scripts. Modify Starship and Mackup configurations, and update SSH
and git settings. Remove outdated documentation.

New Features:
- Add new applications: Linear, Rocket, Dropover, and PastePal.
- Introduce new functions: weather and jc (cursor jump and open).

Enhancements:
- Add Linear, Slack, and Cursor applications to the dock.
- Change the emoji for Node.js in the Starship configuration.
- Use a custom aws.cfg for Mackup to exclude cache data.
- Add another vault to SSH config for 1Password.
- Enable autoSetupRemote in gitconfig.

Documentation:
- Remove outdated sections from the README.

Chores:
- Clean up install.sh and local.sh scripts.
  • Loading branch information
martimlobao authored Oct 26, 2024
1 parent 8fcb211 commit a94d730
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 65 deletions.
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Here's a short description of each script in this repository:
- `local.sh` _interactively_ configure local settings unique to each machine, like the computer name and your git user details
- `macos.sh` configure several macOS settings
- `brew.sh` install command-line tools using Homebrew
- `python.sh` configure python environment
- `apps.sh` install fonts and macOS apps using Homebrew and Mac App Store
- `dock.sh` configure macOS dock
- `bootstrap.sh` install dotfiles for bash settings and command line layout
Expand Down Expand Up @@ -68,26 +67,6 @@ Most of these scripts rely on [Homebrew](https://brew.sh/), which is installed w
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

### Private dotfiles

In addition to this public repository, I also have a private repository where I store other settings that I don't want to be publicly viewable, like my [iStat Menus](https://bjango.com/mac/istatmenus/) license or my [Atom](https://atom.io/) preferences. At the end of the `setup.sh` script, this private repository is cloned and a `run.sh` script is called to install these settings.

Of course, nothing else will be installed for you since you don't have access to this repository, but you can create your own private settings repository and add it to `setup.sh` if you wish.

### Add custom commands

If you want to add a few extra commands without creating your own fork or an additional private repository, you can add these to `.extra`. Since this file is in the `.gitignore`, any changes will remain local to your machine and will not be committed to a public repository.

If `.extra` exists, it is sourced in `.bash_profile` after all other dotfiles, so it can also be used to override settings or functions.

All settings that I do not want to sync are either generated using `local.sh` or stored in my private dotfiles repository, so I don't have anything in my `.extra` file. However, an example `.extra` could look something like this:

```bash
# Export Github token and gist ID for Atom sync-settings https://atom.io/packages/sync-settings
export GITHUB_TOKEN=6a10cc207b88888888888888888888887a67e871
export GIST_ID=b302588888888888888888888888c41c
```

## Contributing

[Pull requests](https://github.com/martimlobao/dotfiles/pulls) are welcome. For non-minor changes, consider [opening an issue](https://github.com/martimlobao/dotfiles/issues) first to discuss what you would like to change.
Expand Down
4 changes: 4 additions & 0 deletions apps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ spotify = "cask" # Music streaming service

[productivity]
chatgpt = "cask" # OpenAI's official ChatGPT desktop app
linear-linear = "cask" # App to manage software development and track bugs
notion = "cask" # App to write, plan, collaborate, and get organised
obsidian = "cask" # Knowledge base that works on top of a local folder of plain text Markdown files
slack = "cask" # Team communication and collaboration software
Expand All @@ -71,9 +72,12 @@ google-drive = "cask" # Client for the Google Drive storage service
iina = "cask" # Free and open-source media player [modern vlc alternative]
istat-menus = "cask" # System monitoring app
notunes = "cask" # Simple application that will prevent iTunes or Apple Music from launching
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
Expand Down
3 changes: 3 additions & 0 deletions dock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ clear_dock
add_app_to_dock "Arc"
add_app_to_dock "Obsidian"
add_app_to_dock "Todoist"
add_app_to_dock "Linear"
add_app_to_dock "Slack"
add_app_to_dock "Visual Studio Code"
add_app_to_dock "Cursor"
add_app_to_dock "Warp"
add_app_to_dock "System Settings"
add_folder_to_dock ~/Downloads --sortby 2 --displayas 1 --viewcontentas 1
Expand Down
30 changes: 17 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ brew_sync() {
local missing_apps=$(echo -e "$missing_formulae\n$missing_casks" | sort -u)

if [[ -n "$missing_apps" ]]; then
echo -e "\n❗️ \033[1;31mThe following Homebrew-installed formulae and casks are missing from apps.toml:\033[0m"
echo -e "❗️ \033[1;31mThe following Homebrew-installed formulae and casks are missing from apps.toml:\033[0m"
echo "$missing_formulae" | sed 's/^/ /'
echo "$missing_casks" | sed 's/^/ /'
read -rp $'\e[1;31mDo you want to uninstall these apps? (y/n) \e[0m ' choice
if [[ "$choice" == "y" ]]; then
for app in $missing_apps; do
brew uninstall "$app"
echo -e "\n🚮 \033[1;35mUninstalled $app.\033[0m"
echo -e "🚮 \033[1;35mUninstalled $app.\033[0m"
done
else
echo -e "\n🆗 \033[1;35mNo apps were uninstalled.\033[0m"
echo -e "🆗 \033[1;35mNo apps were uninstalled.\033[0m"
fi
else
echo -e "\n✅ \033[1;32mAll Homebrew-installed formulae and casks are present in apps.toml.\033[0m"
echo -e "✅ \033[1;32mAll Homebrew-installed formulae and casks are present in apps.toml.\033[0m"
fi
}

Expand All @@ -124,19 +124,19 @@ uv_sync() {
local missing_uv_apps=$(comm -23 <(uv tool list | awk '{print $1}' | grep -v '^-*$' | sort) <(echo "$toml_apps" | sort))

if [[ -n "$missing_uv_apps" ]]; then
echo -e "\n❗️ \033[1;31mThe following uv-installed apps are missing from apps.toml:\033[0m"
echo -e "❗️ \033[1;31mThe following uv-installed apps are missing from apps.toml:\033[0m"
echo "$missing_uv_apps" | sed 's/^/ /'
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"
echo -e "\n🚮 \033[1;35mUninstalled $app.\033[0m"
echo -e "🚮 \033[1;35mUninstalled $app.\033[0m"
done
else
echo -e "\n🆗 \033[1;35mNo apps were uninstalled.\033[0m"
echo -e "🆗 \033[1;35mNo apps were uninstalled.\033[0m"
fi
else
echo -e "\n✅ \033[1;32mAll uv-installed apps are present in apps.toml.\033[0m"
echo -e "✅ \033[1;32mAll uv-installed apps are present in apps.toml.\033[0m"
fi
}

Expand All @@ -155,7 +155,7 @@ mas_sync() {
done <<< "$installed_mas_apps"

if [[ ${#missing_mas_apps[@]} -gt 0 ]]; then
echo -e "\n❗️ \033[1;31mThe following Mac App Store apps are missing from apps.toml:\033[0m"
echo -e "❗️ \033[1;31mThe following Mac App Store apps are missing from apps.toml:\033[0m"
for id in "${!missing_mas_apps[@]}"; do
echo -e " ${missing_mas_apps[$id]} ($id)"
done
Expand All @@ -167,14 +167,14 @@ mas_sync() {
if ! mas uninstall "$id"; then
echo -e "❌ \033[1;31mFailed to uninstall $name ($id). Please uninstall it manually.\033[0m"
else
echo -e "\n🚮 \033[1;35mUninstalled $name ($id).\033[0m"
echo -e "🚮 \033[1;35mUninstalled $name ($id).\033[0m"
fi
done
else
echo -e "\n🆗 \033[1;35mNo apps were uninstalled.\033[0m"
echo -e "🆗 \033[1;35mNo apps were uninstalled.\033[0m"
fi
else
echo -e "\n✅ \033[1;32mAll Mac App Store apps are present in apps.toml.\033[0m"
echo -e "✅ \033[1;32mAll Mac App Store apps are present in apps.toml.\033[0m"
fi
}

Expand All @@ -200,6 +200,7 @@ echo "$parsed_toml" | while IFS=$'\t' read -r category app method; do
install "$app" "$method"
done

echo -e "\n🔄 \033[1;35mSyncing installed apps to apps.toml...\033[0m"
brew_sync
uv_sync
mas_sync
Expand All @@ -209,7 +210,10 @@ echo -e "\n🔼 \033[1;35mUpdating existing apps and packages...\033[0m"
brew update
brew upgrade
uv tool upgrade --all
mas upgrade
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

# Remove outdated versions from the cellar
brew cleanup
36 changes: 5 additions & 31 deletions local.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
#!/usr/bin/env bash

# Bash traceback (from https://gist.github.com/Asher256/4c68119705ffa11adb7446f297a7beae)
set -o errexit # stop the script each time a command fails
set -o nounset # stop if you attempt to use an undef variable

function bash_traceback() {
local lasterr="$?"
set +o xtrace
local code="-1"
local bash_command=${BASH_COMMAND}
echo "Error in ${BASH_SOURCE[1]}:${BASH_LINENO[0]} ('$bash_command' exited with status $lasterr)" >&2
if [ ${#FUNCNAME[@]} -gt 2 ]; then
# Print out the stack trace described by $function_stack
echo "Traceback of ${BASH_SOURCE[1]} (most recent call last):" >&2
for ((i=0; i < ${#FUNCNAME[@]} - 1; i++)); do
local funcname="${FUNCNAME[$i]}"
[ "$i" -eq "0" ] && funcname=$bash_command
echo -e " ${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]}\\t$funcname" >&2
done
fi
echo "Exiting with status ${code}" >&2
exit "${code}"
}

# provide an error handler whenever a command exits nonzero
trap 'bash_traceback' ERR

# propagate ERR trap handler functions, expansions and subshells
set -o errtrace
# Source the bash_traceback.sh file
source "$(dirname "$0")/bash_traceback.sh"

# Ask for the administrator password upfront and keep alive until script has finished
echo -e "🦸 \033[1;34mRequesting admin permissions...\033[0m"
Expand Down Expand Up @@ -62,10 +36,10 @@ fi
echo -e "📝 \033[1;34mSetting up .gitconfig.private...\033[0m"
USERNAME=$(op user get --me | grep 'Name:' | sed 's/Name: *//')
if [ -n "$USERNAME" ]; then
git config --file=$HOME/.gitconfig.private user.name "$USERNAME"
git config --file=$HOME/.gitconfig.private user.name "$USERNAME"
else
echo "Error: User name is empty."
exit 1
echo "Error: User name is empty."
exit 1
fi
git config --file=$HOME/.gitconfig.private user.email "$(op read "op://Private/Github/email")"
git config --file=$HOME/.gitconfig.private user.signingKey "$(op read "op://Private/Github SSH Commit Signing Key/public key")"
Expand Down
3 changes: 3 additions & 0 deletions mackup/.aliases
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ alias pumpitup="osascript -e 'set volume output volume 100'"

# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'

# AWS SSO refresh
alias ssorefresh='unset AWS_ACCESS_KEY_ID && unset AWS_SECRET_ACCESS_KEY && aws-sso exec'
3 changes: 3 additions & 0 deletions mackup/.config/1Password/ssh/agent.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
# https://developer.1password.com/docs/ssh/agent/config
[[ssh-keys]]
vault = "Private"

[[ssh-keys]]
vault = "csk4uyusb2f4cl3klddlw7sx4e"
3 changes: 3 additions & 0 deletions mackup/.config/starship.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ truncate_to_repo = false
[git_branch]
symbol = '🌱 '

[nodejs]
symbol = "☕️"

[username]
style_user = "bold dimmed blue"
show_always = false
Expand Down
3 changes: 3 additions & 0 deletions mackup/.exports
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ export LESS=eFRX;

# Change nnn selection color
export NNN_CONTEXT_COLORS='1234';

# Change go path
export GOPATH="$HOME/.go"
14 changes: 14 additions & 0 deletions mackup/.functions
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ function dataurl () {
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
}

# Weather checker
function weather {
curl -s "wttr.in/${1-lisbon}?format=3"
}

# Cursor jump
function jc {
if [[ -z "$1" || "$1" == "." ]]; then
cursor .;
else
cursor "$(j "$1")";
fi
}

# Create a private github repo on github and copy the current repo to it under the remote 'personal'
function copy-repo-to-personal () {
REPO=$(basename "${PWD##*/}")
Expand Down
1 change: 1 addition & 0 deletions mackup/.gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

[push]
default = current
autoSetupRemote = true

[pull]
default = current
Expand Down
5 changes: 5 additions & 0 deletions mackup/.mackup/aws.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[application]
name = AWS

[configuration_files]
.aws/config

0 comments on commit a94d730

Please sign in to comment.