dotfiles/.zshrc

230 lines
6 KiB
Bash

# bindkey -r '^S'
bindkey -r '\ex'
ZSH="$HOME/.oh-my-zsh"
export DISABLE_LS_COLORS=true
# export W3M_DIR="$HOME/.cache/w3m"
# export PAGER=ov
# export MANPAGER="ov --section-delimiter '^[^\s]' --section-header"
export EGET_BIN="/home/fic/.eget/bin"
# plugins=(ssh-agent git github zsh-autosuggestions zsh-syntax-highlighting aliases copybuffer copyfile copypath fancy-ctrl-z systemd )
plugins=(ssh-agent git github zsh-autosuggestions zsh-syntax-highlighting aliases colored-man-pages copybuffer copyfile copypath fancy-ctrl-z systemd)
source ~/.profile
source $ZSH/oh-my-zsh.sh
ASHEN="$HOME/dev/ashen/monorepo"
source $ASHEN/fzf/ashen.sh
unset LS_COLORS
if whence -w helix &>/dev/null; then
# Stable
HELIX="hx"
export EDITOR="hx"
alias helix="hx"
# alias hx="helix"
else
# Latest
HELIX="hx"
alias helix="hx"
export EDITOR="hx"
fi
# Note: if I do get Obsidian Bridge working, this is
# a really bad way to load the env because
# it slows down shell initialization significantly.
# Would be better to find a way to have the plugin
# call this script dynamically instead!
# source ~/scripts/obsidian-bridge.sh
# autoload -U promptinit; promptinit
# prompt purer
autoload -U edit-command-line
zle -N edit-command-line
bindkey "^e" edit-command-line
bindkey "^h" beginning-of-line
bindkey "^l" end-of-line
bindkey "^b" backward-word
bindkey "^d" backward-kill-word
bindkey "^w" forward-word
function pet-select() {
BUFFER=$(pet search --query "$LBUFFER")
CURSOR=$#BUFFER
zle redisplay
}
zle -N pet-select
stty -ixon
bindkey '^s' pet-select
fpath+=~/.zsh/completions
autoload -Uz compinit
compinit
# Set up fzf key bindings and fuzzy completion
source ~/.config/zsh/fzf.zsh
# Not working for some reason...
# source ~/.config/zsh/fzf-git.sh
alias xcheck="env DISPLAY=:0 xlsclients"
alias mailconf="y ~/.config/mail"
alias rm=gomi
# alias ls="eza -lh --git"
# alias ls="eza --long --color=always --git --header --icons --no-user"
# alias vlc="env -u DISPLAY vlc"
alias ts="tree-sitter"
alias c="clear"
alias top=btop
alias minvim='NVIM_APPNAME="nvim-min" nvim'
alias vimclean='nvim --clean'
alias catkeys='/bin/cat -v'
alias e="$EDITOR"
alias edit="$EDITOR"
alias h="$HELIX"
# alias v='nvim'
# alias vim='nvim'
# alias vi='nvim'
alias vm='nvim --clean'
alias mktdir='cd $(mktemp -d)'
# alias n='nvim'
alias lg=lazygit
alias ylg="yadm enter lazygit"
# tmux aliases
# alias tmuxclean="tmux -L test -f /dev/null"
# alias tm="tmux"
# alias ta="tmux attach-session"
# alias tat="tmux attach-session -t"
# alias tka="tmux kill-session -a"
# alias tkt="tmux kill-session -t"
# alias tl="tmux list-sessions"
# alias tn="tmux new-session"
# alias tnt="tmux new-session -t"
# alias zj=zellij
# alias yeet="yay -Rns"
alias svenv="source .venv/bin/activate"
alias szsh="source ~/.zshrc"
alias ezsh="$EDITOR ~/.zshrc"
alias vzsh="vim ~/.zshrc"
alias vtmux="vim ~/.config/tmux/tmux.conf"
alias icat=chafa
# alias icat="kitty +kitten icat"
alias iecho="xclip -selection clipboard -t image/png -o >"
alias vn=viewnior
alias mermaid=mmdc
alias dnd=dragon-drop
# alias cat=bat
alias autoyadm="AUTOYADMPUSH=1 ~/dev/autoyadm/autoyadm.sh"
alias yadmadd="~/dev/autoyadm/yadmadd.sh"
# Created by `pipx` on 2024-09-20 02:14:00
export PATH="$PATH:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/go/bin"
export PATH="$PATH:/home/fic/.eget/bin"
export PATH="$PATH:/home/fic/.local/share/bob/nvim-bin"
export PATH="$PATH:/home/fic/.luarocks/bin"
export PATH="$PATH:/home/fic/.local/share/npm/bin"
fpath=(~/.zsh/functions $fpath)
autoload -Uz syncthing_menu
autoload -Uz ren
# fpath=(~/.zsh.d/ $fpath)
function noh() {
nohup "$@" >/dev/null 2>&1 &
}
function ls() {
eza --long --color=always --git --header --icons "$@"
}
function copyl() {
wl-copy -t 'text/uri-list' <<<"file://$PWD/$@"
}
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"
}
function cat() {
bat "$@"
}
# . /opt/asdf-vm/asdf.sh
# Need this to fix the cursor in tmux
print -n '\033[6 q'
function zle-keymap-select zle-line-init zle-line-finish
{
case $KEYMAP in
vicmd) print -n '\033[1 q' ;; # block cursor
viins | main) print -n '\033[6 q' ;; # line cursor
esac
}
# DISABLE_AUTO_TITLE="true"
# function set_win_title() {
# echo -ne "\033]0; ${PWD/#$HOME/~} \007"
# }
# function viewport_osc() {
# print -Pn "\e]133;A\e\\"
# }
function mksh() {
local filepath="$1.sh"
if [[ ! -f "$filepath" && "$1" != "" ]]; then
echo '#!/bin/env bash\n\necho "Hello, World!"' >>"$filepath"
/usr/bin/chmod +x "$filepath"
echo "$filepath created."
else
if [[ "$filepath" == ".sh" ]]; then
echo "You must supply an argument!"
else
echo "$filepath already exists"
fi
fi
}
function osc7-pwd() {
emulate -L zsh # also sets localoptions for us
setopt extendedglob
local LC_ALL=C
printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}}
}
function chpwd-osc7-pwd() {
(( ZSH_SUBSHELL )) || osc7-pwd
}
add-zsh-hook -Uz chpwd chpwd-osc7-pwd
function preexec {
# needed for foot prompt integration
print -n "\e]133;C\e\\"
printf '\e[2 q' # block cursor before running a command
}
precmd() {
printf '\e[6 q' # beam cursor before showing the prompt again
# needed for foot prompt integration
print -Pn "\e]133;A\e\\"
if ! builtin zle; then
print -n "\e]133;D\e\\"
fi
}
# precmd_functions+=(set_win_title viewport_osc)
# precmd_functions+=(viewport_osc)
# zle -N zle-line-init
# zle -N zle-line-finish
# zle -N zle-keymap-select
eval $(thefuck --alias)
eval "$(starship init zsh)"
eval "$(zoxide init zsh)"
eval "$(rip completions zsh)"
# export DIRENV_LOG_FORMAT=""
# export GPG_TTY=$(tty)
# gpg-connect-agent updatestartuptty /bye >/dev/null
# export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
# gpg-connect-agent /bye > /dev/null
eval "$(direnv hook zsh)"
# colorscript -e 36
# source ~/scripts/obsidian-bridge.sh
PET_GITHUB_ACCESS_TOKEN=$(pass show github/gist)
export PET_GITHUB_ACCESS_TOKEN
source <(cdhist -i)