diff --git a/.gitignore b/.gitignore index aef55f4..a2a1e6e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ !git !alacritty !nvim +!zsh + +# explicity ignore zcoredump +zsh/.zcomp* diff --git a/zsh/.zprofile b/zsh/.zprofile new file mode 100644 index 0000000..9debef3 --- /dev/null +++ b/zsh/.zprofile @@ -0,0 +1 @@ +export PATH="/usr/local/bin:/opt/homebrew/bin:$Home/neovim/bin:${PATH}" diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..f2646ff --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,89 @@ +# default configuration as per https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_STATE_HOME="$HOME/.local/state" + +# 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 + +# zsh history file +export HISTFILE="$XDG_STATE_HOME/zsh/history" + +# Path to your oh-my-zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +# Set name of the theme to load +ZSH_THEME="powerlevel10k/powerlevel10k" + +# just remind me to update when it's time +zstyle ':omz:update' mode reminder +zstyle ':omz:update' frequency 7 + +# pre plugin load +export NVM_COMPLETION=true +export NVM_AUTO_USE=true +# i don't lazy load nvm because neovim doesn't work well with it + +# plugins +plugins=(zsh-nvm git zsh-autosuggestions zsh-syntax-highlighting) + +# TODO: lose oh my zsh at some point + +# oh my zsh +source $ZSH/oh-my-zsh.sh + +# language environment +export LANG=en_US.UTF-8 + +# brew sbin +export PATH="/opt/homebrew/sbin:$PATH" + +# pyenv +export PYENV_ROOT="$HOME/.pyenv" +command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" + +# # nvim +export PATH="$HOME/neovim/bin:$PATH" + +# go +export GOHOME=$HOME/go +export PATH=$PATH:$GOHOME/bin + +# ggman +export GGROOT=/Users/janezicmatej/Desktop/git +eval "$(ggman shellrc)" + +# gpg +export GPG_TTY=$(tty) + +# deno +export DENO_INSTALL="/Users/janezicmatej/.deno" +export PATH="$DENO_INSTALL/bin:$PATH" + +# dvm +export DVM_DIR="/Users/janezicmatej/.dvm" +export PATH="$DVM_DIR/bin:$PATH" + +# editor +export EDITOR=nvim + +# gcloud sdk +source "$(brew --prefix)/share/google-cloud-sdk/path.zsh.inc" +source "$(brew --prefix)/share/google-cloud-sdk/completion.zsh.inc" + +# custom functions and aliases +source "$ZDOTDIR/aliases.zsh" +source "$ZDOTDIR/functions.zsh" + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +# opam configuration +[[ ! -r /Users/janezicmatej/.opam/opam-init/init.zsh ]] || source /Users/janezicmatej/.opam/opam-init/init.zsh > /dev/null 2> /dev/null diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..adf65bc --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,28 @@ +alias n=nvim_ve +alias vim=nvim_ve + +# navigation +alias cdgit="cd $GGROOT" +alias icloud="cd $HOME/Library/Mobile\ Documents/com\~apple\~CloudDocs" +alias temp="cd $HOME/Desktop/temp" + +# apple specific +alias accenton="defaults write -g ApplePressAndHoldEnabled -bool true" +alias accentoff="defaults write -g ApplePressAndHoldEnabled -bool false" + +# docker +alias aafh=./helper + +# git +alias gcan="git commit -v --amend --no-edit" +alias gros="git reset origin/$(git_current_branch) --soft" + +# quick edit .dotfiles +alias zshrc="n $ZDOTDIR/.zshrc && source $ZDOTDIR/.zshrc" +alias addalias="n $ZDOTDIR/aliases.zsh && source $ZDOTDIR/.zshrc" + +# unsorted +alias ci="glab ci list" +alias bm=batman +alias grow="~/.local/bin/cbonsai -liWC -M 15 -t 2 -w 60 -s $(date +%s)" +alias clean_ds_store='find . -name ".DS_Store" -type f -delete -print' diff --git a/zsh/functions.zsh b/zsh/functions.zsh new file mode 100644 index 0000000..3151fea --- /dev/null +++ b/zsh/functions.zsh @@ -0,0 +1,46 @@ + +function nvim_ve { + if [[ -e "$VIRTUAL_ENV" && -f "$VIRTUAL_ENV/bin/activate" ]]; then + source "$VIRTUAL_ENV/bin/activate" + command nvim $@ + deactivate + else + command nvim $@ + fi +} + +alias nvim=nvim_ve + +function ffb { + if ! [[ -f package.json ]]; then + echo "no package.json" + return + fi + + if [[ -f yarn.lock ]]; then + PACKAGE_MANAGER=yarn + else + PACKAGE_MANAGER=npm + fi + + if [[ -n $(grep "react-scripts" package.json) ]]; then + BROWSER=none FORCE_COLOR=true "$PACKAGE_MANAGER" start | cat + fi +} + +function afm { + RES=$(curl -s "https://$1/api/monitoring/requirements") + COUNT=$(echo "$RES" | grep -c $2) + if [[ $COUNT -ge 0 ]]; then + VER=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).version') + # OP=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).requirement?[0][0]') + # echo "$2""$(echo "$OP" | tr -d '"')""$(echo "$VER" | tr -d '"')" + echo "$2""==""$(echo "$VER" | tr -d '"')" + fi +} + + +function nukepip { + pip uninstall $(pip freeze) -y + pip install -r $(pyenv root)/default-packages +}