Files
dotfiles/MacOS/homeConfigs/.zshrc
TrudeEH 0c315770c5 Add brew shortcuts to .zshrc
A simple port of the "p" package manager, using brew, for macOS.
2024-03-09 15:23:46 +00:00

102 lines
2.9 KiB
Bash

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
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)} <package>"
;;
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
zstyle ':omz:update' frequency 7
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
plugins=(git)
source $ZSH/oh-my-zsh.sh
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='zed'
else
export EDITOR='zed'
fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh