Compare commits
	
		
			4 Commits
		
	
	
		
			main
			...
			559012b3fe
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 559012b3fe | |||
| 259a576d7e | |||
| ab0ce2f188 | |||
| 2d1a6f69fd | 
							
								
								
									
										8
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @ -2,6 +2,10 @@ | |||||||
| 	path = plugins/zsh-history-substring-search | 	path = plugins/zsh-history-substring-search | ||||||
| 	url = https://github.com/zsh-users/zsh-history-substring-search.git | 	url = https://github.com/zsh-users/zsh-history-substring-search.git | ||||||
|     ignore = untracked |     ignore = untracked | ||||||
|  | [submodule "zsh-syntax-highlighting"] | ||||||
|  | 	path = plugins/zsh-syntax-highlighting | ||||||
|  | 	url = https://github.com/zsh-users/zsh-syntax-highlighting.git | ||||||
|  |     ignore = untracked | ||||||
| [submodule "zsh-autosuggestions"] | [submodule "zsh-autosuggestions"] | ||||||
| 	path = plugins/zsh-autosuggestions | 	path = plugins/zsh-autosuggestions | ||||||
| 	url = https://github.com/zsh-users/zsh-autosuggestions.git | 	url = https://github.com/zsh-users/zsh-autosuggestions.git | ||||||
| @ -14,7 +18,3 @@ | |||||||
| 	path = plugins/fzf-tab | 	path = plugins/fzf-tab | ||||||
| 	url = https://github.com/Aloxaf/fzf-tab.git | 	url = https://github.com/Aloxaf/fzf-tab.git | ||||||
|     ignore = dirty |     ignore = dirty | ||||||
| [submodule "fast-syntax-highlighting"] |  | ||||||
| 	path = plugins/fast-syntax-highlighting |  | ||||||
| 	url = https://github.com/zdharma-continuum/fast-syntax-highlighting.git |  | ||||||
|     ignore = untracked |  | ||||||
|  | |||||||
							
								
								
									
										55
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								README.md
									
									
									
									
									
								
							| @ -4,10 +4,8 @@ This is my personal zsh configuraton. | |||||||
| ### Requirements | ### Requirements | ||||||
| * [starship](https://github.com/starship/starship) - a pretty and fast prompt | * [starship](https://github.com/starship/starship) - a pretty and fast prompt | ||||||
| * [direnv](https://github.com/direnv/direnv)* - runs on cd, safely set enviroment | * [direnv](https://github.com/direnv/direnv)* - runs on cd, safely set enviroment | ||||||
| * [eza](https://github.com/eza-community/eza)* - better ls | * [exa](https://github.com/ogham/exa)* - better ls | ||||||
| * [bat](https://github.com/sharkdp/bat)* - better cat, less, man, etc. | * [bat](https://github.com/sharkdp/bat)* - better cat, less, man, etc. | ||||||
| * [trash-cli](https://github.com/andreafrancia/trash-cli)* - safer deletion |  | ||||||
| * [fzf](https://github.com/junegunn/fzf)* - better auto-complete |  | ||||||
|  |  | ||||||
| (* = optional) | (* = optional) | ||||||
|  |  | ||||||
| @ -26,48 +24,13 @@ source "${ZSH_CONFIG_DIR}/init.zsh" | |||||||
|  * ZSH_BOOKMARK_DIR: Bookmark directory (default: ~/.cache/zsh/bookmarks) |  * ZSH_BOOKMARK_DIR: Bookmark directory (default: ~/.cache/zsh/bookmarks) | ||||||
|  * ZSH_BOOKMARK_LS: If true, run `ls` after jumping to a bookmark (default: |  * ZSH_BOOKMARK_LS: If true, run `ls` after jumping to a bookmark (default: | ||||||
|    true) |    true) | ||||||
|  * ZSH_GRAPHICAL_LOGIN: Whether or not to enable starting a graphical session |  * ZSH_USER_DIR: Directory containing configuration files (see below, default: | ||||||
|    when a login shell is started (default: true) |    ~/.zsh.d) | ||||||
|     |  | ||||||
| ### Aliases |  | ||||||
| I use a lot of aliases. Because a lot of the aliases are only enabled if the |  | ||||||
| corresponding piece of software is installed (see above), it is hard to give a |  | ||||||
| full list. Therefore you should think of the following list as a guide and read |  | ||||||
| `init.zsh` if you want a full list. |  | ||||||
|  * `ls`: eza --git -F |  | ||||||
|  * `la`: eza --git -Fa |  | ||||||
|  * `l`: eza --git -Fl  |  | ||||||
|  * `ll`: eza --git -Fla  |  | ||||||
|  * `cat`: bat --paging=never |  | ||||||
|  * `pcat`: bat -pp |  | ||||||
|  * `ncat`: bat -pp --color=never |  | ||||||
|  * `e`: emacsclient -a nvim -nw |  | ||||||
|  * `n`: emacsclient -a nvim -nw |  | ||||||
|  * `emacs`: emacsclient -a nvim -nw |  | ||||||
|  * `d`: *start dired in either the current or provided directory* |  | ||||||
|  * `dired`: *start dired in either the current or provided directory* |  | ||||||
|  * `se`: sudoedit |  | ||||||
|  * `mv`: mv -i |  | ||||||
|  * `cp`: cp -i |  | ||||||
|  * `rm`: *disabled if trash-cli is installed* |  | ||||||
|  * `tp`: trash-put |  | ||||||
|  * `trr`: trash-restore |  | ||||||
|  * `trl`: trash-list |  | ||||||
|  * `tre`: trash-empty |  | ||||||
|  * `trm`: trash-rm |  | ||||||
|  * `gt`: git status |  | ||||||
|  * `ga`: git add |  | ||||||
|  * `gaa`: git add -A |  | ||||||
|  * `gc`: git commit |  | ||||||
|  * `gf`: git fetch |  | ||||||
|  * `gu`: git pull |  | ||||||
|  * `gp`: git push |  | ||||||
|  * `gcm`: *git commit -m, but treat all following args as the message (like echo)* |  | ||||||
|  * `gacm`: *git commit -am, but treat all following args as the message (like echo)* |  | ||||||
|   |  | ||||||
|  |  | ||||||
| ###  Configuration | ###  Configuration | ||||||
| Previous versions of this configuration supported files that were not under | To configure, create `~/.zsh.d` (or set ZSH_USER_DIR as described above). The | ||||||
| version control to be run during initialization of the shell. However the | create either of the option files `init.zsh` and `early-init.zsh`. The former is | ||||||
| current version does not support this. Configuring the shell requires editing | run in the middle of startup, after most plugins have been initialized, but | ||||||
| either `init.zsh` or `early-init.zsh`. | before ones related to command history, auto-complete, etc. The latter is run as | ||||||
|  | the first thing in the configuration file (after `autoload -U compinit && | ||||||
|  | compinit`). | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								arch.zsh
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								arch.zsh
									
									
									
									
									
								
							| @ -1,6 +1,3 @@ | |||||||
| # Arch specific config options | # Arch specific config options | ||||||
| function () { | export DEBUGINFOD_URLS="https://debuginfod.archlinux.org" | ||||||
|     emulate -L sh |  | ||||||
|     source "/etc/profile.d/debuginfod.sh" |  | ||||||
| } |  | ||||||
| source "/usr/share/doc/pkgfile/command-not-found.zsh" | source "/usr/share/doc/pkgfile/command-not-found.zsh" | ||||||
|  | |||||||
							
								
								
									
										73
									
								
								bookmark.zsh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								bookmark.zsh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,73 @@ | |||||||
|  | # A simple bookmark system | ||||||
|  | # $ZSH_BOOKMARK_DIR must be defined | ||||||
|  |  | ||||||
|  | # Create bookmark directory if it does not exist | ||||||
|  | [ ! -d "${ZSH_BOOKMARK_DIR}" ] && mkdir -p "${ZSH_BOOKMARK_DIR}" | ||||||
|  | function __zsh_list_bookmarks { | ||||||
|  |     /bin/ls "${ZSH_BOOKMARK_DIR}" | ||||||
|  | } | ||||||
|  | function __zsh_check_bookmark_name { | ||||||
|  |     ! [[ "${1}" == *'/'* ]] | ||||||
|  | } | ||||||
|  | function _bookmarks { | ||||||
|  |     for file in "${ZSH_BOOKMARK_DIR}/"*; do | ||||||
|  |         compadd "${file#"${ZSH_BOOKMARK_DIR}/"}" | ||||||
|  |     done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # bm <bookmark> | ||||||
|  | function bm { | ||||||
|  |     # With no args, list all bookmarks | ||||||
|  |     [ "${#}" -eq 0 ] && { __zsh_list_bookmarks; return } | ||||||
|  |     # Otherwise, goto the bookmark in argv[1] | ||||||
|  |     __zsh_check_bookmark_name "${1}" || { echo "No such bookmark: '${1}'!"; return 1 } | ||||||
|  |     [ -L "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "No such bookmark: '${1}'!"; return 1 } | ||||||
|  |     [ -e "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "The bookmark '${1}' refers to a non-existant file!"; return 1 } | ||||||
|  |     cd -P "${ZSH_BOOKMARK_DIR}/${1}" | ||||||
|  |     [[ -v ZSH_BOOKMARK_LS ]] && "${ZSH_BOOKMARK_LS}" && ls | ||||||
|  | } | ||||||
|  | function _bm { | ||||||
|  |     _arguments '::bookmark:_bookmarks' | ||||||
|  | } | ||||||
|  | compdef _bm bm | ||||||
|  |  | ||||||
|  | # bmadd [name] [dir] | ||||||
|  | function bmadd { | ||||||
|  |     # With no args, add pwd | ||||||
|  |     [ "${#}" -eq 0 ] && { bmadd "$(basename "${PWD}")" "${PWD}"; return } | ||||||
|  |     # With one arg, add pwd as argv[1] | ||||||
|  |     [ "${#}" -eq 1 ] && { bmadd "${1}" "${PWD}"; return } | ||||||
|  |     local real_path="$(realpath "${2}")" | ||||||
|  |     local bm_name="${1}" | ||||||
|  |     __zsh_check_bookmark_name "${bm_name}" || { echo "Invalid bookmark: '${1}'!"; return 1 } | ||||||
|  |     if [ -L "${ZSH_BOOKMARK_DIR}/${bm_name}" ]; then | ||||||
|  |         echo "A bookmark with the name '${bm_name}' already exists!" | ||||||
|  |         local reply | ||||||
|  |         read -q 'reply?Overwrite? [y/N] ' | ||||||
|  |         printf '\n' | ||||||
|  |         [[ "${reply}" =~ '[yY]' ]] || return 1 | ||||||
|  |     fi | ||||||
|  |     ln -nfs "${real_path}" "${ZSH_BOOKMARK_DIR}/${bm_name}" | ||||||
|  |     echo "Created bookmark '${bm_name}'" | ||||||
|  | } | ||||||
|  | function _bmadd { | ||||||
|  |     _arguments ':name' '::directory:_directories' | ||||||
|  | } | ||||||
|  | compdef _bmadd bmadd | ||||||
|  |  | ||||||
|  | # bmrm <name> | ||||||
|  | function bmrm { | ||||||
|  |     [ "${#}" -eq 0 ] && { echo "usage: bmrm <name>"; return 1 } | ||||||
|  |     __zsh_check_bookmark_name "${1}" || { echo "No bookmark with the name '${1}' exists!"; return 1 } | ||||||
|  |     [ -L "${ZSH_BOOKMARK_DIR}/${1}" ] || { echo "No bookmark with the name '${1}' exists!"; return 1 } | ||||||
|  |     local reply | ||||||
|  |     read -q 'reply?Really delete? [y/N] ' | ||||||
|  |     printf '\n' | ||||||
|  |     [[ "${reply}" =~ '[yY]' ]] || return 1 | ||||||
|  |     /bin/rm "${ZSH_BOOKMARK_DIR}/${1}" | ||||||
|  |     echo "Deleted bookmark '${1}'" | ||||||
|  | } | ||||||
|  | function _bmrm { | ||||||
|  |     _arguments ':bookmark:_bookmarks' | ||||||
|  | } | ||||||
|  | compdef _bmrm bmrm | ||||||
							
								
								
									
										54
									
								
								clean-home.zsh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								clean-home.zsh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,54 @@ | |||||||
|  | # XDG standard | ||||||
|  | export XDG_DATA_HOME="${HOME}/.local/share" | ||||||
|  | export XDG_CONFIG_HOME="${HOME}/.config" | ||||||
|  | export XDG_STATE_HOME="${HOME}/.local/state" | ||||||
|  | export XDG_CACHE_HOME="${HOME}/.cache" | ||||||
|  |  | ||||||
|  | # Android studio and cli | ||||||
|  | export ANDROID_HOME="${XDG_DATA_HOME}/android" | ||||||
|  |  | ||||||
|  | # Cargo | ||||||
|  | export CARGO_HOME="${XDG_DATA_HOME}/cargo" | ||||||
|  |  | ||||||
|  | # Cuda cache | ||||||
|  | export CUDA_CACHE_PATH="${XDG_CACHE_HOME}/nv" | ||||||
|  |  | ||||||
|  | # GnuPG | ||||||
|  | export GNUPGHOME="${XDG_DATA_HOME}/gnupg" | ||||||
|  |  | ||||||
|  | # Go | ||||||
|  | export GOPATH="${XDG_DATA_HOME}/go" | ||||||
|  |  | ||||||
|  | # Gradle | ||||||
|  | export GRADLE_USER_HOME="${XDG_DATA_HOME}/gradle" | ||||||
|  |  | ||||||
|  | # GTK2 | ||||||
|  | export GTK2_RC_FILES="${XDG_CONFIG_HOME}/gtk-2.0/gtkrc" | ||||||
|  |  | ||||||
|  | # Less history | ||||||
|  | [[ -d "${XDG_CACHE_HOME}/less" ]] || mkdir "${XDG_CACHE_HOME}/less" | ||||||
|  | export LESSHISTFILE="${XDG_CACHE_HOME}/less/history" | ||||||
|  |  | ||||||
|  | # Maxima | ||||||
|  | export MAXIMA_USERDIR="${XDG_CONFIG_HOME}/maxima" | ||||||
|  |  | ||||||
|  | # NPM | ||||||
|  | export NPM_CONFIG_USERCONFIG="${XDG_CONFIG_HOME}/npm/npmrc" | ||||||
|  |  | ||||||
|  | # Pass | ||||||
|  | export PASSWORD_STORE_DIR="${XDG_DATA_HOME}/pass" | ||||||
|  |  | ||||||
|  | # Python and python history | ||||||
|  | export PYTHONSTARTUP="${XDG_CONFIG_HOME}/python/pythonrc" | ||||||
|  |  | ||||||
|  | # SQLite history | ||||||
|  | export SQLITE_HISTORY="${XDG_CACHE_HOME}/sqlite_history" | ||||||
|  |  | ||||||
|  | # Wine | ||||||
|  | export WINEPREFIX="${XDG_DATA_HOME}/wine" | ||||||
|  |  | ||||||
|  | # XAuthority | ||||||
|  | export XAUTHORITY="${XDG_RUNTIME_DIR}/Xauthority" | ||||||
|  |  | ||||||
|  | # Minetest | ||||||
|  | export MINETEST_USER_PATH="${XDG_DATA_HOME}/minetest" | ||||||
| @ -1,18 +0,0 @@ | |||||||
| # Some extra environment variables |  | ||||||
| export PATH="${HOME}/.local/bin:${PATH}" |  | ||||||
| export LD_LIBRARY_PATH="${HOME}/.local/lib:${LD_LIBRARY_PATH}" |  | ||||||
| export PKG_CONFIG_PATH="${HOME}/.local/lib/pkgconfig:${PKG_CONFIG_PATH}" |  | ||||||
|  |  | ||||||
| # Because I use zsh to start graphical sessions |  | ||||||
| [[ -v ZSH_GRAPHICAL_LOGIN ]] || ZSH_GRAPHICAL_LOGIN=true |  | ||||||
| if [[ -o login ]] && [[ "${ZSH_GRAPHICAL_LOGIN}" = 'true' ]] ; then |  | ||||||
|     export LC_ALL=en_US.UTF-8 |  | ||||||
|     eval "$(gnome-keyring-daemon --start 2>/dev/null)" |  | ||||||
|     export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/gcr/ssh" |  | ||||||
|     export SSH_ASKPASS=/usr/lib/seahorse/ssh-askpass |  | ||||||
|  |  | ||||||
|     if ! [[ -v WAYLAND_DISPLAY ]] && [ "${XDG_VTNR}" -eq 1 ]; then |  | ||||||
|         source "${HOME}/.config/river/river-env.sh" |  | ||||||
|         exec river |  | ||||||
|     fi |  | ||||||
| fi |  | ||||||
| @ -1,300 +0,0 @@ | |||||||
| # Emacs-based bookmark system |  | ||||||
|  |  | ||||||
| autoload colors && colors |  | ||||||
| zmodload -F zsh/stat b:zstat |  | ||||||
| zmodload zsh/datetime |  | ||||||
| zmodload zsh/mapfile |  | ||||||
|  |  | ||||||
| local __bm_bookmark_cache=() |  | ||||||
| let __bm_last_read_time=-1 |  | ||||||
|  |  | ||||||
| function __bm_offset_to_row_col { |  | ||||||
|     let off="${2}" |  | ||||||
|     let row=1 |  | ||||||
|     let col=0 |  | ||||||
|     for line in "${(@f)mapfile[${1}]}"; do |  | ||||||
|         let len="${#line}" |  | ||||||
|         if (( off > len )); then |  | ||||||
|             off='off - (len + 1)' |  | ||||||
|             if (( off <= 0 )); then |  | ||||||
|                 (( len == 0 )) && col=0 || col='len - 1' |  | ||||||
|                 break |  | ||||||
|             fi |  | ||||||
|             row+=1 |  | ||||||
|         else |  | ||||||
|             col='off' |  | ||||||
|             off=0 |  | ||||||
|             break; |  | ||||||
|         fi |  | ||||||
|     done <"${1}" |  | ||||||
|     if (( off > 0 )); then |  | ||||||
|         row+=-1 |  | ||||||
|     fi |  | ||||||
|     printf '%d\0%d' "${row}" "${col}" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function __bm_find_user_emacs_dir { |  | ||||||
|     [[ -f "${HOME}/.emacs.d/var/bookmark-default.el" ]] && |  | ||||||
|         { printf '%s' "${HOME}/.emacs.d/var/bookmark-default.el"; return 0 } |  | ||||||
|     [[ -f "${HOME}/.emacs.d/bookmark-default.el" ]] && |  | ||||||
|         { printf '%s' "${HOME}/.emacs.d/bookmark-default.el"; return 0 } |  | ||||||
|     [[ -f "${HOME}/.config/emacs/var/bookmark-default.el" ]] && |  | ||||||
|         { printf '%s' "${HOME}/.config/emacs/var/bookmark-default.el"; return 0 } |  | ||||||
|     [[ -f "${HOME}/.config/emacs/bookmark-default.el" ]] && |  | ||||||
|         { printf '%s' "${HOME}/.config/emacs/bookmark-default.el"; return 0 } |  | ||||||
|     [[ -f "${XDG_CONFIG_HOME}/emacs/var/bookmark-default.el" ]] && |  | ||||||
|         { printf '%s' "${XDG_CONFIG_HOME}/emacs/var/bookmark-default.el"; return 0 } |  | ||||||
|     [[ -f "${XDG_CONFIG_HOME}/emacs/bookmark-default.el" ]] && |  | ||||||
|         { printf '%s' "${XDG_CONFIG_HOME}/emacs/bookmark-default.el"; return 0 } |  | ||||||
|     printf 'Could not discover Emacs bookmark file! Please set $BM_MODE to |  | ||||||
| "daemon" or define $BM_BOOKMARK_PATH!\n' |  | ||||||
|     return 1 |  | ||||||
| } |  | ||||||
| BM_BOOKMARK_PATH="${BM_BOOKMARK_PATH:-"$(__bm_find_user_emacs_dir)"}" |  | ||||||
|  |  | ||||||
| function __bm_hash_dirs { |  | ||||||
|     # First empty the hash table |  | ||||||
|     hash -dr |  | ||||||
|  |  | ||||||
|     # Then add the hash dirs |  | ||||||
|     for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do |  | ||||||
|         local name="${__bm_bookmark_cache[${i}]://=/}" |  | ||||||
|         hash -d "${name}=${__bm_bookmark_cache[${i} + 2]}" |  | ||||||
|     done |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function __bm_update_bookmark_list { |  | ||||||
|     __bm_last_read_time="${EPOCHSECONDS}" |  | ||||||
|     local args |  | ||||||
|     local script |  | ||||||
|     case "${BM_MODE}" in |  | ||||||
|         'daemon') |  | ||||||
|             script=$(<<'EOF' |  | ||||||
| (progn |  | ||||||
|   (require 'server) |  | ||||||
|   (dolist (entry (server-eval-at |  | ||||||
|                   "server" |  | ||||||
|                   '(when (boundp 'bookmark-alist) |  | ||||||
|                      bookmark-alist))) |  | ||||||
|     (let ((path (alist-get 'filename (cdr entry) "")) |  | ||||||
|           (pos (alist-get 'position (cdr entry) 1))) |  | ||||||
|       (princ (format "%s\0%s\0%s\0%s\0" (car entry) path |  | ||||||
|                      (expand-file-name path) pos))))) |  | ||||||
| EOF |  | ||||||
|                   ) |  | ||||||
|             ;; |  | ||||||
|         ''|'emacs') |  | ||||||
|             args="--insert=${BM_BOOKMARK_PATH}" |  | ||||||
|             script=$(<<'EOF' |  | ||||||
| (progn |  | ||||||
|   (dolist (entry (read (current-buffer))) |  | ||||||
|     (let ((path (alist-get 'filename (cdr entry) "")) |  | ||||||
|           (pos (alist-get 'position (cdr entry) 1))) |  | ||||||
|       (princ (format "%s\0%s\0%s\0%s\0" (car entry) path |  | ||||||
|                      (expand-file-name path) pos))))) |  | ||||||
| EOF |  | ||||||
|                   ) |  | ||||||
|             ;; |  | ||||||
|         *) |  | ||||||
|         printf 'Unknown value for $BM_MODE: "%s"\n' "${BM_MODE}" |  | ||||||
|         return 1 |  | ||||||
|         ;; |  | ||||||
|     esac |  | ||||||
|     __bm_bookmark_cache=(${(0)"$(command emacs --batch ${args} --eval "${script}")"}) |  | ||||||
|     __bm_hash_dirs |  | ||||||
| } |  | ||||||
| function __bm_bookmark_location { |  | ||||||
|     local parts=(${(s:/:)"${2}"}) |  | ||||||
|     local bm_name="${parts[1]}" |  | ||||||
|     local rest_arr=(${parts:1}) |  | ||||||
|     local rest="${(j:/:)rest_arr}" |  | ||||||
|     for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do |  | ||||||
|         if [[ "${bm_name}" = "${__bm_bookmark_cache[${i}]}" ]]; then |  | ||||||
|             __bm_res=("${__bm_bookmark_cache[${i} + 2]}" |  | ||||||
|                       "${__bm_bookmark_cache[${i} + 3]}" |  | ||||||
|                       "${rest}") |  | ||||||
|             return 0 |  | ||||||
|         fi |  | ||||||
|     done |  | ||||||
|     __bm_res=() |  | ||||||
|     return 1 |  | ||||||
| } |  | ||||||
| function __bm_list_bookmarks { |  | ||||||
|     for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do |  | ||||||
|         local name="${__bm_bookmark_cache[${i}]}" |  | ||||||
|         local pretty_path="${__bm_bookmark_cache[${i} + 1]}" |  | ||||||
|         local abs_path="${__bm_bookmark_cache[${i} + 2]}" |  | ||||||
|         local print_color="" |  | ||||||
|         if [[ -d "${abs_path}" ]]; then |  | ||||||
|             print_color="${bold_color}${fg[blue]}" |  | ||||||
|         fi |  | ||||||
|         printf "${print_color}%s${reset_color} => %s\n" \ |  | ||||||
|                "${name}" "${pretty_path}" |  | ||||||
|     done |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function _bookmarks { |  | ||||||
|     for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do |  | ||||||
|         compadd -q "${__bm_bookmark_cache[${i}]}" |  | ||||||
|     done |  | ||||||
| } |  | ||||||
|  |  | ||||||
| alias lsbm="__bm_update_bookmark_list && __bm_list_bookmarks" |  | ||||||
| function bm { |  | ||||||
|     __bm_update_bookmark_list || \ |  | ||||||
|         { printf 'Updating bookmark list failed!\n'; return 1 } |  | ||||||
|     (( ${#} == 0 )) && { __bm_list_bookmarks; return } |  | ||||||
|     local __bm_res |  | ||||||
|     __bm_bookmark_location __bm_res "${1}" |  | ||||||
|     local bm_loc="${__bm_res[1]}" |  | ||||||
|     local target="${__bm_res[1]}/${__bm_res[3]}" |  | ||||||
|     if (( ${#__bm_res} != 0 )) && [[ -e "${bm_loc}" ]]; then |  | ||||||
|         if [[ -d "${target}" ]]; then |  | ||||||
|             cd "${target}" |  | ||||||
|             [[ "${BM_CWD_LS}" == 'true' ]] && ls || true |  | ||||||
|         elif [[ -e "${bm_loc}" ]]; then |  | ||||||
|             let offset="${__bm_res[2]}" |  | ||||||
|             local rowcol=(${(0)"$(__bm_offset_to_row_col "${bm_loc}" "${offset}")"}) |  | ||||||
|             ${=EDITOR} "+${rowcol[1]}:${rowcol[2]}" "${bm_loc}" |  | ||||||
|         else |  | ||||||
|             printf 'Bookmark exists, but trailing path doesn'"'"'t: "%s"\n' \ |  | ||||||
|                    "${(q)__bm_res[3]}" |  | ||||||
|             return 1 |  | ||||||
|         fi |  | ||||||
|     else |  | ||||||
|         printf 'No such bookmark: "%s"\n' "${(q)1}" |  | ||||||
|         return 1 |  | ||||||
|     fi |  | ||||||
| } |  | ||||||
| function _bm { |  | ||||||
|     (( "${CURRENT}" == 2 )) || return |  | ||||||
|     local arg="${(Q)words[${CURRENT}]}" |  | ||||||
|     if ! [[ "${arg}" == */* ]]; then |  | ||||||
|         for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do |  | ||||||
|             compadd -q -S '/' -- "${__bm_bookmark_cache[${i}]}" |  | ||||||
|         done |  | ||||||
|     else |  | ||||||
|         local __bm_res |  | ||||||
|         __bm_bookmark_location __bm_res "${arg}" |  | ||||||
|         if [[ -d "${__bm_res[1]}" ]]; then |  | ||||||
|             local parts=(${(s:/:)__bm_res[3]}) |  | ||||||
|             local bm="${${(s:/:)${arg}}[1]}" |  | ||||||
|             local subdir="${(j:/:)parts[1,-2]}" |  | ||||||
|             local search="${parts[${#parts}]}" |  | ||||||
|             if ((${#parts} > 0)) && [[ "${arg}" == */ ]]; then |  | ||||||
|                 subdir="${subdir}/${search}" |  | ||||||
|                 subdir="${subdir#/}" |  | ||||||
|                 search="" |  | ||||||
|             fi |  | ||||||
|             local pre_path="${__bm_res[1]}/${subdir}/" |  | ||||||
|             local raw_arg="${words[${CURRENT}]}" |  | ||||||
|             local prefix="${${(s:/:)${raw_arg}}[1]}/${subdir}" |  | ||||||
|             if ! [[ -z "${subdir}" ]]; then |  | ||||||
|                 prefix+='/' |  | ||||||
|             fi |  | ||||||
|             compset -P "${(b)prefix}" |  | ||||||
|             for file in "${pre_path}"*; do |  | ||||||
|                 compadd -W "${pre_path}" -f "${file:t}" |  | ||||||
|             done |  | ||||||
|         fi |  | ||||||
|     fi |  | ||||||
| } |  | ||||||
| compdef _bm bm |  | ||||||
|  |  | ||||||
| function bmadd { |  | ||||||
|     if [[ "${1}" = '-h' ]]; then |  | ||||||
|         printf 'usage: bmadd [PATH] [NAME]\n' |  | ||||||
|         return 0 |  | ||||||
|     fi |  | ||||||
|     [[ "${1}" = '--' ]] && shift 1 |  | ||||||
|     local name |  | ||||||
|     local loc |  | ||||||
|     case "${#}" in |  | ||||||
|         0) |  | ||||||
|             loc="${PWD}" |  | ||||||
|             name="${PWD:t}" |  | ||||||
|             ;; |  | ||||||
|         1) |  | ||||||
|             loc="${1}" |  | ||||||
|             name="${1:t}" |  | ||||||
|             ;; |  | ||||||
|         *) |  | ||||||
|         loc="${1}" |  | ||||||
|         name="${2}" |  | ||||||
|         ;; |  | ||||||
|     esac |  | ||||||
|     __bm_update_bookmark_list |  | ||||||
|     local __bm_res |  | ||||||
|     if __bm_bookmark_location __bm_res "${name}" >/dev/null; then |  | ||||||
|         printf 'Bookmark "%s" already exists. Overwrite it? [y/N] ' "${(q)name}" |  | ||||||
|         read -q |  | ||||||
|         let ans=${?} |  | ||||||
|         printf '\n' |  | ||||||
|         (( ${ans} != 0 )) && return 1 |  | ||||||
|     fi |  | ||||||
|     local res="$(emacsclient --eval \ |  | ||||||
| "(let* ((loc (pop server-eval-args-left)) |  | ||||||
|         (name (pop server-eval-args-left)) |  | ||||||
|         (res (with-temp-buffer |  | ||||||
|                (set-visited-file-name loc t nil) |  | ||||||
|                (bookmark-set name) |  | ||||||
|                (set-buffer-modified-p nil))) |  | ||||||
|         (inhibit-message t)) |  | ||||||
|    (bookmark-save) |  | ||||||
|    res)" "${loc}" "${name}")" |  | ||||||
|     [[ "${res}" = 'nil' ]] && printf 'Added bookmark "%s"\n' "${(q)name}" \ |  | ||||||
|             || { printf '%s\n' "${res}"; return 1 } |  | ||||||
|     __bm_update_bookmark_list |  | ||||||
| } |  | ||||||
| function _bmadd { |  | ||||||
|     _arguments ':file:_files' ':name' |  | ||||||
| } |  | ||||||
| compdef _bmadd bmadd |  | ||||||
|  |  | ||||||
| function bmrm { |  | ||||||
|     if [[ "${1}" = '-h' ]]; then |  | ||||||
|         printf 'usage: bmrm [NAME]\n' |  | ||||||
|         return 0 |  | ||||||
|     fi |  | ||||||
|     [[ "${1}" = '--' ]] && shift 1 |  | ||||||
|     if (( ${#} < 1 )); then |  | ||||||
|         printf 'usage: bmrm [NAME]\n' |  | ||||||
|         return 1 |  | ||||||
|     fi |  | ||||||
|     __bm_update_bookmark_list |  | ||||||
|     local __bm_res |  | ||||||
|     __bm_bookmark_location __bm_res "${1}" >/dev/null || \ |  | ||||||
|         { printf 'No such bookmark: "%s"\n' "${1}"; return 1 } |  | ||||||
|     printf 'Really delete "%s"? [y/N] ' "${(q)1}" |  | ||||||
|     if read -q; then |  | ||||||
|         printf '\n' |  | ||||||
|         local res="$(emacsclient --eval \ |  | ||||||
| "(let* ((res (bookmark-delete (pop server-eval-args-left))) |  | ||||||
|         (inhibit-message t)) |  | ||||||
|    (bookmark-save) |  | ||||||
|    res)" "${1}")" |  | ||||||
|         [[ "${res}" = 'nil' ]] && printf 'Deleted bookmark "%s"\n' "${(q)1}" \ |  | ||||||
|                 || { printf '%s\n' "${res}"; return 1 } |  | ||||||
|  |  | ||||||
|         __bm_update_bookmark_list |  | ||||||
|     else |  | ||||||
|         printf '\n' |  | ||||||
|         return 1 |  | ||||||
|     fi |  | ||||||
| } |  | ||||||
| function _bmrm { |  | ||||||
|     _arguments ':bookmark:_bookmarks' |  | ||||||
| } |  | ||||||
| compdef _bmrm bmrm |  | ||||||
|  |  | ||||||
| function __bm_precmd_hook { |  | ||||||
|     # Auto reload |  | ||||||
|     if [[ "${BM_AUTO_RELOAD}" == true ]] && |  | ||||||
|            (( ${__bm_last_read_time} < $(zstat +mtime "${BM_BOOKMARK_PATH}") )); then |  | ||||||
|         __bm_update_bookmark_list |  | ||||||
|     fi |  | ||||||
| } |  | ||||||
| (( ${precmd_functions[(I)__bm_precmd_hook]} )) || |  | ||||||
|     precmd_functions+=(__bm_precmd_hook) |  | ||||||
|  |  | ||||||
| __bm_update_bookmark_list |  | ||||||
							
								
								
									
										292
									
								
								init.zsh
									
									
									
									
									
								
							
							
						
						
									
										292
									
								
								init.zsh
									
									
									
									
									
								
							| @ -1,11 +1,8 @@ | |||||||
| # Main zsh config file | # Main zsh config file | ||||||
|  |  | ||||||
| zmodload zsh/datetime |  | ||||||
| let __init_zsh_start="${EPOCHREALTIME}" |  | ||||||
|  |  | ||||||
| # Enable completions | # Enable completions | ||||||
| FPATH="${HOME}/.local/share/zsh/site-functions:${FPATH}" | autoload -U compinit | ||||||
| autoload -U compinit && compinit | compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION" | ||||||
|  |  | ||||||
| # Some utility stuff | # Some utility stuff | ||||||
| ZSH_PLUGIN_DIR="${ZSH_CONFIG_DIR}/plugins" | ZSH_PLUGIN_DIR="${ZSH_CONFIG_DIR}/plugins" | ||||||
| @ -17,195 +14,85 @@ function load_plugin { | |||||||
| function cmd_exists { | function cmd_exists { | ||||||
|     hash "${1}" >/dev/null 2>&1 |     hash "${1}" >/dev/null 2>&1 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | # User configuration file | ||||||
|  | [[ -v ZSH_USER_DIR ]] || ZSH_USER_DIR="${HOME}/.config/zsh" | ||||||
| # source_user_file <name> | # source_user_file <name> | ||||||
| function source_user_file { | function source_user_file { | ||||||
|     local machine_specific="${ZSH_CONFIG_DIR}/${1}.${HOST}.zsh" |     [ -e "${ZSH_USER_DIR}/${1}" ] && source "${ZSH_USER_DIR}/${1}" | ||||||
|     local default="${ZSH_CONFIG_DIR}/${1}.zsh" |  | ||||||
|     if [ -e "${machine_specific}" ]; then |  | ||||||
|         source "${machine_specific}" |  | ||||||
|     elif [ -e "${default}" ]; then |  | ||||||
|         source "${default}" |  | ||||||
|     fi |  | ||||||
| } | } | ||||||
|  |  | ||||||
| # Load user early init file | # Clean up home directory | ||||||
| source_user_file "early-init" | source "${ZSH_CONFIG_DIR}/clean-home.zsh" | ||||||
|  |  | ||||||
| # Load distrobox early init file | # Load user early init file | ||||||
| local is_in_distrobox=false | source_user_file "early-init.zsh" | ||||||
| if [[ -e /run/.containerenv ]] && cmd_exists distrobox-host-exec; then |  | ||||||
|     is_in_distrobox=true |  | ||||||
|     local ctenv=("${(@f)"$(</run/.containerenv)"}") |  | ||||||
|     for line in ${ctenv}; do |  | ||||||
|         if [[ "${line}" == 'name='* ]]; then |  | ||||||
|             export DISTROBOX_MY_NAME="${(Q)${line:5}}" |  | ||||||
|             if [[ -d "${HOME}/src/compat/${DISTROBOX_MY_NAME}" ]]; then |  | ||||||
|                 export DISTROBOX_MY_COMPAT="${HOME}/src/compat/${DISTROBOX_MY_NAME}" |  | ||||||
|                 local init_file="${DISTROBOX_MY_COMPAT}/early-init.zsh" |  | ||||||
|                 [[ -e "${init_file}" ]] && source "${init_file}" |  | ||||||
|             fi |  | ||||||
|             break |  | ||||||
|         fi |  | ||||||
|     done |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Some options | # Some options | ||||||
| setopt autocd extendedglob rm_star_silent completealiases rc_quotes histignorespace | setopt autocd extendedglob rm_star_silent completealiases | ||||||
| unsetopt beep notify | unsetopt beep notify | ||||||
|  |  | ||||||
| # Some general, random configuration | # Some general, random configuration | ||||||
| # History stuff | # History stuff | ||||||
| if [[ -v INSIDE_EMACS ]]; then |  | ||||||
|     () { |  | ||||||
|         emulate -L zsh |  | ||||||
|         set -o rematchpcre |  | ||||||
|         if [[ "${HISTFILE}" =~ '^~([^/]*)($|/.*)' ]]; then |  | ||||||
|             local user="${match[1]}" |  | ||||||
|             local rest="${match[2]}" |  | ||||||
|             if [[ -z "${user}" ]]; then |  | ||||||
|                 HISTFILE="${HOME}${rest}" |  | ||||||
|             else |  | ||||||
|                 HISTFILE="${userdirs[${user}]}" |  | ||||||
|             fi |  | ||||||
|         fi |  | ||||||
|     } |  | ||||||
| fi |  | ||||||
| [ ! -d "${HISTFILE:h}" ] && mkdir -p "${HISTFILE:h}" |  | ||||||
| [ -v HISTFILE ] || HISTFILE="${HOME}/.cache/zsh/history" | [ -v HISTFILE ] || HISTFILE="${HOME}/.cache/zsh/history" | ||||||
|  | [ ! -d "$(dirname "${HISTFILE}")" ] && mkdir -p "$(dirname "${HISTFILE}")" | ||||||
| HISTSIZE=1000 | HISTSIZE=1000 | ||||||
| SAVEHIST=10000 | SAVEHIST=10000 | ||||||
|  |  | ||||||
| # Tools for graphical sessions | # Tools for graphical sessions | ||||||
| export BROWSER=mullvad-browser | export BROWSER=firefox | ||||||
| export READER=zathura | export READER=zathura | ||||||
| if [[ -v WAYLAND_DISPLAY ]]; then | alias clip="xclip -selection clipboard" | ||||||
|     function clip { |  | ||||||
|         (( ${#} >= 1 )) && (cat "${@}" | wl-copy) || wl-copy |  | ||||||
|     } |  | ||||||
| else |  | ||||||
|     alias clip="xclip -selection clipboard" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # I mess this up a lot | # I mess this up a lot | ||||||
| alias cd..="cd .." | alias cd..="cd .." | ||||||
|  |  | ||||||
| # Make xargs, sudo, etc. understand aliases | # Neovim stuff | ||||||
| alias xargs='xargs ' |  | ||||||
| if cmd_exists doas; then |  | ||||||
|     __zsh_sudo_cmd=doas |  | ||||||
|     alias sudo='doas ' |  | ||||||
|     alias doas='doas ' |  | ||||||
|     alias sudoedit="doas $EDITOR " |  | ||||||
|     alias se="doas $EDITOR " |  | ||||||
| else |  | ||||||
|     __zsh_sudo_cmd=sudo |  | ||||||
|     alias sudo='sudo ' |  | ||||||
|     alias se='sudoedit ' |  | ||||||
|     alias doas='sudo ' |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Emacs and Neovim stuff |  | ||||||
| if [[ -v NVIM ]]; then | if [[ -v NVIM ]]; then | ||||||
|     export EDITOR=nvr |     export EDITOR=nvr | ||||||
|     alias n=nvr |     alias n=nvr | ||||||
|     alias nvim=nvr |     alias nvim=nvr | ||||||
|     alias e=nvr |  | ||||||
|     alias emacs=nvr |  | ||||||
| elif [[ "${is_in_distrobox}" == true ]]; then |  | ||||||
|     if [[ -v INSIDE_EMACS ]]; then |  | ||||||
|         [[ -z "${XDG_RUNTIME_DIR}" ]] && \ |  | ||||||
|             export XDG_RUNTIME_DIR="/run/user/${UID}" |  | ||||||
|         export EDITOR='distrobox-host-exec emacsclient -a nvim ' |  | ||||||
|         alias emacs='distrobox-host-exec emacsclient -a nvim ' |  | ||||||
|     else |  | ||||||
|         export EDITOR='distrobox-host-exec emacsclient -a nvim -c ' |  | ||||||
|         alias emacs='distrobox-host-exec emacsclient -a nvim -c ' |  | ||||||
|     fi |  | ||||||
|     alias n='emacs ' |  | ||||||
|     alias e='emacs ' |  | ||||||
| elif [[ -v INSIDE_EMACS ]]; then |  | ||||||
|     export EDITOR='emacsclient' |  | ||||||
|     alias e='emacsclient ' |  | ||||||
|     alias emacs='emacsclient ' |  | ||||||
|     alias n='emacsclient ' |  | ||||||
|     alias nvim='emacsclient ' |  | ||||||
| else | else | ||||||
|     export EDITOR='emacsclient -a nvim -nw' |     export EDITOR=nvim | ||||||
|     # Because I keep using n by mistake |     alias n=nvim | ||||||
|     alias emacs="${EDITOR} " |  | ||||||
|     alias n=emacs |  | ||||||
|     alias e=emacs |  | ||||||
|     alias nvim=emacs |  | ||||||
| fi | fi | ||||||
| export VISUAL="${EDITOR}" | export VISUAL="${EDITOR}" | ||||||
|  | alias se=sudoedit | ||||||
| # Make SBCL *slightly* less frustrating to use on the command line |  | ||||||
| alias sbcl='rlwrap -pblue -q "\"" sbcl' |  | ||||||
|  |  | ||||||
| # Safer file functions | # Safer file functions | ||||||
|  | local rm_confirm_flag='-i' | ||||||
|  | uname | grep -i linux >/dev/null && rm_confirm_flag='-I' | ||||||
|  | alias rm="rm ${rm_confirm_flag}" | ||||||
| alias cp="cp -i" | alias cp="cp -i" | ||||||
| alias mv="mv -i" | alias mv="mv -i" | ||||||
|  |  | ||||||
| # Trash put for safety |  | ||||||
| if cmd_exists clash; then |  | ||||||
|     alias rm='echo "rm: I''m unsafe! Don''t use me."; false' |  | ||||||
|     alias tp="clash put" |  | ||||||
|     alias trr="clash restore" |  | ||||||
|     alias trl="clash list" |  | ||||||
|     alias tre="clash emtpy" |  | ||||||
|     alias trm="clash empty" |  | ||||||
| elif cmd_exists trash-put; then |  | ||||||
|     alias rm='echo "rm: I''m unsafe! Don''t use me."; false' |  | ||||||
|     alias tp=trash-put |  | ||||||
|     alias trr=trash-restore |  | ||||||
|     alias trl=trash-list |  | ||||||
|     alias tre=trash-empty |  | ||||||
|     alias trm=trash-rm |  | ||||||
| else |  | ||||||
|     local rm_confirm_flag='-i' |  | ||||||
|     uname | grep -i linux >/dev/null && rm_confirm_flag='-I' |  | ||||||
|     alias rm="rm ${rm_confirm_flag}" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Enable mouse support in less | # Enable mouse support in less | ||||||
| export LESS="--mouse" | export LESS="--mouse" | ||||||
|  |  | ||||||
| # Bat configuration | # Bat configuration | ||||||
| local bat_exec |  | ||||||
| if cmd_exists bat; then | if cmd_exists bat; then | ||||||
|     bat_exec=bat |  | ||||||
| elif cmd_exists batcat; then |  | ||||||
|     bat_exec=batcat; |  | ||||||
|     alias bat=batcat |  | ||||||
| fi |  | ||||||
| if ! [[ -z "${bat_exec}" ]]; then |  | ||||||
|     # Pager |     # Pager | ||||||
|     export PAGER="${bat_exec} --paging=always" |     export PAGER="bat --paging=always" | ||||||
|  |  | ||||||
|     # Less syntax highlighting in interactive shells |     # Less syntax highlighting in interactive shells | ||||||
|     alias less="${bat_exec} --paging=always" |     alias less="bat --paging=always" | ||||||
|  |  | ||||||
|     # Use bat instead of cat |     # Use bat instead of cat | ||||||
|     alias cat="${bat_exec} --paging=never" |     alias cat="bat --paging=never" | ||||||
|     alias pcat="${bat_exec} -pp" |     alias pcat="bat -pp" | ||||||
|     alias ncat="${bat_exec} -pp --color=never" |     alias ncat="bat -pp --color=never" | ||||||
|  |  | ||||||
|     # Bat as man pager |     # Bat as man pager | ||||||
|     if [[ "${bat_exec}" = (bat|*/bat) ]]; then |     export MANPAGER="zsh -c 'col -bx | bat -l man -p --paging=always'" | ||||||
|         export MANPAGER="zsh -c 'col -bx | ${bat_exec} -l man --paging=always --style=plain'" |  | ||||||
|         export MANROFFOPT="-c" |  | ||||||
|     fi |  | ||||||
| fi | fi | ||||||
| unset bat_exec |  | ||||||
|  |  | ||||||
| # Eza configuration | # Exa configuration | ||||||
| # Don't define an alias if ls is already an alias | if cmd_exists exa; then | ||||||
| if cmd_exists eza && ! alias ls >/dev/null; then |     alias ls="exa --git -F" | ||||||
|     alias ls="eza --git -F=auto" |     alias la="ls -a" | ||||||
|  |     alias l="ls -l" | ||||||
|  |     alias ll="ls -al" | ||||||
| fi | fi | ||||||
| alias la="ls -a" |  | ||||||
| alias l="ls -l" |  | ||||||
| alias ll="ls -al" |  | ||||||
|  |  | ||||||
| # Delta configuration | # Delta configuration | ||||||
| if cmd_exists delta; then | if cmd_exists delta; then | ||||||
| @ -219,31 +106,61 @@ alias ga="git add" | |||||||
| alias gaa="git add -A" | alias gaa="git add -A" | ||||||
| alias gco="git commit" | alias gco="git commit" | ||||||
| gcm() { | gcm() { | ||||||
|     git commit -m "${${@}}" |     local args="${@}" | ||||||
|  |     git commit -m "${args}" | ||||||
| } | } | ||||||
| alias gca="git commit -a" | alias gca="git commit -a" | ||||||
| gcam() { | gcam() { | ||||||
|     git commit -am "${${@}}" |     local args="${@}" | ||||||
|  |     git commit -am "${args}" | ||||||
| } | } | ||||||
| alias gp="git push" | alias gp="git push" | ||||||
| alias gu="git pull" | alias gu="git pull" | ||||||
| alias gf="git fetch" | alias gf="git fetch" | ||||||
| alias gt="git status" | alias gt="git status" | ||||||
| alias gd="git diff" |  | ||||||
|  | # Dotfile management | ||||||
|  | [ -v ZSH_MANAGE_DOTFILES_REPO ] || ZSH_MANAGE_DOTFILES_REPO="${HOME}/src/dotfiles" | ||||||
|  | function dots { | ||||||
|  |     local args=("--git-dir=${ZSH_MANAGE_DOTFILES_REPO}" '--work-tree=/' '--bare') | ||||||
|  |     if (( ${#} == 0 )); then | ||||||
|  | 		(cd / | ||||||
|  |         for file in $(git ${args} ls-files); do | ||||||
|  |             printf '%s\t%s\t\e[38;2;255;255;0m%s\e[m\n' \ | ||||||
|  |                 "$(git ${args} -c color.status=always status -s "${file}" | sed "s#${file}##")" \ | ||||||
|  |                 "/${file}" \ | ||||||
|  |                 "$(git ${args} log --max-count=1 --format='%s' "${file}")" | ||||||
|  | 		done) | column -t -T2 --separator="	" | ||||||
|  |     else | ||||||
|  |         git ${args} "${@}" | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  | compdef -e "words[1]=(git '--git-dir=${HOME}/src/dotfiles' --work-tree=/ --bare); service=git; (( CURRENT+=3 )); _git" dots | ||||||
|  |  | ||||||
| # Sudo last line with <Esc><Esc> | # Sudo last line with <Esc><Esc> | ||||||
| sudo-command-line() { | sudo-command-line() { | ||||||
|     [[ -z $BUFFER ]] && zle up-history |     [[ -z $BUFFER ]] && zle up-history | ||||||
|     if [[ $BUFFER == ${__zsh_sudo_cmd}\ * ]]; then |     if [[ $BUFFER == sudo\ * ]]; then | ||||||
|         LBUFFER="${LBUFFER#${__zsh_sudo_cmd} }" |         LBUFFER="${LBUFFER#sudo }" | ||||||
|  |     elif [[ $BUFFER == $EDITOR\ * ]]; then | ||||||
|  |         LBUFFER="${LBUFFER#$EDITOR }" | ||||||
|  |         LBUFFER="sudoedit $LBUFFER" | ||||||
|  |     elif [[ $BUFFER == sudoedit\ * ]]; then | ||||||
|  |         LBUFFER="${LBUFFER#sudoedit }" | ||||||
|  |         LBUFFER="$EDITOR $LBUFFER" | ||||||
|     else |     else | ||||||
|         LBUFFER="${__zsh_sudo_cmd} ${LBUFFER}" |         LBUFFER="sudo $LBUFFER" | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
| zle -N sudo-command-line | zle -N sudo-command-line | ||||||
| bindkey -M vicmd "^f" sudo-command-line | bindkey -M vicmd "^f" sudo-command-line | ||||||
| bindkey -M viins "^f" sudo-command-line | bindkey -M viins "^f" sudo-command-line | ||||||
|  |  | ||||||
|  | # Autosuggestions | ||||||
|  | load_plugin zsh-autosuggestions | ||||||
|  | ZSH_AUTOSUGGEST_STRATEGY=(history completion) | ||||||
|  | bindkey '^ ' autosuggest-accept | ||||||
|  |  | ||||||
| # Use vi mode | # Use vi mode | ||||||
| bindkey -v | bindkey -v | ||||||
| # Fast switch of modes | # Fast switch of modes | ||||||
| @ -258,7 +175,7 @@ function overwrite-mode { | |||||||
| zle -N overwrite-mode | zle -N overwrite-mode | ||||||
|  |  | ||||||
| # Fancy prompt (starship) | # Fancy prompt (starship) | ||||||
| cmd_exists starship && eval "$(starship init zsh)" | eval "$(starship init zsh)" | ||||||
| # Change cursor shape for different vi modes. | # Change cursor shape for different vi modes. | ||||||
| function __zsh_vim_key_prompt_handler { | function __zsh_vim_key_prompt_handler { | ||||||
|     SPACESHIP_CHAR_SYMBOL="❮" |     SPACESHIP_CHAR_SYMBOL="❮" | ||||||
| @ -304,28 +221,10 @@ if cmd_exists direnv;  then | |||||||
|     eval "$(direnv hook zsh)" |     eval "$(direnv hook zsh)" | ||||||
| fi | fi | ||||||
|  |  | ||||||
| # Pyenv |  | ||||||
| if cmd_exists pyenv; then |  | ||||||
|     export PYENV_ROOT="${HOME}/.pyenv" |  | ||||||
|     [[ -d "${PYENV_ROOT/bin}" ]] && export PATH="${PYENV_ROOT}/bin:${PATH}" |  | ||||||
|     eval "$(pyenv init - zsh)" |  | ||||||
|     eval "$(pyenv virtualenv-init - zsh)" |  | ||||||
|     __zsh_fix_pyenv_prompt() { |  | ||||||
|         if [[ -v _OLD_VIRTUAL_PS1 ]]; then |  | ||||||
|             PS1="${_OLD_VIRTUAL_PS1}" |  | ||||||
|             unset _OLD_VIRTUAL_PS1 |  | ||||||
|         fi |  | ||||||
|     } |  | ||||||
|     precmd_functions+=(__zsh_fix_pyenv_prompt) |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Bookmarks | # Bookmarks | ||||||
| if cmd_exists emacs; then | [ -v ZSH_BOOKMARK_DIR ] || ZSH_BOOKMARK_DIR="${HOME}/.cache/zsh/bookmarks" | ||||||
|     [[ -v BM_CWD_LS ]] || BM_CWD_LS=true | [ -v ZSH_BOOKMARK_LS ] || ZSH_BOOKMARK_LS=true | ||||||
|     [[ -v BM_MODE ]] || BM_MODE=daemon | source "${ZSH_CONFIG_DIR}/bookmark.zsh" | ||||||
|     [[ -v BM_AUTO_RELOAD ]] || BM_AUTO_RELOAD=true |  | ||||||
|     source "${ZSH_CONFIG_DIR}/emacs-bookmark.zsh" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Platform specific stuff | # Platform specific stuff | ||||||
| [ -f /usr/bin/pacman ] && source "${ZSH_CONFIG_DIR}/arch.zsh" | [ -f /usr/bin/pacman ] && source "${ZSH_CONFIG_DIR}/arch.zsh" | ||||||
| @ -338,8 +237,8 @@ zstyle ':completion:*:git-checkout:*' sort false | |||||||
| zstyle ':completion:*:descriptions' format '[%d]' | zstyle ':completion:*:descriptions' format '[%d]' | ||||||
| # Set list-colors to enable filename colorizing | # Set list-colors to enable filename colorizing | ||||||
| zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | ||||||
| # Preview directory's content with eza when completing cd | # Preview directory's content with exa when completing cd | ||||||
| zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' | zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath' | ||||||
| # Remove the '.' prefix at the start of every completion | # Remove the '.' prefix at the start of every completion | ||||||
| zstyle ':fzf-tab:*' prefix '' | zstyle ':fzf-tab:*' prefix '' | ||||||
| # Switch groups | # Switch groups | ||||||
| @ -347,39 +246,25 @@ zstyle ':fzf-tab:*' switch-group 'ctrl-h' 'ctrl-l' | |||||||
| # Toggle selected for all visible entries | # Toggle selected for all visible entries | ||||||
| zstyle ':fzf-tab:*' fzf-bindings 'ctrl-a:toggle-all' | zstyle ':fzf-tab:*' fzf-bindings 'ctrl-a:toggle-all' | ||||||
|  |  | ||||||
| # Autosuggestions |  | ||||||
| load_plugin zsh-autosuggestions |  | ||||||
| ZSH_AUTOSUGGEST_STRATEGY=(history completion) |  | ||||||
| bindkey '^ ' autosuggest-accept |  | ||||||
|  |  | ||||||
| # Load user init file | # Load user init file | ||||||
| source_user_file 'local' | source_user_file 'local.zsh' | ||||||
|  |  | ||||||
| # Load distrobox normal init file |  | ||||||
| if [[ -v DISTROBOX_MY_COMPAT ]] && \ |  | ||||||
|        [[ -f "${DISTROBOX_MY_COMPAT}/init.zsh" ]]; then |  | ||||||
|     source "${DISTROBOX_MY_COMPAT}/init.zsh" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # THE FOLLOWING PLUGINS MUST COME LAST | # THE FOLLOWING PLUGINS MUST COME LAST | ||||||
|  |  | ||||||
| # Tea (Gitea CLI) completions |  | ||||||
| cmd_exists tea && source <(tea completion zsh) |  | ||||||
|  |  | ||||||
| # More completions | # More completions | ||||||
| load_plugin zsh-completions | load_plugin zsh-completions | ||||||
|  |  | ||||||
| # Syntax highlighting | # Syntax highlighting | ||||||
| load_plugin fast-syntax-highlighting | load_plugin zsh-syntax-highlighting | ||||||
|  |  | ||||||
| # History substring search | # History substring search | ||||||
| load_plugin zsh-history-substring-search | load_plugin zsh-history-substring-search | ||||||
| bindkey '^[[A' history-substring-search-up | bindkey '^[[A' history-substring-search-up | ||||||
| bindkey '^[[B' history-substring-search-down | bindkey '^[[B' history-substring-search-down | ||||||
| #bindkey '^k' history-substring-search-up | bindkey '^k' history-substring-search-up | ||||||
| #bindkey '^j' history-substring-search-down | bindkey '^j' history-substring-search-down | ||||||
| #bindkey -M vicmd '^k' history-substring-search-up | bindkey -M vicmd '^k' history-substring-search-up | ||||||
| #bindkey -M vicmd '^j' history-substring-search-down | bindkey -M vicmd '^j' history-substring-search-down | ||||||
| bindkey -M vicmd 'k' history-substring-search-up | bindkey -M vicmd 'k' history-substring-search-up | ||||||
| bindkey -M vicmd 'j' history-substring-search-down | bindkey -M vicmd 'j' history-substring-search-down | ||||||
| bindkey -M emacs '^P' history-substring-search-up | bindkey -M emacs '^P' history-substring-search-up | ||||||
| @ -390,21 +275,10 @@ HISTORY_SUBSTRING_SEARCH_PREFIXED="true" | |||||||
| HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="" | HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="" | ||||||
| setopt histignoredups | setopt histignoredups | ||||||
|  |  | ||||||
| # Run fortune and cowsay if we are not in nvim or ssh |  | ||||||
| if cmd_exists fortune && cmd_exists cowsay; then |  | ||||||
|     [[ -v NVIM ]] || [[ -v SSH_CLIENT ]] || [[ -v INSIDE_EMACS ]] || \ |  | ||||||
|         fortune | cowsay -felephant-in-snake -n |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # [[ -v EAT_SHELL_INTEGRATION_DIR ]] && source "${EAT_SHELL_INTEGRATION_DIR}/zsh" |  | ||||||
|  |  | ||||||
| # Clean up internal functions | # Clean up internal functions | ||||||
| unfunction load_plugin | unfunction load_plugin | ||||||
| unfunction cmd_exists | unfunction cmd_exists | ||||||
| unfunction source_user_file | unfunction source_user_file | ||||||
| unset is_in_distrobox |  | ||||||
|  |  | ||||||
| let ZSH_INIT_TIME="$(( EPOCHREALTIME - __init_zsh_start ))" | # Run fortune and cowsay if we are not in nvim | ||||||
| function zsh-init-time { | [[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n | ||||||
|     printf 'Zsh initialization took: %05fms\n' "$(( ZSH_INIT_TIME * 1000 ))" |  | ||||||
| } |  | ||||||
|  | |||||||
 Submodule plugins/fast-syntax-highlighting deleted from 3d574ccf48
									
								
							 Submodule plugins/fzf-tab updated: fac145167f...5a81e13792
									
								
							 Submodule plugins/zsh-autosuggestions updated: 85919cd1ff...a411ef3e09
									
								
							 Submodule plugins/zsh-completions updated: 173a14c436...45a37bc26f
									
								
							 Submodule plugins/zsh-history-substring-search updated: 87ce96b186...400e58a87f
									
								
							
							
								
								
									
										1
									
								
								plugins/zsh-syntax-highlighting
									
									
									
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								plugins/zsh-syntax-highlighting
									
									
									
									
									
										Submodule
									
								
							 Submodule plugins/zsh-syntax-highlighting added at 754cefe018
									
								
							
		Reference in New Issue
	
	Block a user