Files
dotfiles/zsh/.zshrc
2026-04-02 18:13:43 +03:00

127 lines
3.2 KiB
Bash

## Brew configuration
# used fix for git completions
# https://stackoverflow.com/a/77774933
# Init Homebrew to get `HOMEBREW_PREFIX`
eval "$(/opt/homebrew/bin/brew shellenv)"
# Delete brew's objectively worse git completion
remove_conflicting_git_completions() {
local git_completion_bash="$HOMEBREW_PREFIX/share/zsh/site-functions/git-completion.bash"
local git_completion_zsh="$HOMEBREW_PREFIX/share/zsh/site-functions/_git"
[ -e "$git_completion_bash" ] && rm "$git_completion_bash"
[ -e "$git_completion_zsh" ] && rm "$git_completion_zsh"
}
# This needs to run every time since brew sometimes brings those files back
remove_conflicting_git_completions
# Add Homebrew's site functions to fpath (minus git, because that causes conflicts)
# This will give you autocomplete for _other_ things you installed
# from brew (like `just`, or `exa`, or `k6`)
fpath=($HOMEBREW_PREFIX/share/zsh/site-functions $fpath)
# Path to your oh-my-zsh installation.
export ZSH="/Users/liquidpredator/.oh-my-zsh"
# Set name of the theme to load
#ZSH_THEME="dracula"
#Plugin configurations
zstyle ':omz:plugins:eza' 'dirs-first' yes
zstyle ':omz:plugins:eza' 'icons' yes
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
aws
docker
eza
fancy-ctrl-z
fzf
gcloud
gitfast
gitignore
helm
k9s
kubectl
mise
starship
terraform
thefuck
zoxide
zsh-autosuggestions
)
# Run oh-my-zsh
source $ZSH/oh-my-zsh.sh
## User configuration
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
# YandexCloud CLI completion
# NOTE: Versions checked from utility version output
source "$HOMEBREW_PREFIX/Caskroom/yandex-cloud-cli/$(yc --version | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")/yandex-cloud-cli/completion.zsh.inc"
#compdef opencode
###-begin-opencode-completions-###
#
# yargs command completion script
#
# Installation: opencode completion >> ~/.zshrc
# or opencode completion >> ~/.zprofile on OSX.
#
_opencode_yargs_completions()
{
local reply
local si=$IFS
IFS=$'
' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" opencode --get-yargs-completions "${words[@]}"))
IFS=$si
if [[ ${#reply} -gt 0 ]]; then
_describe 'values' reply
else
_default
fi
}
if [[ "'${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
_opencode_yargs_completions "$@"
else
compdef _opencode_yargs_completions opencode
fi
###-end-opencode-completions-###
# Add Docker Desktop for Mac (docker)
export PATH="$PATH:/Applications/Docker.app/Contents/Resources/bin/"
## Functions
#Generate strong password
function pwg() {
pwgen -cny -r \[\]\{\}\(\)\"\'\-\|\:\;\`\,\<\>\$\= 32 1
}
# Yazi
function y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
#DuckDuckGo Search with w3m
function ddgs(){
w3m https://lite.duckduckgo.com/html/\?q\="$@"
}