169 lines
4.6 KiB
Cheetah
169 lines
4.6 KiB
Cheetah
# Remove older command from the history if a duplicate is to be added.
|
|
setopt HIST_IGNORE_ALL_DUPS
|
|
|
|
# Set editor default keymap to emacs (`-e`) or vi (`-v`)
|
|
bindkey -v
|
|
|
|
# Remove path separator from WORDCHARS.
|
|
WORDCHARS=${WORDCHARS//[\/]}
|
|
|
|
# Disable automatic widget re-binding on each precmd. This can be set when
|
|
# zsh-users/zsh-autosuggestions is the last module in your ~/.zimrc.
|
|
ZSH_AUTOSUGGEST_MANUAL_REBIND=1
|
|
|
|
# Set what highlighters will be used.
|
|
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
|
|
|
|
ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
|
|
|
# Download zimfw plugin manager if missing.
|
|
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
|
if (( ${+commands[curl]} )); then
|
|
curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
|
|
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
|
|
else
|
|
mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \
|
|
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
|
|
fi
|
|
fi
|
|
|
|
# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
|
|
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
|
|
source ${ZIM_HOME}/zimfw.zsh init -q
|
|
fi
|
|
|
|
# Initialize modules.
|
|
source ${ZIM_HOME}/init.zsh
|
|
|
|
# zsh-history-substring-search
|
|
zmodload -F zsh/terminfo +p:terminfo
|
|
|
|
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
|
|
for key ('^[[A' '^P' ${terminfo[kcuu1]}) bindkey ${key} history-substring-search-up
|
|
for key ('^[[B' '^N' ${terminfo[kcud1]}) bindkey ${key} history-substring-search-down
|
|
for key ('k') bindkey -M vicmd ${key} history-substring-search-up
|
|
for key ('j') bindkey -M vicmd ${key} history-substring-search-down
|
|
unset key
|
|
|
|
srcs=(
|
|
"/opt/miniforge3/etc/profile.d/conda.sh"
|
|
"/opt/miniforge3/etc/profile.d/mamba.sh"
|
|
"$HOME/.cargo/env"
|
|
"$HOME/.zshklaviyo"
|
|
"$HOME/.zshprivate"
|
|
)
|
|
|
|
for fp in $srcs; do
|
|
if [[ -s "$fp" ]]; then
|
|
source "$fp"
|
|
fi
|
|
done
|
|
|
|
alias devlog="cd ~/projects/personal/devlog && hx logs/$(date '+%Y-%m-%d').gmi && cd -"
|
|
|
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
eval "$(direnv hook zsh)"
|
|
eval "$(jj util completion zsh)"
|
|
# export NVM_DIR="$HOME/.nvm"
|
|
# [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
|
|
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
|
|
|
|
function reldate() {
|
|
date -v "${1}" "+%Y-%m-%d"
|
|
}
|
|
|
|
[ "$TERM" = "xterm-kitty" ] && alias ssh="TERM=xterm ssh"
|
|
|
|
alias strip_jira="sed 's/\[\{0,1\}[a-zA-Z]*-[0-9]*\]\{0,1\}//g'"
|
|
|
|
export FZF_DEFAULT_OPTS=" \
|
|
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
|
|
--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
|
|
--color=marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8 \
|
|
--color=selected-bg:#45475a \
|
|
--color=border:#313244,label:#cdd6f4"
|
|
|
|
task_inbox_count_prompt() {
|
|
local count
|
|
count=$(task +inbox +PENDING count 2>/dev/null)
|
|
if [[ $count -gt 0 ]]; then
|
|
echo "%B%F{yellow}(inbox:$count)%f%b "
|
|
fi
|
|
}
|
|
|
|
select_project() {
|
|
local project_list result query selection project
|
|
|
|
project_list=$(task _unique project | grep -v '^$')
|
|
result=$(echo "$project_list" | fzf --prompt="select project: " --print-query --expect=enter)
|
|
|
|
query=$(echo "$result" | sed -n 1p)
|
|
key=$(echo "$result" | sed -n 2p)
|
|
selection=$(echo "$result" | sed -n 3p)
|
|
|
|
if [ -z "$selection" ]; then
|
|
project="$query"
|
|
else
|
|
project="$selection"
|
|
fi
|
|
|
|
if [ -z "$project" ] || [ "$project" = "enter" ]; then
|
|
return 1
|
|
fi
|
|
|
|
echo "$project"
|
|
}
|
|
|
|
work_on() {
|
|
if [ -z "$1" ]; then
|
|
echo "usage: work_on <task_id>"
|
|
return 1
|
|
fi
|
|
|
|
task "$1" start
|
|
|
|
description=$(task _get "$1".description)
|
|
|
|
klog switch -s "$description"
|
|
if [ $? -ne 0 ]; then
|
|
klog start -s "$description"
|
|
fi
|
|
}
|
|
|
|
task_file() {
|
|
if [ -z "$1" ]; then
|
|
echo "usage: task_file <task_id>"
|
|
return 1
|
|
fi
|
|
|
|
task "$1" modify -inbox project:"$(select_project)"
|
|
}
|
|
|
|
task_schedule() {
|
|
if [ -z "$1" ]; then
|
|
echo "usage: task_schedule <task_id> [<date>]"
|
|
return 1
|
|
fi
|
|
|
|
local id="$1"
|
|
local date="$2"
|
|
|
|
if [ -n "$date" ]; then
|
|
task "$id" modify scheduled:"$date"
|
|
return
|
|
fi
|
|
|
|
local current_scheduled
|
|
current_scheduled=$(task "$id" _get scheduled)
|
|
|
|
if [ -z "$current_scheduled" ]; then
|
|
task "$id" modify scheduled:today
|
|
else
|
|
task "$id" modify scheduled:
|
|
fi
|
|
}
|
|
|
|
export PS1='
|
|
$(task_inbox_count_prompt)%(!.%B%F{red}%n%f%b in .${SSH_TTY:+"%B%F{yellow}%n%f%b in "})${SSH_TTY:+"%B%F{green}%m%f%b in "}%B%F{cyan}%~%f%b${(e)git_info[prompt]}${VIRTUAL_ENV:+" via %B%F{yellow}${VIRTUAL_ENV:t}%f%b"}${duration_info}
|
|
%B%(1j.%F{blue}*%f .)%(?.%F{green}.%F{red}%? )$(_prompt_asciiship_vimode)%f%b '
|