diff --git a/MacOS/homeConfigs/.zshrc b/MacOS/homeConfigs/.zshrc index 558b3c6f..e1c8cf6e 100644 --- a/MacOS/homeConfigs/.zshrc +++ b/MacOS/homeConfigs/.zshrc @@ -8,6 +8,59 @@ fi # Open VSCode from the terminal code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;} +# Shortcuts for brew and macOS update +p () { + if ! command -v brew &> /dev/null; then + echo "Brew not found. Installing..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') > ~/.zprofile + eval "$(/opt/homebrew/bin/brew shellenv)" + fi + + case $1 in + install|i) + shift + brew install $* + ;; + remove|uninstall|delete|r|d) + shift + brew uninstall $* + ;; + update|u) + brew update + ;; + list|l) + brew list + ;; + macOSupdate|m) + echo "Updating MacOS..." + echo "THE DEVICE WILL RESTART IF NECESSARY." + sudo softwareupdate -iaR + ;; + *) + echo "Usage: p {install(i)|remove(r/d)|update(u)|list(l)|macOSupdate(m)} " + ;; + esac +} + +# Shortcuts to extract files +extract () { + if [[ -z $* ]]; then + echo "No files provided for extraction." + return 1 + fi + + for file in "$@"; do + case "${file##*.}" in + (zip) unzip "$file" ;; + (tar.gz|tgz|gzip) tar -xzf "$file" ;; + (tar.bz2|tbz2) tar -xf "$file" ;; + (bz2) bunzip2 "$file" ;; + (*) echo "Unsupported file format: $file" ;; + esac + done +} + export ZSH="$HOME/.oh-my-zsh" ZSH_THEME="powerlevel10k/powerlevel10k" zstyle ':omz:update' mode auto # update automatically without asking @@ -39,10 +92,6 @@ if [[ -n $SSH_CONNECTION ]]; then # Compilation flags # export ARCHFLAGS="-arch x86_64" -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. # # Example aliases # alias zshconfig="mate ~/.zshrc" diff --git a/MacOS/scripts/moveAppsToBrew.sh b/MacOS/scripts/moveAppsToBrew.sh new file mode 100755 index 00000000..af5408aa --- /dev/null +++ b/MacOS/scripts/moveAppsToBrew.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# List all installed apps +all_apps=(/Applications/*) + +# Loop through each app +for app in "${all_apps[@]}"; do + # Extract the app name without the extension (if any) + app_name="${app##*/}" + app_name="${app_name%.*}" # Removes everything after the last dot + + # Check if the app name exists in a brew cask + brew search $app_name &> /dev/null + if [ $? -eq 0 ]; then + echo "Found $app_name in Homebrew. Installing..." + brew install --cask --force "$app_name" + else + echo "$app_name not found in Homebrew." + fi +done + +echo "All checks completed."