119 lines
2.5 KiB
Bash
119 lines
2.5 KiB
Bash
# z shell configuration
|
|
|
|
#
|
|
# prompt
|
|
#
|
|
|
|
# set icon
|
|
if [ -e /System ]; then
|
|
OSICON=""
|
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
elif [ -f /etc/os-release ]; then
|
|
. /etc/os-release &> /dev/null
|
|
|
|
if [ "$ID" = "nixos" ]; then
|
|
OSICON=""
|
|
elif [ "$ID" = "debian" ]; then
|
|
OSICON=""
|
|
elif [ "$ID" = "fedora" ]; then
|
|
OSICON=""
|
|
elif [ "$ID" = "arch" ]; then
|
|
OSICON=""
|
|
fi
|
|
else
|
|
OSICON="$"
|
|
fi
|
|
|
|
# set prompt colours
|
|
if [ -f ~/.cache/zsh_colours.sh ]; then
|
|
source ~/.cache/zsh_colours.sh
|
|
else
|
|
PRIMARY_COLOUR="{blue}"
|
|
SECONDARY_COLOUR="{yellow}"
|
|
TEXT_COLOUR="{black}"
|
|
fi
|
|
|
|
PROMPT="%F$PRIMARY_COLOUR%~ %F$SECONDARY_COLOUR$OSICON %k%F$TEXT_COLOUR"
|
|
|
|
bindkey -e
|
|
|
|
# zstyles
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
|
zstyle ':completion:*' menu no
|
|
|
|
#
|
|
# history
|
|
#
|
|
HISTFILE="$HOME/.local/share/zsh_hist"
|
|
HISTSIZE=10000000
|
|
SAVEHIST=$HISTSIZE
|
|
|
|
setopt appendhistory
|
|
setopt sharehistory
|
|
setopt hist_save_no_dups
|
|
setopt hist_ignore_all_dups
|
|
setopt hist_find_no_dups
|
|
setopt hist_ignore_space
|
|
|
|
#
|
|
# shell alias
|
|
#
|
|
alias ls="ls -h --color=auto"
|
|
alias la="ls -ah --color=auto"
|
|
alias ll="ls -ahl --color=auto"
|
|
alias cat="bat"
|
|
alias rm="trash"
|
|
|
|
alias v="nvim"
|
|
alias vi="nvim"
|
|
alias vim="nvim"
|
|
|
|
alias ssh="TERM=xterm-256color ssh" # fix ssh not recognising terminal and remote shell being somewhat broken
|
|
alias tmux="tmux -f $HOME/.config/tmux/tmux.conf" # needed for osx systems for some reason
|
|
|
|
# env vars
|
|
export GOPATH="$HOME/.local/share/go"
|
|
export PATH="$PATH:$GOPATH/bin"
|
|
|
|
export EDITOR="nvim"
|
|
|
|
# plugins
|
|
#
|
|
plugindir="$HOME/.local/share/zsh_plug"
|
|
func plugInstall() {
|
|
# clones a repo and then sources it.
|
|
# first arg is git url, second is source
|
|
# location
|
|
|
|
if [ ! command -v "git" &> /dev/null ]; then
|
|
exit 1
|
|
fi
|
|
|
|
foldername=$(basename $1)
|
|
clonepath="$plugindir/$foldername"
|
|
sourcefile="$clonepath/$2"
|
|
|
|
if command -v git > /dev/null && [ ! -d "$clonepath" ]; then
|
|
git clone $1 "$clonepath" --depth=1
|
|
fi
|
|
|
|
if [ -f "$sourcefile" ]; then
|
|
source "$sourcefile"
|
|
fi
|
|
}
|
|
|
|
plugInstall https://github.com/zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting.zsh
|
|
plugInstall https://github.com/Aloxaf/fzf-tab fzf-tab.zsh
|
|
|
|
# load fzf and zoxide
|
|
eval "$(fzf --zsh)"
|
|
eval "$(zoxide init zsh)"
|
|
|
|
function y() {
|
|
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
|
|
command yazi "$@" --cwd-file="$tmp"
|
|
IFS= read -r -d '' cwd < "$tmp"
|
|
[ -n "$cwd" ] && [ "$cwd" != "$PWD" ] && builtin cd -- "$cwd"
|
|
command rm -f -- "$tmp"
|
|
}
|