113 lines
3.2 KiB
Bash
113 lines
3.2 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|r|)
|
|
shift
|
|
brew uninstall $*
|
|
;;
|
|
update|u)
|
|
brew update
|
|
brew upgrade
|
|
brew autoremove
|
|
brew cleanup
|
|
;;
|
|
list|l)
|
|
brew list
|
|
;;
|
|
bundle|b)
|
|
brew bundle --file $2
|
|
;;
|
|
macOSupdate|m)
|
|
echo "Updating MacOS..."
|
|
echo "THE DEVICE WILL RESTART IF NECESSARY."
|
|
sudo softwareupdate -iaR
|
|
;;
|
|
*)
|
|
echo "Usage: p {(i)nstall|(r)emove|(u)pdate|(l)ist|(b)undle|(m)acOSupdate} <package>"
|
|
;;
|
|
esac
|
|
|
|
# Generate a new bundle in the dotfiles.
|
|
echo "Updating bundle in $HOME/dotfiles..."
|
|
rm -f $HOME/dotfiles/BrewFile
|
|
brew bundle dump --describe --file=$HOME/dotfiles/BrewFile
|
|
}
|
|
|
|
# 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
|