#!/usr/bin/env zsh # Set up nice and lengthy history export HISTFILE="${ZDOTDIR:-$HOME}/.zsh_history" export HISTSIZE=1000000 export SAVEHIST=1000000 # Simple prompt PROMPT="%F{15}%K{4}%n@%M:%~%f%k " RPROMPT="%(?.%F{10}%?.%F{9}%?)%f %T" autoload -U compaudit compinit zrecompile giti setup_checklist autoload -U colors && colors # zinit declare -A ZINIT ZINIT[HOME_DIR]="${XDG_CONFIG_HOME}/zinit" ZINIT[ZCOMPDUMP_PATH]="${XDG_CACHE_HOME}/zcompdump-${HOSTNAME}-${ZSH_VERSION}" source "${XDG_DATA_HOME}/zinit/zinit.git/zinit.zsh" # bashcompinit after zinit sets up compdump path autoload -U +X bashcompinit && bashcompinit # Powerlevel10k instant prompt. Any input prompts above, other stuff below if [[ -r "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh" fi # Speed up autosuggestions by requiring manual rebind if ever lost ZSH_AUTOSUGGEST_MANUAL_REBIND=1 ZSH_CUSTOM="${XDG_DATA_HOME:-${HOME}/.local/share}/zsh" zinit load "${ZSH_CUSTOM}/brew/" zinit load "${ZSH_CUSTOM}/fzf/" zinit load "${ZSH_CUSTOM}/completion/" zinit load "${ZSH_CUSTOM}/clipboard/" zinit load "${ZSH_CUSTOM}/git/" zinit load "${ZSH_CUSTOM}/powerlevel10k/" zinit load "${ZSH_CUSTOM}/coloured-man/" zinit load "${ZSH_CUSTOM}/zsh-autosuggestions/" zinit load "${ZSH_CUSTOM}/fast-syntax-highlighting/" zinit load "${ZSH_CUSTOM}/auto-activate-venv/" zinit load "${ZSH_CUSTOM}/fzf-z/" zinit load "${ZSH_CUSTOM}/bindings/" # zinit load "${ZSH_CUSTOM}/zsh-autocomplete/" # zinit has issues, use zsh-defer # zinit load "${ZSH_CUSTOM}/zsh-edit/" source "${ZSH_CUSTOM}/zsh-defer/zsh-defer.plugin.zsh" zsh-defer source "${ZSH_CUSTOM}/zsh-edit/zsh-edit.plugin.zsh" zsh-defer bindkey '^W' backward-kill-subword zsh-defer bindkey '^H' backward-kill-shell-word zsh-defer source "${ZDOTDIR}/alias.zsh" zinit ice as"completion" zinit snippet "${ZSH_CUSTOM}/completion/_pass" zinit ice as"completion" zinit snippet https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker zinit ice as"completion" zinit snippet https://github.com/zsh-users/zsh-completions/blob/master/src/_nano # get git-extras + git-extras completions alias pip='noglob python -m pip' # zinit load ${ZSH}/plugins/fasd/ # steal: j/z but use fzf? # zinit load ${ZSH}/plugins/fzf/ # steal: fzf-completion # steal: fzf-cd-widget # steal: fzf-history-widget zicompinit zicdreplay # echo ${INSTALLED_COMPS} # Set editor to micro/nano if which micro &>/dev/null; then export EDITOR='micro' function micro() { emulate -L zsh autoload is-at-least if is-at-least 2.0.0 $(command env micro -version | cut -d' ' -f2); then unset -f micro command env micro "$@" else local log_exists if [[ -f log.txt ]]; then log_exists=1 fi command env micro "$@" if [[ -f log.txt ]] && [[ ${log_exists} != 1 ]]; then rm log.txt fi fi } else export EDITOR='nano' fi # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. if [[ -f "${ZDOTDIR}/.p10k.zsh" ]]; then source "${ZDOTDIR}/.p10k.zsh" elif [[ -f "/etc/zsh/p10k.zsh" ]]; then source "/etc/zsh/p10k.zsh" fi # WSL tricks if [[ "$(uname -r)" == *microsoft-standard* ]]; then if [[ $(service ssh status) == *"is not running"* ]]; then sudo service ssh --full-restart > /dev/null fi fi # iTerm2 integration if [[ -e "${HOME}/.local/share/iterm2/integration/shell_integration/zsh" ]] && which hostname &>/dev/null; then source "${HOME}/.local/share/iterm2/integration/shell_integration/zsh" iterm2_print_user_vars() { it2git } fi # macOS wifi utility if [[ -f "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" ]]; then alias airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" fi export FZFZ_RECENT_DIRS_TOOL="fasd" safari_history() { sqlite3 -box -readonly ~/Library/Safari/History.db < 80 THEN substr(history_visits.title, 1, 77) || '...' ELSE history_visits.title END as title, -- history_items.URL, CASE WHEN length(history_items.URL) > 80 THEN substr(history_items.URL, 1, 77) || '...' ELSE history_items.URL END as trimmed_url, substr(history_items.URL, instr(history_items.URL, '://') + 3, instr(substr(history_items.URL, instr(history_items.URL, '://') + 3), '/') - 1) as domain, ROW_NUMBER() OVER ( PARTITION BY history_visits.title, substr(history_items.URL, instr(history_items.URL, '://') + 3, instr(substr(history_items.URL, instr(history_items.URL, '://') + 3), '/') - 1) ORDER BY history_visits.visit_time DESC ) as row_num FROM history_visits LEFT JOIN history_items ON history_items.id = history_visits.history_item ) -- SELECT time_local, time_utc, title, URL, trimmed_url SELECT time_local, title, trimmed_url FROM ranked_visits WHERE row_num = 1 ORDER BY time_local DESC LIMIT 2000; SQL }