37 Commits

Author SHA1 Message Date
50e6a381a3 Remove unused fresh.ini 2025-12-02 16:34:49 +00:00
06977c56c9 Move adding ~/.local/bin to PATH after Hombrew 2025-09-02 22:22:18 +01:00
Benie
46f2b88db1 Teach pixi xdg base-dir manners 2025-07-30 10:16:08 +00:00
Kenneth Benzie (Benie)
8ca2be7aa0 Add -h/--help to session command 2025-07-01 12:44:32 +01:00
fb2d270e2d Print build directory once selected 2025-04-09 16:50:35 +01:00
a0468b7842 Always enable CMake color diagnostics 2025-02-07 12:22:28 +00:00
8ff71513b2 Add completions for session command 2024-09-17 20:36:09 +01:00
2fea9a3795 Update build usage and error message 2024-09-17 19:43:57 +01:00
ee2dac70db Only migrate histfile if target doesn't exist 2024-09-11 20:30:01 +01:00
Kenneth Benzie (Benie)
8812ef8544 Use XDG base dir vars instead of defaults 2024-09-10 07:39:51 -07:00
1e53581d17 Add configurable session host shortnames 2024-08-23 21:40:31 +01:00
6c86d1c0cc Add session command 2024-08-21 23:00:52 +01:00
4ff10eb05e Use neovim as man pager 2024-08-03 00:09:45 +01:00
0ad3647ddc Make prompt also detect running in a container 2024-07-13 10:13:21 +00:00
b5dedf6d56 Also notify ignore fg 2024-07-08 13:41:17 +01:00
c401ecfb86 Also export BUILD_DIR to an absolute path 2024-06-21 14:16:10 +01:00
e7da727896 Also ignore watch commands 2024-06-17 19:37:57 +01:00
192659fd84 Also ignore cat & bat 2024-05-25 17:45:07 +01:00
6632715529 Teach golang xdg manners 2024-05-17 21:44:04 +01:00
37fd8b00e3 Also ignore podman notifications 2024-05-17 17:22:52 +01:00
3be19a22a0 Fix fresh prompt cleanup when options were specified 2024-05-11 22:43:27 +01:00
fda79768b7 Also ignore [i]python 2024-05-09 12:06:33 +01:00
88fdfe7a84 Properly cleanup fresh prompt theme
If `prompt <theme>` is used, prior to this patch the `fresh_line_one`
precmd hook would not be removed. This is no longer the case and cleanup
is correctly performed.
2024-05-08 23:36:21 +01:00
d0cf713a02 Also ignore zsh & bash 2024-05-08 23:00:13 +01:00
e1f16b56b0 Also notify ignore slides 2024-05-08 22:52:34 +01:00
f983c1e205 Also ignore top like tools in notify complete 2024-05-08 14:42:21 +01:00
52a9552bf7 Don't edit an autoenv on init 2024-05-06 21:52:19 +01:00
96a1272506 Remove zcurses build-dir selector 2024-05-04 10:39:10 +01:00
f7bca0102a Tweak .build-dir widget and only enable during build-dir 2024-05-04 10:31:08 +01:00
dcacb1de42 Add .build-var zle widget
Press Ctrl-B to fuzzy find all configuration CMake variables for the
current build directory. Once a variable is selected, rewrite the
command-line to set the selected CMake variable.
2024-05-03 22:44:30 +01:00
766ac3c5bf Move fzf-history-search to utilities
Also rename to .fzf-history-search to avoid it turning up in normal
command completion as an option.
2024-05-03 22:38:19 +01:00
2d56207f1e Stop disabling Ex mode 2024-05-03 22:31:32 +01:00
c20d18e62d More tweaks for build-dir fzf invocation 2024-05-03 15:59:54 +01:00
6388b076bd Add ping to notify ignore list 2024-05-03 15:06:25 +01:00
a3ca92e2a6 Search entire history with fzf in Ctrl-R 2024-05-02 23:57:44 +01:00
d12bc6f756 Make C-r work more like build-dir 2024-05-01 21:41:49 +01:00
e269e6ff8d Swap fzf args in build-dir to make more sense 2024-05-01 21:41:25 +01:00
11 changed files with 242 additions and 211 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
# Ignore all plugin files in subdirectories
zsh-*/
local
zsh*.local

View File

@@ -36,8 +36,6 @@ commands:
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
# If exit script exists, authorize it.
[ -f $PWD/.exit ] && _autoenv_authorized $PWD/.exit yes
# Edit the autoenv.
autoenv edit
# Enter the autoenv.
_autoenv_enter $PWD
;;
@@ -139,16 +137,22 @@ zmodload -F zsh/stat b:zstat
# Check if the given file is authorized, if not prompt the user to authorize,
# ignore, or view the file. Authorized files and their modified times are
# stored in the ~/.cache/autoenv/authorized file to make authorization
# stored in the $XDG_STATE_HOME/autoenv/authorized file to make authorization
# persistent.
_autoenv_authorized() {
local file=$1 yes=$2
# If autoenv cache directory does not exist, create it.
! [ -d ~/.cache/autoenv ] && mkdir -p ~/.cache/autoenv
# If autoenv state directory does not exist, create it.
! [ -d ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv ] && \
mkdir -p ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv
# Migrate from cache to state directory
[ -f $HOME/.cache/autoenv/authorized ] && \
mv $HOME/.cache/autoenv/authorized \
${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized
# If the authorized file does not exist, create it.
! [ -f ~/.cache/autoenv/authorized ] && touch ~/.cache/autoenv/authorized
! [ -f ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized ] && \
touch ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized
# Load the authorized file into a map of authorized key value pairs.
typeset -A authorized=(`cat ~/.cache/autoenv/authorized`)
typeset -A authorized=(`cat ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized`)
# If the file has been removed, return.
! [ -f $file ] && return 1
# If the given file has been authorized, i.e. the modified time matches that
@@ -170,7 +174,7 @@ _autoenv_authorized() {
# Add file to the authorized map.
authorized[$file]=$modified_time
# Store authorized map in authorized file.
echo ${(kv)authorized} > ~/.cache/autoenv/authorized
echo ${(kv)authorized} > ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized
}
# Source an enter script and add its directory to the global entered

View File

@@ -29,7 +29,7 @@ fi
# Interactively choose a `~build` directory for `build` to build.
build-dir() {
local usage='usage: build-dir [-h] [--build] [<directory>]'
local usage='usage: build-dir [-h] [-s] [--build] [<directory>]'
local -a help show do_build
zparseopts -D h=help -help=help s=show -show=show -build=do_build
if [[ -n $help ]]; then
@@ -62,7 +62,7 @@ EOF
local local_build_dir
if [[ ${#*} -gt 1 ]]; then
echo $usage
error "unexpected position arguments: ${*[2,${#*}]}"; return 1
error "unexpected positional arguments: ${*[2,${#*}]}"; return 1
elif [[ ${#*} -eq 1 ]]; then
if [[ ! -d ${*[1]} ]]; then
warning "directory not found: ${*[1]}"
@@ -87,80 +87,16 @@ EOF
elif [[ ${#local_build_dirs} -eq 1 ]]; then
local_build_dir=${local_build_dirs[1]}
elif [[ ${#local_build_dirs} -gt 1 ]]; then
if command -v fzf &> /dev/null; then
# Use fzf to select a build directory
local max=$(( $( tput lines ) / 2 ))
local best=$(( ${#local_build_dirs} + 3 ))
local_build_dir=$(
printf '%s\n' "${local_build_dirs[@]}" |
fzf --layout=reverse --info=hidden --border=rounded --tac \
--height=$(( $best < $max ? $best : $max ))
)
if [[ $? -ne 0 ]]; then
return 1
fi
else
# Fallback to zcurses selector when fzf is not available
zmodload zsh/curses && {
# Get the size of the terminal
local size=`stty size`
integer height=${size% *}
integer width=${size#* }
# Create the window and hide the cursor
zcurses init
zcurses addwin build-dir $height $width 0 0
# Hide the cursor for zcurses, trap SIGINT to ensure cleanup in
# always-list occurs below
tput civis; trap 'return 130' INT
# Enter display loop
local key keypad
while (( 1 )); do
zcurses clear build-dir
# Add the prompt text
zcurses move build-dir 1 1
zcurses string build-dir 'Select a build directory:'
# Add the selections text
for (( i = 0; i < ${#local_build_dirs}; i++ )); do
integer line=$i+3
zcurses move build-dir $line 1
[[ $index -eq $i ]] &&
zcurses string build-dir "* " ||
zcurses string build-dir " "
zcurses string build-dir ${local_build_dirs[$i+1]}
done
# Display the text the and wait for input
zcurses refresh build-dir
zcurses input build-dir key keypad
# Handle user input
case $key in
(UP|k|$'\C-P')
[[ $index -gt 0 ]] && index=$index-1 ;;
(DOWN|j|$'\C-N')
[[ $index -lt ${#local_build_dirs}-1 ]] && index=$index+1 ;;
(ENTER|$'\n')
break ;;
esac
done
} always {
# Restore the cursor and cleanup zcurses
tput cvvis; tput cnorm
zcurses delwin build-dir
zcurses end
}
# On success setup the build directory for use
if [[ $? -eq 0 ]]; then
# Set the build directory from selection if empty
[[ -z $local_build_dir ]] && \
local_build_dir=${local_build_dirs[$index+1]}
fi
# Use fzf to select a build directory
local max=$(( $( tput lines ) / 2 ))
local best=$(( ${#local_build_dirs} + 4 ))
local_build_dir=$(
printf '%s\n' "${local_build_dirs[@]}" |
fzf --layout=reverse --tac --info=hidden --border=rounded \
--cycle --height=$(( $best < $max ? $best : $max ))
)
if [[ $? -ne 0 ]]; then
return 1
fi
fi
fi
@@ -189,11 +125,17 @@ EOF
alias build="$build"
hash -d build=$local_build_dir
export build_dir=$local_build_dir
export BUILD_DIR=$PWD/$local_build_dir
echo "$build_dir"
# If `--build` is specified then evaluate the command.
if [[ -n $do_build ]]; then
eval build
fi
# Bind C-B to fuzzy find & complete cmake variables.
zle -N .build-var
bindkey '^B' .build-var
}
# Build then run a target residing in `~build/bin`.
@@ -207,3 +149,22 @@ build-debug() {
local target=$1; shift 1
eval build $target && debug ~build/bin/$target "$@"
}
# Fuzzy find CMake variables, select one to set the variable via a command.
.build-var() {
local var=$(
cat $build_dir/CMakeCache.txt |
grep --color=never -Ex '^\w+:\w+=.*$' |
fzf --layout=reverse --info=hidden --border=rounded \
--cycle --height=50%
)
if [[ -n "$var" ]]; then
if [[ "$BUFFER" = "cmake"* ]]; then
BUFFER="$BUFFER-D$var"
else
BUFFER="cmake -B\$build_dir -D$var"
fi
zle end-of-line
fi
zle reset-prompt
}

View File

@@ -1,76 +0,0 @@
; fresh fast-syntax-highlighting theme
[base]
default = none
unknown-token = red,bold
commandseparator = none
redirection = none
here-string-tri = yellow
here-string-word = bg:blue
exec-descriptor = yellow,bold
comment = black,bold
correct-subtle = none
incorrect-subtle = red
subtle-bg = bg:blue
secondary =
[command-point]
reserved-word = yellow
alias = green
suffix-alias = green
global-alias = bg:blue
builtin = green
function = green
command = green
precommand = green
hashed-command = green
[paths]
path = none
pathseparator = none
path-to-dir = none
globbing = blue,bold
[brackets]
paired-bracket = bg:blue
bracket-level-1 = green,bold
bracket-level-2 = yellow,bold
bracket-level-3 = cyan,bold
[arguments]
single-hyphen-option = cyan
double-hyphen-option = cyan
back-quoted-argument = none
single-quoted-argument = yellow
double-quoted-argument = yellow
dollar-quoted-argument = yellow
[in-string]
; backslash in $'...'
back-dollar-quoted-argument = cyan
; backslash or $... in "..."
back-or-dollar-double-quoted-argument = cyan
[other]
variable = 113
assign = none
assign-array-bracket = green
history-expansion = blue,bold
[math]
mathvar = blue,bold
mathnum = magenta
matherr = red
[for-loop]
forvar = none
fornum = magenta
; operator
foroper = yellow
; separator
forsep = yellow,bold
[case]
case-input = green
case-parentheses = yellow
case-condition = bg:blue

View File

@@ -31,7 +31,8 @@ for plugin in $plugins; do
error $plugin_directory contains unstaged changes
fi
pull=`git -C $plugin_directory pull`
if [ "$pull" != "Already up-to-date." ]; then
if [ "$pull" != "Already up to date." ] && \
[ "$pull" != "Already up-to-date." ]; then
echo changed pulled $plugin_directory
fi
else
@@ -53,7 +54,7 @@ symlinks=(
~/.config/zsh/zshenv ~/.zshenv
~/.config/zsh/zshrc ~/.zshrc
~/.config/zsh/prompt_fresh_setup
~/.local/share/zsh/site-functions/prompt_fresh_setup
~/.local/share/zsh/site-functions/prompt_fresh_setup
~/.config/zsh/cmake-uninstall ~/.local/bin/cmake-uninstall
~/.config/zsh/$ ~/.local/bin/$
~/.config/zsh/url/url ~/.local/bin/url

View File

@@ -44,7 +44,7 @@ prompt_fresh_setup() {
fi
local userhost=$USER
if [ "$SSH_CONNECTION" != "" ] || [ "$DISTROBOX_ENTER_PATH" != "" ]; then
if [ "$SSH_CONNECTION" != "" ] || [ "$container" != "" ]; then
local user="$user@%{%F{244}%}%M%{%f%}"
local userhost="$userhost@`hostname`"
fi
@@ -56,13 +56,20 @@ prompt_fresh_setup() {
}
prompt_cleanup() {
[ -f ~/.cache/zsh/git-prompt ] && rm ~/.cache/zsh/git-prompt
[ -f ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt ] && \
rm ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt
}
fresh_line_one() {
# First get the last commands exit code before doing anything
local exit_code=$?
# Clean up if fresh is no longer the current prompt theme
if [[ "`prompt -c | tail -1 | xargs`" != "fresh"* ]]; then
add-zsh-hook -d precmd fresh_line_one
return
fi
# Construct the time and directory portions of the prompt
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
[[ -n $SANDBOX_HOME ]] && \
@@ -70,7 +77,7 @@ fresh_line_one() {
local directory="%{%F{37}%}%~%{%f%}"
# Check we are in a git repository
local git=`~/.cache/zsh/git-prompt`
local git=`${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt`
# If the last command failed, display its error code at the right
if [[ $exit_code -ne 0 ]]; then
@@ -172,10 +179,12 @@ fresh_almostontop_preexec() {
fresh_compile_git_prompt() {
# Compile a simple C program which parses the output of `git status
# --procelain` to greatly decrease the time taken to draw the prompt
[ ! -d ~/.cache/zsh ] && mkdir -p ~/.cache/zsh
if [ ! -f ~/.cache/zsh/git-prompt ]; then
[ ! -d ${XDG_CACHE_HOME:-$HOME/.cache}/zsh ] && \
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/zsh
if [ ! -f ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt ]; then
cc -std=gnu99 -O3 -DNDEBUG -Wno-unused-result \
~/.config/zsh/git-prompt.c -o ~/.cache/zsh/git-prompt
${XDG_CONFIG_HOME:-$HOME/.config}/zsh/git-prompt.c \
-o ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt
if [ $? -ne 0 ]; then
echo "git-prompt was not compiled, is a C99 toolchain installed?"
fi

32
session/_session Normal file
View File

@@ -0,0 +1,32 @@
#compdef session
__session_sessions() {
list() {
for item in $HOME/.local/share/tmux/layouts/session-*; do
item=${item#$HOME/.local/share/tmux/layouts/}
echo ${item#session-}
done
}
local -a sessions
sessions=(${(fo)"$(list)"})
_describe 'session' sessions
}
__session_hosts() {
list() {
declare -A hosts
if [ -f ~/.config/session ]; then
source ~/.config/session
for key val in "${(@kv)hosts}"; do
echo $key
done
fi
}
local -a hosts
hosts=(${(fo)"$(list)"})
_describe 'host' hosts
}
_arguments \
':session:__session_sessions' \
':host:__session_hosts'

View File

@@ -0,0 +1,39 @@
session() {
if [[ "$1" == "" ]]; then
echo "usage: session [-h] <name> [<host>]"
elif [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "usage: session [-h] <name> [<host>]
Create or attach to a tmux session by name either locally on on a remote host
via ssh.
"
else
local name=$1
local host=$2
if [[ "$3" != "" ]]; then
echo "$fg[red]error:$reset_color invalid argument: $3"
return 1
fi
declare -A hosts
if [ -f ~/.config/session ]; then
source ~/.config/session
fi
local url=$hosts[$host]
host=${url:-$host}
if [[ "$TMUX" == "" ]]; then
local cmd="tmux new-session -As $name"
if [[ "$host" != "" ]]; then
cmd="ssh $host -t $cmd"
fi
eval $cmd
else
if [[ "$host" != "" ]]; then
echo "$fg[red]error:$reset_color <host> not allowed inside tmux session"
return 1
fi
tmux list-sessions | grep "$name:" &> /dev/null || \
tmux new-session -Ads $name -c $HOME
tmux switch-client -t $name
fi
fi
}

View File

@@ -46,7 +46,33 @@ notify() {
# Send a desktop notification when long running commands complete.
notify_command_threshold=60
notify_ignore_list=(
cmatrix gh git glab man nvim ssh sudo sudoedit tmux vi vim
bash
bat
btop
cat
cmatrix
fg
gh
git
glab
htop
ipython
man
nvim
ping
podman
python
session
slides
ssh
sudo
sudoedit
tmux
top
vi
vim
watch
zsh
)
notify-ignore() {
@@ -148,3 +174,22 @@ fi
ls-iommu() {
$HOME/.config/zsh/ls-iommu.sh | sort -n
}
# Fuzzy history search with fzf
function .fzf-history-search() {
local selected
selected=$(
cat $HISTFILE | # get entire history
sed 's/ *[0-9]* *//' | # remove cruft
awk '!seen[$0]++' | # remove duplicates
fzf --layout=reverse --tac --cycle --info=hidden \
--border=rounded --height=50%
)
if [[ -n "$selected" ]]; then
BUFFER="$selected"
zle end-of-line
fi
zle reset-prompt
}
zle -N .fzf-history-search
bindkey '^R' .fzf-history-search

60
zshenv
View File

@@ -2,24 +2,30 @@
# contain commands that produce output or assume the shell is attached to a
# tty. This file will always be sourced.
[ -f ~/.config/zsh/zshenv.local ] && source ~/.config/zsh/zshenv.local
# Ensure cache and state directories exist
[ ! -d -${XDG_CACHE_HOME:-$HOME/.cache}/zsh ] && \
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/zsh
[ ! -d -${XDG_STATE_HOME:-$HOME/.local/state}/zsh ] && \
mkdir -p ${XDG_STATE_HOME:-$HOME/.local/state}/zsh
# Enable saving command history to file
[ ! -d $HOME/.cache/zsh ] && mkdir -p $HOME/.cache/zsh
HISTFILE=$HOME/.cache/zsh/histfile
HISTFILE=${XDG_STATE_HOME:-$HOME/.local/state}/zsh/histfile
HISTSIZE=20000
SAVEHIST=20000
# Migrate histfile from cache to state directory
! [ -f $HISTFILE ] && [ -f $HOME/.cache/zsh/histfile ] && \
mv $HOME/.cache/zsh/histfile \
${XDG_STATE_HOME:-$HOME/.local/state}/zsh/histfile
# Remove vi mode switch delay
KEYTIMEOUT=1
# Enable time stats for long lasting commands
REPORTTIME=5
# Add ~/.local to the environment
fpath+=$HOME/.local/share/zsh/site-functions
PATH=$HOME/.local/bin:$PATH
MANPATH=$HOME/.local/share/man:$MANPATH
INFOPATH=$HOME/.local/share/info:$INFOPATH
# Add ccache compiler aliases to PATH and use XDG base dir paths
if [ `uname` = Darwin ]; then
if [ `uname -m` = arm64 ]; then
@@ -40,13 +46,20 @@ elif [ -f /usr/bin/ccache ]; then
PATH=/usr/lib/ccache:$PATH
fi
fi
export CCACHE_CONFIGPATH=$HOME/.config/ccache
export CCACHE_DIR=$HOME/.cache/ccache
export CCACHE_CONFIGPATH=${XDG_CONFIG_HOME:-$HOME/.config}/ccache
export CCACHE_DIR=${XDG_CACHE_HOME:-$HOME/.cache}/ccache
# Add default CMake generator
# Add ~/.local to the environment
fpath+=$HOME/.local/share/zsh/site-functions
PATH=$HOME/.local/bin:$PATH
MANPATH=$HOME/.local/share/man:$MANPATH
INFOPATH=$HOME/.local/share/info:$INFOPATH
# Add default CMake options
command -v ninja &> /dev/null && \
export CMAKE_GENERATOR=Ninja
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
export CMAKE_COLOR_DIAGNOSTICS=ON
# Remove duplicates from environment variables
typeset -U fpath
@@ -57,6 +70,8 @@ typeset -U INFOPATH; export INFOPATH
# Set default editor.
if command -v nvim &> /dev/null; then
export EDITOR=`command -v nvim`
# Also use nvim for man pages
export MANPAGER='nvim +Man!'
elif command -v vim &> /dev/null; then
export EDITOR=`command -v vim`
fi
@@ -101,22 +116,29 @@ command -v pinentry-curses &> /dev/null && \
export LPASS_PINENTRY=pinentry-curses
# Teach these some XDG Base Directory Spec manners
export IPYTHONDIR=$HOME/.config/ipython
export IPYTHONDIR=${XDG_CONFIG_HOME:-$HOME/.config}/ipython
command -v cargo &> /dev/null && \
export CARGO_HOME=$HOME/.local/share/cargo
if command -v ccache &> /dev/null; then
export CCACHE_CONFIGPATH=$HOME/.config/ccache.conf
export CCACHE_DIR=$HOME/.cache/ccache
export CCACHE_CONFIGPATH=${XDG_CONFIG_HOME:-$HOME/.config}/ccache.conf
export CCACHE_DIR=${XDG_CACHE_HOME:-$HOME/.cache}/ccache
fi
command -v conan &> /dev/null && \
export CONAN_USER_HOME=$HOME/.local/share/conan
command -v docker &> /dev/null && \
export DOCKER_CONFIG=$HOME/.local/share/docker
export GTK_RC_FILES=$HOME/.config/gtk/gtkrc
export GTK2_RC_FILES=$HOME/.config/gtk-2.0/gtkrc
export PYLINTHOME=$HOME/.cache/pylint
export GTK_RC_FILES=${XDG_CONFIG_HOME:-$HOME/.config}/gtk/gtkrc
export GTK2_RC_FILES=${XDG_CONFIG_HOME:-$HOME/.config}/gtk-2.0/gtkrc
export PYLINTHOME=${XDG_CACHE_HOME:-$HOME/.cache}/pylint
command -v rustup &> /dev/null && \
export RUSTUP_HOME=$HOME/.local/share/rustup
[ -f $HOME/.config/wget/rc ] && \
export WGETRC=$HOME/.config/wget/rc
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc ] && \
export WGETRC=${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc
# TODO: terminfo
export GOBIN=$HOME/.local/bin
export GOPATH=$HOME/.local/share/go
export GOCACHE=${XDG_CACHE_HOME:-$HOME/.cache}/go/build
export GOMODCACHE=${XDG_CACHE_HOME:-$HOME/.cache}/go/pkg/mod
export GOTMPDIR=${XDG_CACHE_HOME:-$HOME/.cache}/go/tmp
export PIXI_HOME=$HOME/.local
export PIXI_NO_PATH_UPDATE=1

39
zshrc
View File

@@ -3,8 +3,8 @@
# Load plugin scripts
source-plugin() {
local shared_plugin=~/.local/share/zsh/plugins/$1/$1.plugin.zsh
local local_plugin=~/.config/zsh/$1/$1.plugin.zsh
local shared_plugin=${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/$1/$1.plugin.zsh
local local_plugin=${XDG_CONFIG_HOME:-$HOME/.config}/zsh/$1/$1.plugin.zsh
if [ -f $shared_plugin ]; then
source $shared_plugin
elif [ -f $local_plugin ]; then
@@ -41,6 +41,9 @@ source-plugin utilities
# Automatically source .enter and .exit scripts on cd
source-plugin autoenv
# Session manager
source-plugin session
# Layout tmux window commands
[ "$TMUX" != "" ] && source-plugin layout
@@ -73,7 +76,7 @@ setopt completeinword
# Initialize completions
autoload -U compinit
compinit -d ~/.cache/zsh/compdump
compinit -d ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/compdump
# Add pip to the old completion engine if present
if command -v pip &> /dev/null; then
@@ -126,9 +129,6 @@ bindkey -M vicmd 'j' history-substring-search-down
bindkey -r '^[h'
bindkey -M vicmd 'K' run-help
# Disable Ex mode with ':'
bindkey -rM vicmd ':'
# Enable '<Shirt><Tab>' reverse order completions
bindkey '^[[Z' reverse-menu-complete
@@ -146,18 +146,6 @@ if [[ `uname` = Linux ]]; then
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
fi
# Fuzzy history search with fzf
function fzf-history-search() {
local selected
selected=`history | sed 's/ *[0-9]* *//' | fzf`
if [[ -n "$selected" ]]; then
BUFFER="$selected"
zle end-of-line
fi
}
zle -N fzf-history-search
bindkey '^R' fzf-history-search
# Enable changing cursor shape based on vi mode
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
# iTerm2 cursor shape escape sequences outside tmux
@@ -204,14 +192,19 @@ frequent-directory Documents "$HOME/Documents"
frequent-directory Downloads "$HOME/Downloads"
frequent-directory Projects "$HOME/Projects"
frequent-directory Sandbox "$HOME/Sandbox"
frequent-directory cache "$HOME/.cache"
frequent-directory config "$HOME/.config"
frequent-directory cache "${XDG_CACHE_HOME:-$HOME/.cache}"
frequent-directory config "${XDG_CONFIG_HOME:-$HOME/.config}"
frequent-directory local "$HOME/.local"
# Load work related config
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
[ -f ~/.config/private/zshrc ] && source ~/.config/private/zshrc
[ -f ~/.config/zsh/local ] && source ~/.config/zsh/local
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/work/zshrc ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/work/zshrc
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/private/zshrc ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/private/zshrc
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/local ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/local
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshrc.local ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshrc.local
# Aliases
alias grep='grep --color=always'