Skip to content

Commit

Permalink
add a fake hashbang to all autoloadable functions and sourced scripts…
Browse files Browse the repository at this point in the history
… to get syntax highlighting
  • Loading branch information
romkatv committed Feb 6, 2021
1 parent 715604f commit 0029ed6
Show file tree
Hide file tree
Showing 83 changed files with 166 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fn/-z4h-autosuggest-fetch
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

if [[ -z $BUFFER || $CONTEXT != start ]]; then
unset POSTDISPLAY _z4h_autosuggest_buffer _z4h_autosuggestion
else
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-brew-command-not-found
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

{
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cd-rotate
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

() {
eval "$_z4h_opt"
while (( $#dirstack )) && ! pushd -q $1 &>/dev/null; do
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-chsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

local user=${(%):-%n}
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cmd-bindkey
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

zparseopts -D -F -- || return '_z4h_err()'
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cmd-compile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local file
zparseopts -D -F -- || return '_z4h_err()'
emulate zsh -o extended_glob -c 'local files=(${^@}(N))'
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cmd-help
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

if (( ARGC == 1 )); then
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cmd-ssh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# TODO: write proper docs for these configuration options.
#
# zstyle ':z4h:ssh:my_host' enable 'yes'
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cmd-sudo
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

local term
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-cmd-update
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"
-z4h-check-core-params || return

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-comp-files
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

() {
eval "$_z4h_opt"

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-comp-insert-all
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

emulate -L zsh

if (( $#_z4h_scaffolds == 1 )); then
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-comp-words
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

() {
eval "$_z4h_opt"

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-compile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# Runs with user options.
#
# Precondition: [[ -e $1 ]].
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-complete-cargo
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

(( $+commands[rustup] && $+commands[rustc] )) || {
unset '_comps[cargo]'
_default "$@"
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-complete-helm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local helm="${commands[helm]-}"
local orig_cmd="${_comps[helm]-}"
local comp="$Z4H"/cache/helm-completion-$EUID.zsh
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-complete-kitty
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local kitty="${commands[kitty]-}"
local orig_cmd="${_comps[kitty]-}"
local comp="$Z4H"/cache/kitty-completion-$EUID.zsh
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-complete-kubectl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local kubectl="${commands[kubectl]-}"
local orig_cmd="${_comps[kubectl]-}"
local comp="$Z4H"/cache/kubectl-completion-$EUID.zsh
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-complete-oc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local oc="${commands[oc]-}"
local orig_cmd="${_comps[oc]-}"
local comp="$Z4H"/cache/oc-completion-$EUID.zsh
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-complete-rustup
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

(( $+commands[rustup] )) || {
unset '_comps[rustup]'
_default "$@"
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-enable-iterm2-integration
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

function iterm2_set_user_var() {
(( ${+commands[base64]} )) || return
local x
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-error-command
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local home=~
local zdotdir=${${${(q)ZDOTDIR}/#${(q)home}/'~'}//\%/%%}
local z4h=${${${(q)Z4H}/#${(q)home}/'~'}//\%/%%}
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-error-iterm2-integration
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local home=~
local zdotdir=${${${(q)ZDOTDIR}/#${(q)home}/'~'}//\%/%%}

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-error-param-changed
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

print -Pru2 -- "%F{3}z4h%f: core parameters have unexpectedly changed"
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-find
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local dot_glob=$1
local only_dirs=$2
local dirs=("${@:3}")
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-fix-locale
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# Try in order: C.UTF-8, en_US.UTF-8, the first UTF-8 locale in lexicographical order.
(( $+commands[locale] )) || return
local loc=(${(@M)$(locale -a):#*.(utf|UTF)(-|)8})
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-flowing
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

local -a centered indentation
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-fzf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

local widget=${WIDGET#z4h-}
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-gen-init-darwin-paths
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local -a stat
local files=(/usr/libexec/path_helper /etc/{,man}paths{,.d} /etc/paths.d/*(N) /etc/manpaths.d/*(N))
zstat -A stat +mtime -- $files 2>/dev/null || return
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-get-cursor-pos
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/usr/bin/env zsh

local esc
IFS='[;' builtin read -s -d R esc\?$'\e[6n' cursor_y cursor_x <"$TTY"
2 changes: 2 additions & 0 deletions fn/-z4h-gnu-command-not-found
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

function command_not_found_handler() {
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-help-bindkey
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

print -Pr -- "$(<<\END
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-help-compile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

print -Pr -- "$(<<\END
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-help-source
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

print -Pr -- "$(<<\END
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-help-ssh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

print -Pr -- "$(<<\END
Usage: %F{2}z4h%f %Bssh%b [%Ussh-options%u]... [--] [%Uuser@%u]%Uhostname%u
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-init
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

if zstyle -t :z4h: iterm2-integration &&
[[ $TERM != (dumb|linux) && $ITERM_SHELL_INTEGRATION_INSTALLED != Yes ]]; then
-z4h-enable-iterm2-integration
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-init-wsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

[[ "$(</proc/version)" == *[Mm]icrosoft* ]] || return

local cmd=${commands[cmd.exe]:-/mnt/c/Windows/System32/cmd.exe}
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-insert-all
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local hook=${widgets[zle-line-pre-redraw]-}
if [[ $hook == user:* ]]; then
hook=${hook#user:}
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-install-many
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local success

{
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-install-one
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local url postinstall command

if [[ $1 == */* ]]; then
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-main-complete
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# Based on _main_complete from Zsh 5.8.

local IFS=$' \t\n\0'
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-move-and-kill
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local -i cursor=CURSOR
"$@"
emulate -L zsh
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-mv
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

(( ARGC == 2 )) || return '_z4h_err()'
[[ $2 != */ ]] || return '_z4h_err()'

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-fzf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

if [[ -e $Z4H/.updating ]]; then
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-powerlevel10k
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

zf_mkdir -p -- $Z4H/cache/powerlevel10k/p10k-root || return
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-systemd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

local comp=$Z4H_PACKAGE_DIR/shell-completion/zsh/_systemctl
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-terminfo
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

# Fork to avoid triggering https://www.zsh.org/mla/workers/2020/msg00588.html
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-zsh-autosuggestions
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

z4h compile -- $Z4H_PACKAGE_DIR/{zsh-autosuggestions.zsh,src/**/*.zsh}(N)
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-zsh-history-substring-search
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

z4h compile -- $Z4H_PACKAGE_DIR/zsh-history-substring-search.zsh
2 changes: 2 additions & 0 deletions fn/-z4h-postinstall-zsh-syntax-highlighting
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

z4h compile -- $Z4H_PACKAGE_DIR/{zsh-syntax-highlighting.zsh,highlighters/*/*.zsh}(N)
2 changes: 2 additions & 0 deletions fn/-z4h-present-files
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"
setopt octalzeroes

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-prompt-length
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local -i COLUMNS=1024
local -i x y=${#1} m
if (( y )); then
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-redraw-buffer
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

if (( ${+_z4h_redraw_fd} )); then
zle -F "$_z4h_redraw_fd"
exec {_z4h_redraw_fd}>&-
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-redraw-prompt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

{
-z4h-cursor-hide
local f
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-restore-screen
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

[[ -w $TTY ]] || return
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-run-process-tree
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# Copied from https://github.com/romkatv/run-process-tree.

zmodload zsh/parameter || return
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-sanitize-word-prefix
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

() {
emulate -L zsh -o extended_glob
[[ $_z4h_word_prefix != *('$'|'\') ]] || return
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-save-screen
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

if [[ -n $_Z4H_TMUX ]]; then
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-set-list-colors
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"
setopt octalzeroes

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-set-term-title
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

emulate -L zsh -o no_prompt_bang -o prompt_subst -o prompt_percent

local title=$1
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-show-dots
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local -i cursor=CURSOR
local postdisplay=$POSTDISPLAY
local buffer=$BUFFER
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-ssh-maybe-update
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

# Requires: [[ $Z4H_SSH == <1->:* ]]

eval "$_z4h_opt"
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-tmux-bypass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local x
builtin printf -v x "$@"

Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-welcome
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

add-zsh-hook -d -- precmd -z4h-welcome
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-with-local-history
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

eval "$_z4h_opt"

local last=$LASTWIDGET
Expand Down
2 changes: 2 additions & 0 deletions fn/-z4h-zle-line-finish
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env zsh

local -i ret

if [[ -v widgets[-z4h-orig-zle-line-finish] ]]; then
Expand Down
Loading

0 comments on commit 0029ed6

Please sign in to comment.