Compare commits
1 Commits
main
...
e9f9ce6193
| Author | SHA1 | Date | |
|---|---|---|---|
| e9f9ce6193 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
# Ignore all plugin files in subdirectories
|
# Ignore all plugin files in subdirectories
|
||||||
zsh-*/
|
zsh-*/
|
||||||
local
|
local
|
||||||
zsh*.local
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ commands:
|
|||||||
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
|
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
|
||||||
# If exit script exists, authorize it.
|
# If exit script exists, authorize it.
|
||||||
[ -f $PWD/.exit ] && _autoenv_authorized $PWD/.exit yes
|
[ -f $PWD/.exit ] && _autoenv_authorized $PWD/.exit yes
|
||||||
|
# Edit the autoenv.
|
||||||
|
autoenv edit
|
||||||
# Enter the autoenv.
|
# Enter the autoenv.
|
||||||
_autoenv_enter $PWD
|
_autoenv_enter $PWD
|
||||||
;;
|
;;
|
||||||
@@ -132,88 +134,21 @@ commands:
|
|||||||
# Global entered directories array.
|
# Global entered directories array.
|
||||||
_autoenv_entered=()
|
_autoenv_entered=()
|
||||||
|
|
||||||
# Per-directory shell state snapshots for computing enter/exit diffs.
|
|
||||||
typeset -gA _autoenv_snap_pre_funcs _autoenv_snap_pre_aliases _autoenv_snap_pre_env
|
|
||||||
typeset -gA _autoenv_snap_pre_path _autoenv_snap_pre_ps1
|
|
||||||
typeset -gA _autoenv_snap_diff_funcs _autoenv_snap_diff_aliases _autoenv_snap_diff_env
|
|
||||||
|
|
||||||
# Snapshot shell state before .enter modifications. Call in .enter BEFORE
|
|
||||||
# sourcing scripts: _autoenv_snap_pre ${0:A:h}
|
|
||||||
_autoenv_snap_pre() {
|
|
||||||
local dir=$1
|
|
||||||
_autoenv_snap_pre_funcs[$dir]="${(pj:\n:)${(@k)functions}}"
|
|
||||||
_autoenv_snap_pre_aliases[$dir]="${(pj:\n:)${(@k)aliases}}"
|
|
||||||
_autoenv_snap_pre_env[$dir]="${(F)$(typeset +gx 2>/dev/null)}"
|
|
||||||
_autoenv_snap_pre_path[$dir]="$PATH"
|
|
||||||
_autoenv_snap_pre_ps1[$dir]="$PS1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Snapshot shell state after .enter modifications and compute the diff.
|
|
||||||
# Call in .enter AFTER sourcing scripts: _autoenv_snap_post ${0:A:h}
|
|
||||||
_autoenv_snap_post() {
|
|
||||||
local dir=$1 f a v
|
|
||||||
local -a pre_funcs=("${(f)_autoenv_snap_pre_funcs[$dir]}")
|
|
||||||
local -a pre_aliases=("${(f)_autoenv_snap_pre_aliases[$dir]}")
|
|
||||||
local -a pre_env=("${(f)_autoenv_snap_pre_env[$dir]}")
|
|
||||||
local -a diff_funcs=() diff_aliases=() diff_env=()
|
|
||||||
for f in "${(@k)functions}"; do
|
|
||||||
(( ${pre_funcs[(Ie)$f]} )) || diff_funcs+=$f
|
|
||||||
done
|
|
||||||
for a in "${(@k)aliases}"; do
|
|
||||||
(( ${pre_aliases[(Ie)$a]} )) || diff_aliases+=$a
|
|
||||||
done
|
|
||||||
for v in "${(f)$(typeset +gx 2>/dev/null)}"; do
|
|
||||||
(( ${pre_env[(Ie)$v]} )) || diff_env+=$v
|
|
||||||
done
|
|
||||||
_autoenv_snap_diff_funcs[$dir]="${(pj:\n:)diff_funcs}"
|
|
||||||
_autoenv_snap_diff_aliases[$dir]="${(pj:\n:)diff_aliases}"
|
|
||||||
_autoenv_snap_diff_env[$dir]="${(pj:\n:)diff_env}"
|
|
||||||
unset "_autoenv_snap_pre_funcs[$dir]" "_autoenv_snap_pre_aliases[$dir]" \
|
|
||||||
"_autoenv_snap_pre_env[$dir]"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Restore shell state by removing only what was added between snap_pre and
|
|
||||||
# snap_post. Call in .exit: _autoenv_snap_restore ${0:A:h}
|
|
||||||
_autoenv_snap_restore() {
|
|
||||||
local dir=$1 f a v
|
|
||||||
for f in "${(f)_autoenv_snap_diff_funcs[$dir]}"; do
|
|
||||||
[[ -n "$f" ]] && unset -f "$f"
|
|
||||||
done
|
|
||||||
for a in "${(f)_autoenv_snap_diff_aliases[$dir]}"; do
|
|
||||||
[[ -n "$a" ]] && unalias "$a" 2>/dev/null
|
|
||||||
done
|
|
||||||
for v in "${(f)_autoenv_snap_diff_env[$dir]}"; do
|
|
||||||
[[ -n "$v" ]] && unset "$v"
|
|
||||||
done
|
|
||||||
PATH="${_autoenv_snap_pre_path[$dir]}"
|
|
||||||
PS1="${_autoenv_snap_pre_ps1[$dir]}"
|
|
||||||
unset "_autoenv_snap_pre_path[$dir]" "_autoenv_snap_pre_ps1[$dir]" \
|
|
||||||
"_autoenv_snap_diff_funcs[$dir]" "_autoenv_snap_diff_aliases[$dir]" \
|
|
||||||
"_autoenv_snap_diff_env[$dir]"
|
|
||||||
prompt "${prompt_theme[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Load zstat from stat module for inspecting modified time.
|
# Load zstat from stat module for inspecting modified time.
|
||||||
zmodload -F zsh/stat b:zstat
|
zmodload -F zsh/stat b:zstat
|
||||||
|
|
||||||
# Check if the given file is authorized, if not prompt the user to authorize,
|
# 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
|
# ignore, or view the file. Authorized files and their modified times are
|
||||||
# stored in the $XDG_STATE_HOME/autoenv/authorized file to make authorization
|
# stored in the ~/.cache/autoenv/authorized file to make authorization
|
||||||
# persistent.
|
# persistent.
|
||||||
_autoenv_authorized() {
|
_autoenv_authorized() {
|
||||||
local file=$1 yes=$2
|
local file=$1 yes=$2
|
||||||
# If autoenv state directory does not exist, create it.
|
# If autoenv cache directory does not exist, create it.
|
||||||
! [ -d ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv ] && \
|
! [ -d ~/.cache/autoenv ] && mkdir -p ~/.cache/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.
|
# If the authorized file does not exist, create it.
|
||||||
! [ -f ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized ] && \
|
! [ -f ~/.cache/autoenv/authorized ] && touch ~/.cache/autoenv/authorized
|
||||||
touch ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized
|
|
||||||
# Load the authorized file into a map of authorized key value pairs.
|
# Load the authorized file into a map of authorized key value pairs.
|
||||||
typeset -A authorized=(`cat ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized`)
|
typeset -A authorized=(`cat ~/.cache/autoenv/authorized`)
|
||||||
# If the file has been removed, return.
|
# If the file has been removed, return.
|
||||||
! [ -f $file ] && return 1
|
! [ -f $file ] && return 1
|
||||||
# If the given file has been authorized, i.e. the modified time matches that
|
# If the given file has been authorized, i.e. the modified time matches that
|
||||||
@@ -235,7 +170,7 @@ _autoenv_authorized() {
|
|||||||
# Add file to the authorized map.
|
# Add file to the authorized map.
|
||||||
authorized[$file]=$modified_time
|
authorized[$file]=$modified_time
|
||||||
# Store authorized map in authorized file.
|
# Store authorized map in authorized file.
|
||||||
echo ${(kv)authorized} > ${XDG_STATE_HOME:-$HOME/.local/state}/autoenv/authorized
|
echo ${(kv)authorized} > ~/.cache/autoenv/authorized
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source an enter script and add its directory to the global entered
|
# Source an enter script and add its directory to the global entered
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fi
|
|||||||
|
|
||||||
# Interactively choose a `~build` directory for `build` to build.
|
# Interactively choose a `~build` directory for `build` to build.
|
||||||
build-dir() {
|
build-dir() {
|
||||||
local usage='usage: build-dir [-h] [-s] [--build] [<directory>]'
|
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
||||||
local -a help show do_build
|
local -a help show do_build
|
||||||
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
||||||
if [[ -n $help ]]; then
|
if [[ -n $help ]]; then
|
||||||
@@ -62,7 +62,7 @@ EOF
|
|||||||
local local_build_dir
|
local local_build_dir
|
||||||
if [[ ${#*} -gt 1 ]]; then
|
if [[ ${#*} -gt 1 ]]; then
|
||||||
echo $usage
|
echo $usage
|
||||||
error "unexpected positional arguments: ${*[2,${#*}]}"; return 1
|
error "unexpected position arguments: ${*[2,${#*}]}"; return 1
|
||||||
elif [[ ${#*} -eq 1 ]]; then
|
elif [[ ${#*} -eq 1 ]]; then
|
||||||
if [[ ! -d ${*[1]} ]]; then
|
if [[ ! -d ${*[1]} ]]; then
|
||||||
warning "directory not found: ${*[1]}"
|
warning "directory not found: ${*[1]}"
|
||||||
@@ -87,6 +87,7 @@ EOF
|
|||||||
elif [[ ${#local_build_dirs} -eq 1 ]]; then
|
elif [[ ${#local_build_dirs} -eq 1 ]]; then
|
||||||
local_build_dir=${local_build_dirs[1]}
|
local_build_dir=${local_build_dirs[1]}
|
||||||
elif [[ ${#local_build_dirs} -gt 1 ]]; then
|
elif [[ ${#local_build_dirs} -gt 1 ]]; then
|
||||||
|
if command -v fzf &> /dev/null; then
|
||||||
# Use fzf to select a build directory
|
# Use fzf to select a build directory
|
||||||
local max=$(( $( tput lines ) / 2 ))
|
local max=$(( $( tput lines ) / 2 ))
|
||||||
local best=$(( ${#local_build_dirs} + 4 ))
|
local best=$(( ${#local_build_dirs} + 4 ))
|
||||||
@@ -98,6 +99,69 @@ EOF
|
|||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -125,17 +189,11 @@ EOF
|
|||||||
alias build="$build"
|
alias build="$build"
|
||||||
hash -d build=$local_build_dir
|
hash -d build=$local_build_dir
|
||||||
export build_dir=$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 `--build` is specified then evaluate the command.
|
||||||
if [[ -n $do_build ]]; then
|
if [[ -n $do_build ]]; then
|
||||||
eval build
|
eval build
|
||||||
fi
|
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`.
|
# Build then run a target residing in `~build/bin`.
|
||||||
@@ -150,8 +208,11 @@ build-debug() {
|
|||||||
eval build $target && debug ~build/bin/$target "$@"
|
eval build $target && debug ~build/bin/$target "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fuzzy find CMake variables, select one to set the variable via a command.
|
# Interactively view CMake variables
|
||||||
.build-var() {
|
.build-var() {
|
||||||
|
if [[ ! -n $build_dir ]]; then
|
||||||
|
build-dir
|
||||||
|
fi
|
||||||
local var=$(
|
local var=$(
|
||||||
cat $build_dir/CMakeCache.txt |
|
cat $build_dir/CMakeCache.txt |
|
||||||
grep --color=never -Ex '^\w+:\w+=.*$' |
|
grep --color=never -Ex '^\w+:\w+=.*$' |
|
||||||
@@ -159,12 +220,10 @@ build-debug() {
|
|||||||
--cycle --height=50%
|
--cycle --height=50%
|
||||||
)
|
)
|
||||||
if [[ -n "$var" ]]; then
|
if [[ -n "$var" ]]; then
|
||||||
if [[ "$BUFFER" = "cmake"* ]]; then
|
|
||||||
BUFFER="$BUFFER-D$var"
|
|
||||||
else
|
|
||||||
BUFFER="cmake -B\$build_dir -D$var"
|
BUFFER="cmake -B\$build_dir -D$var"
|
||||||
fi
|
|
||||||
zle end-of-line
|
zle end-of-line
|
||||||
fi
|
fi
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
zle -N .build-var
|
||||||
|
bindkey '^B' .build-var
|
||||||
|
|||||||
76
fresh.ini
Normal file
76
fresh.ini
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
; 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
|
||||||
11
install.zsh
11
install.zsh
@@ -17,10 +17,10 @@ for directory in $directories; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
plugins=(
|
plugins=(
|
||||||
kbenzie/zsh-syntax-highlighting
|
|
||||||
zsh-users/zsh-autosuggestions
|
zsh-users/zsh-autosuggestions
|
||||||
zsh-users/zsh-completions
|
|
||||||
zsh-users/zsh-history-substring-search
|
zsh-users/zsh-history-substring-search
|
||||||
|
zsh-users/zsh-syntax-highlighting
|
||||||
|
zsh-users/zsh-completions
|
||||||
)
|
)
|
||||||
|
|
||||||
for plugin in $plugins; do
|
for plugin in $plugins; do
|
||||||
@@ -30,13 +30,8 @@ for plugin in $plugins; do
|
|||||||
if ! git -C $plugin_directory diff-index --quiet HEAD --; then
|
if ! git -C $plugin_directory diff-index --quiet HEAD --; then
|
||||||
error $plugin_directory contains unstaged changes
|
error $plugin_directory contains unstaged changes
|
||||||
fi
|
fi
|
||||||
existing_url=`git -C $plugin_directory config --get remote.origin.url`
|
|
||||||
if [ "$existing_url" != "https://github.com/$plugin.git" ]; then
|
|
||||||
git -C $plugin_directory config remote.origin.url https://github.com/$plugin.git
|
|
||||||
fi
|
|
||||||
pull=`git -C $plugin_directory pull`
|
pull=`git -C $plugin_directory pull`
|
||||||
if [ "$pull" != "Already up to date." ] && \
|
if [ "$pull" != "Already up-to-date." ]; then
|
||||||
[ "$pull" != "Already up-to-date." ]; then
|
|
||||||
echo changed pulled $plugin_directory
|
echo changed pulled $plugin_directory
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ prompt_fresh_setup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local userhost=$USER
|
local userhost=$USER
|
||||||
if [ "$SSH_CONNECTION" != "" ] || [ "$container" != "" ]; then
|
if [ "$SSH_CONNECTION" != "" ] || [ "$DISTROBOX_ENTER_PATH" != "" ]; then
|
||||||
local user="$user@%{%F{244}%}%M%{%f%}"
|
local user="$user@%{%F{244}%}%M%{%f%}"
|
||||||
local userhost="$userhost@`hostname`"
|
local userhost="$userhost@`hostname`"
|
||||||
fi
|
fi
|
||||||
@@ -56,20 +56,13 @@ prompt_fresh_setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prompt_cleanup() {
|
prompt_cleanup() {
|
||||||
[ -f ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt ] && \
|
[ -f ~/.cache/zsh/git-prompt ] && rm ~/.cache/zsh/git-prompt
|
||||||
rm ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fresh_line_one() {
|
fresh_line_one() {
|
||||||
# First get the last commands exit code before doing anything
|
# First get the last commands exit code before doing anything
|
||||||
local exit_code=$?
|
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
|
# Construct the time and directory portions of the prompt
|
||||||
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
||||||
[[ -n $SANDBOX_HOME ]] && \
|
[[ -n $SANDBOX_HOME ]] && \
|
||||||
@@ -77,18 +70,7 @@ fresh_line_one() {
|
|||||||
local directory="%{%F{37}%}%~%{%f%}"
|
local directory="%{%F{37}%}%~%{%f%}"
|
||||||
|
|
||||||
# Check we are in a git repository
|
# Check we are in a git repository
|
||||||
local git=`${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt`
|
local git=`~/.cache/zsh/git-prompt`
|
||||||
|
|
||||||
# Truncate branch name from directory when already shown (e.g., worktrees)
|
|
||||||
if [[ -n "$git" ]] && [[ -z $SANDBOX_HOME ]]; then
|
|
||||||
local branch_name=$(git symbolic-ref --short HEAD 2>/dev/null)
|
|
||||||
if [[ -n "$branch_name" ]]; then
|
|
||||||
local dir=${(%):-%~}
|
|
||||||
if [[ "$dir" == *"@${branch_name}"* ]]; then
|
|
||||||
directory="%{%F{37}%}${dir/@${branch_name}/@}%{%f%}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the last command failed, display its error code at the right
|
# If the last command failed, display its error code at the right
|
||||||
if [[ $exit_code -ne 0 ]]; then
|
if [[ $exit_code -ne 0 ]]; then
|
||||||
@@ -144,12 +126,8 @@ fresh_line_one() {
|
|||||||
local docker=" %{%F{6}%}$DOCKER_MACHINE_NAME%{%f%}"
|
local docker=" %{%F{6}%}$DOCKER_MACHINE_NAME%{%f%}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$MODULAR_PATH" ]]; then
|
|
||||||
local modular=" 🔥"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print the first line of the prompt
|
# Print the first line of the prompt
|
||||||
print -P "$time_stamp $directory$git$py$docker$modular$result"
|
print -P "$time_stamp $directory$git$py$docker$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Executed before each prompt.
|
# Executed before each prompt.
|
||||||
@@ -194,12 +172,10 @@ fresh_almostontop_preexec() {
|
|||||||
fresh_compile_git_prompt() {
|
fresh_compile_git_prompt() {
|
||||||
# Compile a simple C program which parses the output of `git status
|
# Compile a simple C program which parses the output of `git status
|
||||||
# --procelain` to greatly decrease the time taken to draw the prompt
|
# --procelain` to greatly decrease the time taken to draw the prompt
|
||||||
[ ! -d ${XDG_CACHE_HOME:-$HOME/.cache}/zsh ] && \
|
[ ! -d ~/.cache/zsh ] && mkdir -p ~/.cache/zsh
|
||||||
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/zsh
|
if [ ! -f ~/.cache/zsh/git-prompt ]; then
|
||||||
if [ ! -f ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt ]; then
|
|
||||||
cc -std=gnu99 -O3 -DNDEBUG -Wno-unused-result \
|
cc -std=gnu99 -O3 -DNDEBUG -Wno-unused-result \
|
||||||
${XDG_CONFIG_HOME:-$HOME/.config}/zsh/git-prompt.c \
|
~/.config/zsh/git-prompt.c -o ~/.cache/zsh/git-prompt
|
||||||
-o ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "git-prompt was not compiled, is a C99 toolchain installed?"
|
echo "git-prompt was not compiled, is a C99 toolchain installed?"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#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'
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
@@ -46,33 +46,7 @@ notify() {
|
|||||||
# Send a desktop notification when long running commands complete.
|
# Send a desktop notification when long running commands complete.
|
||||||
notify_command_threshold=60
|
notify_command_threshold=60
|
||||||
notify_ignore_list=(
|
notify_ignore_list=(
|
||||||
bash
|
cmatrix gh git glab man nvim ping ssh sudo sudoedit tmux vi vim
|
||||||
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() {
|
notify-ignore() {
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
#compdef worktree
|
|
||||||
|
|
||||||
__worktree_branches() {
|
|
||||||
local -a branches
|
|
||||||
branches=(
|
|
||||||
${(fo)"$(git branch --format='%(refname:short)' 2>/dev/null)"}
|
|
||||||
${${${${(fo)"$(git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null)"}#refs/remotes/}#*/}:#HEAD}
|
|
||||||
)
|
|
||||||
_describe 'branch' branches
|
|
||||||
}
|
|
||||||
|
|
||||||
__worktree_active_branches() {
|
|
||||||
local -a branches
|
|
||||||
branches=(${(fo)"$(git worktree list --porcelain 2>/dev/null | \
|
|
||||||
awk '/^worktree /{ wt++ } wt>1 && /^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); print }')"})
|
|
||||||
_describe 'branch' branches
|
|
||||||
}
|
|
||||||
|
|
||||||
__worktree_all_branches() {
|
|
||||||
local -a branches
|
|
||||||
branches=(${(fo)"$(git worktree list --porcelain 2>/dev/null | \
|
|
||||||
awk '/^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); print }')"})
|
|
||||||
_describe 'branch' branches
|
|
||||||
}
|
|
||||||
|
|
||||||
_worktree() {
|
|
||||||
local context curcontext="$curcontext" state line
|
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
|
||||||
'1: :->cmd' \
|
|
||||||
'*:: :->args'
|
|
||||||
|
|
||||||
case $state in
|
|
||||||
(cmd)
|
|
||||||
local commands; commands=(
|
|
||||||
'add:Create a worktree for a branch'
|
|
||||||
'cd:Change directory to a worktree by branch'
|
|
||||||
'list:List managed worktrees'
|
|
||||||
'ls:List managed worktrees'
|
|
||||||
'remove:Remove a worktree by branch'
|
|
||||||
'rm:Remove a worktree by branch'
|
|
||||||
'sync:Sync copied files from root to worktrees'
|
|
||||||
)
|
|
||||||
_describe -t commands 'worktree command' commands "$@"
|
|
||||||
;;
|
|
||||||
(args)
|
|
||||||
curcontext="${curcontext%:*:*}:worktree-cmd-$words[1]:"
|
|
||||||
case $line[1] in
|
|
||||||
(add)
|
|
||||||
_arguments '1:: :__worktree_branches'
|
|
||||||
;;
|
|
||||||
(cd)
|
|
||||||
_arguments '1:: :__worktree_all_branches'
|
|
||||||
;;
|
|
||||||
(rm|remove)
|
|
||||||
_arguments \
|
|
||||||
'(-f --force)'{-f,--force}'[Force removal even with modified or untracked files]' \
|
|
||||||
'*:: :__worktree_active_branches'
|
|
||||||
;;
|
|
||||||
(sync)
|
|
||||||
_arguments '*:: :__worktree_active_branches'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_worktree "$@"
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
worktree() {
|
|
||||||
if [[ "$1" == "" ]]; then
|
|
||||||
echo "usage: worktree {add,cd,list,remove,sync} <branch> [<branch>...]"
|
|
||||||
return 1
|
|
||||||
elif [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
|
|
||||||
echo "usage: worktree {add,cd,list,remove,sync} <branch> [<branch>...]
|
|
||||||
|
|
||||||
Manage git worktrees by branch name."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local cmd=$1
|
|
||||||
local branch=$2
|
|
||||||
|
|
||||||
if ! git rev-parse --git-dir &>/dev/null; then
|
|
||||||
print -P "%F{red}error:%f not a git repository"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$cmd" != "cd" ]] && \
|
|
||||||
[[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]] && \
|
|
||||||
[[ "$(git rev-parse --absolute-git-dir)" != "$(git rev-parse --show-toplevel)/.git" ]]
|
|
||||||
then
|
|
||||||
print -P "%F{red}error:%f must be run from the main clone, not a worktree"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $cmd in
|
|
||||||
add)
|
|
||||||
if [[ -z "$branch" ]]; then
|
|
||||||
print -P "%F{red}error:%f missing <branch> argument"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
local root=$(git rev-parse --show-toplevel)
|
|
||||||
local wt_dest=${root:h}/${root:t}@${branch}
|
|
||||||
if ! git show-ref --verify --quiet refs/heads/"$branch" && \
|
|
||||||
! git show-ref --verify --quiet refs/remotes/origin/"$branch"; then
|
|
||||||
git branch "$branch" origin/main || return 1
|
|
||||||
fi
|
|
||||||
git worktree add "$wt_dest" "$branch" || return 1
|
|
||||||
if [ -f $root/.enter ] && [ -f $root/.exit ]; then
|
|
||||||
cp $root/.enter $wt_dest/.enter
|
|
||||||
cp $root/.exit $wt_dest/.exit
|
|
||||||
_autoenv_authorized $wt_dest/.enter yes
|
|
||||||
_autoenv_authorized $wt_dest/.exit yes
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
cd)
|
|
||||||
if [[ -z "$branch" ]]; then
|
|
||||||
print -P "%F{red}error:%f missing <branch> argument"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
local wt_path
|
|
||||||
wt_path=$(git worktree list --porcelain | awk -v b="$branch" \
|
|
||||||
'/^worktree /{ sub(/^worktree /, ""); p=$0 } /^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); if($0==b) print p }')
|
|
||||||
if [[ -z "$wt_path" ]]; then
|
|
||||||
print -P "%F{red}error:%f no worktree for branch: $branch"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
cd "$wt_path"
|
|
||||||
;;
|
|
||||||
list|ls)
|
|
||||||
local root=$(git rev-parse --show-toplevel)
|
|
||||||
local prefix="${root:h}/${root:t}@"
|
|
||||||
git worktree list --porcelain | awk -v prefix="$prefix" '
|
|
||||||
/^worktree /{ sub(/^worktree /, ""); p=$0 }
|
|
||||||
/^branch refs\/heads\//{ if(index(p, prefix)==1) { sub(/^branch refs\/heads\//, ""); print } }
|
|
||||||
'
|
|
||||||
;;
|
|
||||||
rm|remove)
|
|
||||||
local force=0
|
|
||||||
local branches=()
|
|
||||||
local arg
|
|
||||||
for arg in "${@:2}"; do
|
|
||||||
case "$arg" in
|
|
||||||
-f|--force) force=1 ;;
|
|
||||||
*) branches+=("$arg") ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
if (( ${#branches[@]} == 0 )); then
|
|
||||||
print -P "%F{red}error:%f missing <branch> argument"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
local root=$(git rev-parse --show-toplevel)
|
|
||||||
local wt_list
|
|
||||||
wt_list=$(git worktree list --porcelain)
|
|
||||||
local failed=0
|
|
||||||
local wt_path
|
|
||||||
for branch in "${branches[@]}"; do
|
|
||||||
wt_path=$(echo "$wt_list" | awk -v b="$branch" \
|
|
||||||
'/^worktree /{ sub(/^worktree /, ""); p=$0 } /^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); if($0==b) print p }')
|
|
||||||
if [[ -z "$wt_path" ]]; then
|
|
||||||
print -P "%F{yellow}warning:%f no worktree for branch: $branch"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if [[ -f "$wt_path/BUILD" ]] || [[ -f "$wt_path/WORKSPACE" ]]; then
|
|
||||||
if (( $+commands[bazel] )); then
|
|
||||||
bazel --output_base="$wt_path" clean --expunge
|
|
||||||
elif [[ -x "$wt_path/bazelw" ]]; then
|
|
||||||
"$wt_path/bazelw" clean --expunge
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
local -a rm_args=()
|
|
||||||
(( force )) && rm_args+=(--force)
|
|
||||||
if ! git worktree remove "${rm_args[@]}" "$wt_path"; then
|
|
||||||
failed=1
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
local parent=${wt_path:h}
|
|
||||||
while [[ "$parent" != "${root:h}" ]] && [[ -d "$parent" ]]; do
|
|
||||||
rmdir "$parent" 2>/dev/null || break
|
|
||||||
parent=${parent:h}
|
|
||||||
done
|
|
||||||
done
|
|
||||||
return $failed
|
|
||||||
;;
|
|
||||||
sync)
|
|
||||||
local root=$(git rev-parse --show-toplevel)
|
|
||||||
local prefix="${root:h}/${root:t}@"
|
|
||||||
local wt_list
|
|
||||||
wt_list=$(git worktree list --porcelain)
|
|
||||||
local branches=("${@:2}")
|
|
||||||
if (( ${#branches[@]} == 0 )); then
|
|
||||||
branches=("${(@f)$(echo "$wt_list" | awk -v prefix="$prefix" '
|
|
||||||
/^worktree /{ sub(/^worktree /, ""); p=$0 }
|
|
||||||
/^branch refs\/heads\//{ if(index(p, prefix)==1) { sub(/^branch refs\/heads\//, ""); print } }
|
|
||||||
')}")
|
|
||||||
fi
|
|
||||||
local failed=0
|
|
||||||
local wt_path
|
|
||||||
for branch in "${branches[@]}"; do
|
|
||||||
[[ -z "$branch" ]] && continue
|
|
||||||
wt_path=$(echo "$wt_list" | awk -v b="$branch" \
|
|
||||||
'/^worktree /{ sub(/^worktree /, ""); p=$0 } /^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); if($0==b) print p }')
|
|
||||||
if [[ -z "$wt_path" ]]; then
|
|
||||||
print -P "%F{yellow}warning:%f no worktree for branch: $branch"
|
|
||||||
failed=1
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if [[ "$wt_path" == "$root" ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
for f in .enter .exit; do
|
|
||||||
[[ -f "$root/$f" ]] || continue
|
|
||||||
if [[ -L "$wt_path/$f" ]]; then
|
|
||||||
rm "$wt_path/$f"
|
|
||||||
elif [[ -f "$wt_path/$f" ]] && cmp -s "$root/$f" "$wt_path/$f"; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
cp "$root/$f" "$wt_path/$f"
|
|
||||||
_autoenv_authorized "$wt_path/$f" yes
|
|
||||||
print -P "%F{green}updated:%f $wt_path/$f"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
return $failed
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print -P "%F{red}error:%f unknown command: $cmd"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
55
zshenv
55
zshenv
@@ -2,16 +2,9 @@
|
|||||||
# contain commands that produce output or assume the shell is attached to a
|
# contain commands that produce output or assume the shell is attached to a
|
||||||
# tty. This file will always be sourced.
|
# 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
|
# Enable saving command history to file
|
||||||
HISTFILE=${XDG_STATE_HOME:-$HOME/.local/state}/zsh/histfile
|
[ ! -d $HOME/.cache/zsh ] && mkdir -p $HOME/.cache/zsh
|
||||||
|
HISTFILE=$HOME/.cache/zsh/histfile
|
||||||
HISTSIZE=20000
|
HISTSIZE=20000
|
||||||
SAVEHIST=20000
|
SAVEHIST=20000
|
||||||
|
|
||||||
@@ -21,6 +14,12 @@ KEYTIMEOUT=1
|
|||||||
# Enable time stats for long lasting commands
|
# Enable time stats for long lasting commands
|
||||||
REPORTTIME=5
|
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
|
# Add ccache compiler aliases to PATH and use XDG base dir paths
|
||||||
if [ `uname` = Darwin ]; then
|
if [ `uname` = Darwin ]; then
|
||||||
if [ `uname -m` = arm64 ]; then
|
if [ `uname -m` = arm64 ]; then
|
||||||
@@ -41,20 +40,13 @@ elif [ -f /usr/bin/ccache ]; then
|
|||||||
PATH=/usr/lib/ccache:$PATH
|
PATH=/usr/lib/ccache:$PATH
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
export CCACHE_CONFIGPATH=${XDG_CONFIG_HOME:-$HOME/.config}/ccache
|
export CCACHE_CONFIGPATH=$HOME/.config/ccache
|
||||||
export CCACHE_DIR=${XDG_CACHE_HOME:-$HOME/.cache}/ccache
|
export CCACHE_DIR=$HOME/.cache/ccache
|
||||||
|
|
||||||
# Add ~/.local to the environment
|
# Add default CMake generator
|
||||||
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 && \
|
command -v ninja &> /dev/null && \
|
||||||
export CMAKE_GENERATOR=Ninja
|
export CMAKE_GENERATOR=Ninja
|
||||||
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
|
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
export CMAKE_COLOR_DIAGNOSTICS=ON
|
|
||||||
|
|
||||||
# Remove duplicates from environment variables
|
# Remove duplicates from environment variables
|
||||||
typeset -U fpath
|
typeset -U fpath
|
||||||
@@ -65,8 +57,6 @@ typeset -U INFOPATH; export INFOPATH
|
|||||||
# Set default editor.
|
# Set default editor.
|
||||||
if command -v nvim &> /dev/null; then
|
if command -v nvim &> /dev/null; then
|
||||||
export EDITOR=`command -v nvim`
|
export EDITOR=`command -v nvim`
|
||||||
# Also use nvim for man pages
|
|
||||||
export MANPAGER='nvim +Man!'
|
|
||||||
elif command -v vim &> /dev/null; then
|
elif command -v vim &> /dev/null; then
|
||||||
export EDITOR=`command -v vim`
|
export EDITOR=`command -v vim`
|
||||||
fi
|
fi
|
||||||
@@ -111,29 +101,22 @@ command -v pinentry-curses &> /dev/null && \
|
|||||||
export LPASS_PINENTRY=pinentry-curses
|
export LPASS_PINENTRY=pinentry-curses
|
||||||
|
|
||||||
# Teach these some XDG Base Directory Spec manners
|
# Teach these some XDG Base Directory Spec manners
|
||||||
export IPYTHONDIR=${XDG_CONFIG_HOME:-$HOME/.config}/ipython
|
export IPYTHONDIR=$HOME/.config/ipython
|
||||||
command -v cargo &> /dev/null && \
|
command -v cargo &> /dev/null && \
|
||||||
export CARGO_HOME=$HOME/.local/share/cargo
|
export CARGO_HOME=$HOME/.local/share/cargo
|
||||||
if command -v ccache &> /dev/null; then
|
if command -v ccache &> /dev/null; then
|
||||||
export CCACHE_CONFIGPATH=${XDG_CONFIG_HOME:-$HOME/.config}/ccache.conf
|
export CCACHE_CONFIGPATH=$HOME/.config/ccache.conf
|
||||||
export CCACHE_DIR=${XDG_CACHE_HOME:-$HOME/.cache}/ccache
|
export CCACHE_DIR=$HOME/.cache/ccache
|
||||||
fi
|
fi
|
||||||
command -v conan &> /dev/null && \
|
command -v conan &> /dev/null && \
|
||||||
export CONAN_USER_HOME=$HOME/.local/share/conan
|
export CONAN_USER_HOME=$HOME/.local/share/conan
|
||||||
command -v docker &> /dev/null && \
|
command -v docker &> /dev/null && \
|
||||||
export DOCKER_CONFIG=$HOME/.local/share/docker
|
export DOCKER_CONFIG=$HOME/.local/share/docker
|
||||||
export GTK_RC_FILES=${XDG_CONFIG_HOME:-$HOME/.config}/gtk/gtkrc
|
export GTK_RC_FILES=$HOME/.config/gtk/gtkrc
|
||||||
export GTK2_RC_FILES=${XDG_CONFIG_HOME:-$HOME/.config}/gtk-2.0/gtkrc
|
export GTK2_RC_FILES=$HOME/.config/gtk-2.0/gtkrc
|
||||||
export PYLINTHOME=${XDG_CACHE_HOME:-$HOME/.cache}/pylint
|
export PYLINTHOME=$HOME/.cache/pylint
|
||||||
command -v rustup &> /dev/null && \
|
command -v rustup &> /dev/null && \
|
||||||
export RUSTUP_HOME=$HOME/.local/share/rustup
|
export RUSTUP_HOME=$HOME/.local/share/rustup
|
||||||
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc ] && \
|
[ -f $HOME/.config/wget/rc ] && \
|
||||||
export WGETRC=${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc
|
export WGETRC=$HOME/.config/wget/rc
|
||||||
# TODO: terminfo
|
# 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
|
|
||||||
|
|||||||
27
zshrc
27
zshrc
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
# Load plugin scripts
|
# Load plugin scripts
|
||||||
source-plugin() {
|
source-plugin() {
|
||||||
local shared_plugin=${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/$1/$1.plugin.zsh
|
local shared_plugin=~/.local/share/zsh/plugins/$1/$1.plugin.zsh
|
||||||
local local_plugin=${XDG_CONFIG_HOME:-$HOME/.config}/zsh/$1/$1.plugin.zsh
|
local local_plugin=~/.config/zsh/$1/$1.plugin.zsh
|
||||||
if [ -f $shared_plugin ]; then
|
if [ -f $shared_plugin ]; then
|
||||||
source $shared_plugin
|
source $shared_plugin
|
||||||
elif [ -f $local_plugin ]; then
|
elif [ -f $local_plugin ]; then
|
||||||
@@ -41,18 +41,12 @@ source-plugin utilities
|
|||||||
# Automatically source .enter and .exit scripts on cd
|
# Automatically source .enter and .exit scripts on cd
|
||||||
source-plugin autoenv
|
source-plugin autoenv
|
||||||
|
|
||||||
# Session manager
|
|
||||||
source-plugin session
|
|
||||||
|
|
||||||
# Layout tmux window commands
|
# Layout tmux window commands
|
||||||
[ "$TMUX" != "" ] && source-plugin layout
|
[ "$TMUX" != "" ] && source-plugin layout
|
||||||
|
|
||||||
# Note taking commands
|
# Note taking commands
|
||||||
source-plugin notes
|
source-plugin notes
|
||||||
|
|
||||||
# git worktree helper
|
|
||||||
source-plugin worktree
|
|
||||||
|
|
||||||
# Remove duplicates from history
|
# Remove duplicates from history
|
||||||
setopt histignoredups
|
setopt histignoredups
|
||||||
|
|
||||||
@@ -79,7 +73,7 @@ setopt completeinword
|
|||||||
|
|
||||||
# Initialize completions
|
# Initialize completions
|
||||||
autoload -U compinit
|
autoload -U compinit
|
||||||
compinit -d ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/compdump
|
compinit -d ~/.cache/zsh/compdump
|
||||||
|
|
||||||
# Add pip to the old completion engine if present
|
# Add pip to the old completion engine if present
|
||||||
if command -v pip &> /dev/null; then
|
if command -v pip &> /dev/null; then
|
||||||
@@ -195,19 +189,14 @@ frequent-directory Documents "$HOME/Documents"
|
|||||||
frequent-directory Downloads "$HOME/Downloads"
|
frequent-directory Downloads "$HOME/Downloads"
|
||||||
frequent-directory Projects "$HOME/Projects"
|
frequent-directory Projects "$HOME/Projects"
|
||||||
frequent-directory Sandbox "$HOME/Sandbox"
|
frequent-directory Sandbox "$HOME/Sandbox"
|
||||||
frequent-directory cache "${XDG_CACHE_HOME:-$HOME/.cache}"
|
frequent-directory cache "$HOME/.cache"
|
||||||
frequent-directory config "${XDG_CONFIG_HOME:-$HOME/.config}"
|
frequent-directory config "$HOME/.config"
|
||||||
frequent-directory local "$HOME/.local"
|
frequent-directory local "$HOME/.local"
|
||||||
|
|
||||||
# Load work related config
|
# Load work related config
|
||||||
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/work/zshrc ] && \
|
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
|
||||||
source ${XDG_CONFIG_HOME:-$HOME/.config}/work/zshrc
|
[ -f ~/.config/private/zshrc ] && source ~/.config/private/zshrc
|
||||||
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/private/zshrc ] && \
|
[ -f ~/.config/zsh/local ] && source ~/.config/zsh/local
|
||||||
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
|
# Aliases
|
||||||
alias grep='grep --color=always'
|
alias grep='grep --color=always'
|
||||||
|
|||||||
Reference in New Issue
Block a user