summaryrefslogtreecommitdiffstats
path: root/dot_config/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/zsh')
-rw-r--r--dot_config/zsh/aliasrc84
-rw-r--r--dot_config/zsh/dot_p10k.zsh22
-rw-r--r--dot_config/zsh/dot_zshenv37
-rw-r--r--dot_config/zsh/dot_zshrc37
-rw-r--r--dot_config/zsh/executable_dot_zshopts30
5 files changed, 125 insertions, 85 deletions
diff --git a/dot_config/zsh/aliasrc b/dot_config/zsh/aliasrc
index 0b2b91d..c3e724d 100644
--- a/dot_config/zsh/aliasrc
+++ b/dot_config/zsh/aliasrc
@@ -3,35 +3,45 @@
# Use neovim for vim if present.
[ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d"
+# If code-insiders exists and code does not, use code-insiders.
+[ -x "$(command -v code-insiders)" ] && [ ! -x "$(command -v code)" ] && alias code="code-insiders"
+
+# if batcat exists and bat does not, use batcat.
+[ -x "$(command -v batcat)" ] && [ ! -x "$(command -v bat)" ] && alias bat="batcat"
+
+# If fdfind exists and fd does not, use fdfind.
+[ -x "$(command -v fdfind)" ] && [ ! -x "$(command -v fd)" ] && alias fd="fdfind"
+
# Use $XINITRC variable if file exists.
-[ -f "$XINITRC" ] && alias startx="startx $XINITRC"
+[ -f "$XINITRC" ] && alias startx='startx "$XINITRC"'
# sudo not required for some system commands
-for x in mount umount sv emerge apt pacman updatedb su ; do
- alias $x="sudo $x"
+for x in mount umount sv emerge apt pacman updatedb su; do
+ # shellcheck disable=SC2139
+ alias $x="sudo $x"
done
-if command -v doas &>/dev/null
-then
- alias sudo='doas'
+if command -v doas >/dev/null 2>&1; then
+ alias sudo='doas'
else
- alias sudo='sudo '
+# alias sudo='sudo -E'
fi
# Verbosity and settings that you pretty much just always are going to want.
alias \
- cp="cp -iv" \
- mv="mv -iv" \
- rm="rm -vI" \
- bc="bc -ql" \
- mkdir="mkdir -pv" \
- yt="yt-dlp --add-metadata -i" \
- yta="yt -x -f bestaudio/best" \
- ffmpeg="ffmpeg -hide_banner" \
- df="df -h" \
- du="dust -r" \
- free="free -m" \
- gdb='gdb -q -nh -x "$XDG_CONFIG_HOME/gdb/init"' \
+ cp="cp -iv" \
+ mv="mv -iv" \
+ rm="rm -vI" \
+ bc="bc -ql" \
+ mkdir="mkdir -pv" \
+ yt="yt-dlp --add-metadata -i" \
+ yta="yt -x -f bestaudio/best" \
+ ffmpeg="ffmpeg -hide_banner" \
+ df="df -h" \
+ du="dust -r" \
+ free="free -m" \
+ gdb='gdb -q -nh -x "$XDG_CONFIG_HOME/gdb/init"' \
+ wget='wget --hsts-file="$XDG_DATA_HOME/wget-hsts"'
# Colorize commands when possible.
alias \
@@ -39,24 +49,30 @@ alias \
ll="eza -alg --group-directories-first" \
lt='eza -aTF --group-directories-first' \
lr='eza -aRF' \
- grep="rg --color=auto" \
+ grep="rg --color=auto --hyperlink-format=file://{wslprefix}{path}" \
diff="delta" \
- cat='bat --paging=never --style=plain' \
+ cat='bat --paging=never --style=plain'
# These common commands are just too long! Abbreviate them.
alias \
- ka="killall" \
- g="git" \
- trem="transmission-remote" \
- YT="youtube-viewer" \
- sdn="sudo shutdown -h now" \
- e="$EDITOR" \
- v="$EDITOR" \
- em="sudo emerge" \
- p="sudo pacman" \
- xi="sudo xbps-install" \
- xr="sudo xbps-remove -R" \
- xq="xbps-query" \
- z="zathura"
+ ka="killall" \
+ g="git" \
+ trem="transmission-remote" \
+ YT="youtube-viewer" \
+ sdn="sudo shutdown -h now" \
+ e="\$EDITOR" \
+ v="\$EDITOR" \
+ em="sudo emerge" \
+ p="sudo pacman" \
+ xi="sudo xbps-install" \
+ xr="sudo xbps-remove -R" \
+ xq="xbps-query" \
+ z="zathura"
alias adb='HOME="$XDG_DATA_HOME"/android adb'
+
+# Use the SSH kitten when possible. (but not already in SSH)
+if [ "$TERM" = "xterm-kitty" ] && [ -z "$SSH_TTY" ]; then
+ alias sshs='sshs -t "kitten ssh \"{{{name}}}\""'
+fi
+
diff --git a/dot_config/zsh/dot_p10k.zsh b/dot_config/zsh/dot_p10k.zsh
index fc1b23c..eccf809 100644
--- a/dot_config/zsh/dot_p10k.zsh
+++ b/dot_config/zsh/dot_p10k.zsh
@@ -1,4 +1,4 @@
-# Generated by Powerlevel10k configuration wizard on 2023-11-09 at 16:04 CST.
+# Generated by Powerlevel10k configuration wizard on 1970-01-01 at 00:00 UTC.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh.
# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 24h time,
# 2 lines, disconnected, no frame, sparse, few icons, concise, transient_prompt,
@@ -32,7 +32,7 @@
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
- # os_icon # os identifier
+ os_icon # os identifier
dir # current directory
vcs # git status
# =========================[ Line #2 ]=========================
@@ -57,15 +57,15 @@
#goenv # go environment (https://github.com/syndbg/goenv)
#nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv)
#nvm # node.js version from nvm (https://github.com/nvm-sh/nvm)
- nodeenv # node.js environment (https://github.com/ekalinin/nodeenv)
- node_version # node.js version
- go_version # go version (https://golang.org)
- rust_version # rustc version (https://www.rust-lang.org)
- dotnet_version # .NET version (https://dotnet.microsoft.com)
- # php_version # php version (https://www.php.net/)
+ #nodeenv # node.js environment (https://github.com/ekalinin/nodeenv)
+ node_version # node.js version
+ go_version # go version (https://golang.org)
+ rust_version # rustc version (https://www.rust-lang.org)
+ dotnet_version # .NET version (https://dotnet.microsoft.com)
+ php_version # php version (https://www.php.net/)
# laravel_version # laravel php framework version (https://laravel.com/)
- # java_version # java version (https://www.java.com/)
- package # name@version from package.json (https://docs.npmjs.com/files/package.json)
+ java_version # java version (https://www.java.com/)
+ package # name@version from package.json (https://docs.npmjs.com/files/package.json)
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io)
fvm # flutter version management (https://github.com/leoafarias/fvm)
@@ -104,7 +104,7 @@
timewarrior # timewarrior tracking status (https://timewarrior.net/)
taskwarrior # taskwarrior task count (https://taskwarrior.org/)
per_directory_history # Oh My Zsh per-directory-history local/global indicator
- # cpu_arch # CPU architecture
+ cpu_arch # CPU architecture
time # current time
# =========================[ Line #2 ]=========================
newline
diff --git a/dot_config/zsh/dot_zshenv b/dot_config/zsh/dot_zshenv
index dfa3718..88e4cbe 100644
--- a/dot_config/zsh/dot_zshenv
+++ b/dot_config/zsh/dot_zshenv
@@ -1,4 +1,4 @@
-#!/bin/zsh
+#!/usr/bin/env zsh
# profile file. Runs on login. Environmental variables are set here.
# If you don't plan on reverting to bash, you can remove the link in ~/.profile
@@ -8,9 +8,27 @@ export FPATH="$FPATH:${XDG_DATA_HOME:-$HOME/.local/share/zsh/site-functions}"
unsetopt PROMPT_SP
-# Default programs:
-export EDITOR="nvim +star"
-export BROWSER="chromium"
+if command -v nvim >/dev/null 2>&1
+then
+ DEFAULT_EDITOR="nvim +star"
+else
+ DEFAULT_EDITOR="nano"
+fi
+
+# Use TUI editor for git
+[ -z "$GIT_EDITOR" ] && export GIT_EDITOR="$DEFAULT_EDITOR"
+
+# Default programs for SSH or not
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
+ export BROWSER="w3m"
+ export EDITOR="$DEFAULT_EDITOR"
+else
+ export BROWSER="chromium"
+ # shellcheck disable=SC2015
+ [ -n "$DISPLAY" ] && export EDITOR="code -nw" || export EDITOR="$DEFAULT_EDITOR"
+fi
+
+export VISUAL="$EDITOR"
# ~/ Clean-up (XDG):
[ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME="$HOME/.config"
@@ -20,6 +38,7 @@ export BROWSER="chromium"
[ -z "$XDG_BIN_HOME" ] && export XDG_BIN_HOME="$HOME/.local/bin"
[ -z "$XDG_RUNTIME_DIR" ] && export XDG_RUNTIME_DIR="/run/user/$UID"
+export ZSTD_NBTHREADS=0
export DO_NOT_TRACK=1
export USERXSESSION="$XDG_CACHE_HOME"/X11/xsession
export USERXSESSIONRC="$XDG_CACHE_HOME"/X11/xsessionrc
@@ -55,7 +74,7 @@ export PNPM_HOME="$XDG_DATA_HOME"/pnpm
#export DENO_INSTALL_ROOT="${XDG_BIN_HOME:-$HOME/.local/bin}
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME"/ansible/ansible.cfg
export UNISON="$XDG_DATA_HOME"/unison
-export HISTFILE="$XDG_DATA_HOME"/history
+# export HISTFILE="$XDG_DATA_HOME"/history
export WEECHAT_HOME="$XDG_CONFIG_HOME"/weechat
export MBSYNCRC="$XDG_CONFIG_HOME"/mbsync/config
export ELECTRUMDIR="$XDG_DATA_HOME"/electrum
@@ -73,11 +92,15 @@ export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
export AWS_SHARED_CREDENTIALS_FILE="$XDG_CONFIG_HOME"/aws/credentials
export AWS_CONFIG_FILE="$XDG_CONFIG_HOME"/aws/config
export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure
+export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME"/ripgrep/config
+export GRADLE_USER_HOME="$XDG_DATA_HOME"/gradle
+export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc
+export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
+export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
+export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
# Other program settings:
export DOTNET_CLI_TELEMETRY_OPTOUT=1
-export DICS="/usr/share/stardict/dic/"
-export SUDO_ASKPASS="$HOME/.local/bin/dmenupass"
export FZF_DEFAULT_OPTS="--layout=reverse --height 40%"
export LESS=-R
export LESS_TERMCAP_mb="$(printf '%b' '')"
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc
index 829b5a7..350571a 100644
--- a/dot_config/zsh/dot_zshrc
+++ b/dot_config/zsh/dot_zshrc
@@ -1,3 +1,4 @@
+#!/usr/bin/env zsh
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
@@ -11,6 +12,8 @@ then
else
ID=$(uname -s)
fi
+
+# Load Powerlevel10k theme
case "$ID" in
Darwin )
source /usr/local/share/powerlevel10k/powerlevel10k.zsh-theme
@@ -25,31 +28,15 @@ case "$ID" in
;;
esac
+if [ -x "$(command -v gem)" ]; then
+ export GEM_HOME="$(gem env user_gemhome)"
+ export PATH="$PATH:$GEM_HOME/bin"
+fi
# Enable colors and change prompt:
autoload -U colors && colors # Load colors
-setopt autocd # Automatically cd into typed directory.
#stty stop undef # Disable ctrl-s to freeze terminal.
-setopt interactive_comments
-setopt complete_aliases
-# History in cache directory:
-HISTSIZE=100000000
-SAVEHIST=100000000
-HISTFILE="$XDG_STATE_HOME"/zsh/history
-setopt BANG_HIST # Treat the '!' character specially during expansion.
-setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
-setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
-setopt SHARE_HISTORY # Share history between all sessions.
-setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
-setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
-setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
-setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
-setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
-setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
-setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
-setopt HIST_VERIFY # Don't execute immediately upon history expansion.
-setopt HIST_BEEP # Beep when accessing nonexistent history.
# Load aliases and shortcuts if existent.
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/aliasrc"
@@ -64,10 +51,6 @@ zmodload zsh/complist
compinit -d ~/.cache/zsh/zcompdump-$ZSH_VERSION
_comp_options+=(globdots) # Include hidden files.
-# To customize prompt, run `p10k configure` or edit ~/.config/zsh/. p10k.zsh.
-[[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh
-[[ ! -f ~/.config/zsh/keybindings.zsh ]] || source ~/.config/zsh/keybindings.zsh
-
if [ -n "$WSL_DISTRO_NAME" ]
then
command_not_found_handler() {
@@ -104,3 +87,9 @@ case "$ID" in
;;
esac
+# Windows Terminal stuff
+PS1="\[\033]133;D;\007\]\[\033]133;A;\007\]$PS1\[\033]133;B;\007\]"
+
+# To customize prompt, run `p10k configure` or edit ~/.config/zsh/. p10k.zsh.
+[[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh
+[[ ! -f ~/.config/zsh/keybindings.zsh ]] || source ~/.config/zsh/keybindings.zsh \ No newline at end of file
diff --git a/dot_config/zsh/executable_dot_zshopts b/dot_config/zsh/executable_dot_zshopts
index 6756bfd..cc26e74 100644
--- a/dot_config/zsh/executable_dot_zshopts
+++ b/dot_config/zsh/executable_dot_zshopts
@@ -1,7 +1,17 @@
#! /usr/bin/env zsh
+
+# If you don't plan on reverting to bash, you can remove the link in ~/.profile
+# to clean up.
+
+# create hist directory if it doesn't exist
+if [ -z "$XDG_STATE_HOME/zsh" ]; then
+ mkdir -p "$XDG_STATE_HOME/zsh"
+fi
+
# History settings
-HISTSIZE=50000
-SAVEHIST=10000
+HISTSIZE=9999999999
+SAVEHIST=$HISTSIZE
+HISTFILE="$XDG_STATE_HOME"/zsh/history
setopt append_history # append the history
setopt inc_append_history # append to history in the current
@@ -18,11 +28,13 @@ setopt hist_find_no_dups # if we find dupes in the history, don't show
setopt hist_reduce_blanks # remove blank lines from the command which
# mean nothing to the shell
-# Disable this on boxes that are affected by bug
-# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=924736
-# is-at-least 5.5 && unsetopt hist_reduce_blanks
-# bugfix is incoming, lets see what it does
-# is-at-least 5.7.2 && setopt hist_reduce_blanks
+setopt HIST_VERIFY # Don't execute immediately upon history expansion.
+setopt BANG_HIST # Treat the '!' character specially during expansion.
+
+setopt complete_aliases # complete aliases
+setopt complete_in_word # complete in the middle of a word
+
+setopt hist_reduce_blanks
setopt hist_ignore_space # lines starting with space don't go into the
# history
@@ -36,7 +48,7 @@ setopt notify # notify when a command returns exit code
setopt no_beep # silence..!
-#unsetopt auto_cd # disable $ ./bin as cd ./bin
+setopt auto_cd # cd to a directory if it's the only argument
setopt extendedglob # ls ^bla.* will not show ^bla.txt for example
setopt correct # correct incorrent cmd's
@@ -66,6 +78,6 @@ setopt auto_name_dirs # foo=/path/to/foo is the same as
# hash -d foo=/path/to/foo
# Misc
-setopt interactivecomments # $ # foo doesn't become an error when hitting
+setopt interactive_comments # $ # foo doesn't become an error when hitting
# enter