Skip to content

Commit

Permalink
modified: .editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-o committed Nov 29, 2021
1 parent 1958a1f commit 6023cb9
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ indent_size = 2
[.git*]
indent_size = tab
indent_style = tab

[*.{sh,zsh}]
indent_style = space
Empty file modified lib/_zi
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions lib/git/hooks/post-checkout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Branch specific `.gitignore`

This `post-checkout` hook will copy `.gitignore.branch_name in place` of `.git/info/exclude` each time with `git checkout branch_name`.

## Setup

1. Create new `.gitignore` files for each branch and name it : `.gitignore.branch_name`
2. In your git repo, go to `.git/hooks/` and copy `post-checkout` file there.
3. Make sure permissions are: `chmod +x post-checkout` and `chmod 755 post-checkout`
4. Just go to the branch you want and type `git status`: **TADAAA** !
27 changes: 27 additions & 0 deletions lib/git/hooks/post-checkout/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

old_ref="$1"
new_ref="$2"
branch_switched="$3"

if [[ $branch_switched != '1' ]]; then
exit 0
fi

echo "=== POST CHECKOUT ==="
current_branch="$(git rev-parse --abbrev-ref HEAD)"
hook_dir="$(dirname $0)"
root_dir="$(pwd -P)"
info_dir="$root_dir/.git/info"
exclude_target='.gitignore'

if [[ -f "${root_dir}/${exclude_target}.${current_branch}" ]]; then
echo -e "Use .gitignore.${current_branch} to exclude files"
exclude_target=.gitignore.${current_branch}
fi

builtin cd "$info_dir" || exit
rm exclude
echo -e "Copy .gitignore.${current_branch} where required"
cp "${root_dir}/${exclude_target}" exclude
echo -e "=== POST CHECKOUT END ==="
File renamed without changes.
File renamed without changes.
Empty file modified lib/zsh/additional.zsh
100644 → 100755
Empty file.
Empty file modified lib/zsh/install.zsh
100644 → 100755
Empty file.
Empty file modified lib/zsh/side.zsh
100644 → 100755
Empty file.
Empty file modified lib/zsh/zinit.zsh
100644 → 100755
Empty file.
100 changes: 100 additions & 0 deletions lib/zsh/ztransform
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/zsh
# vim:ft=zsh

setopt extendedglob

fpath+=( "${0%/*}" )
autoload zplg-process-buffer

local name="$1"
local doc="$(<$name)" token prev_token="" spaces prev_spaces="" next_token next_spaces

local preamble="" fun_name=""
local -A funs

integer next_fun=0 cur_fun=0 prev_fun=0
integer depth=0 prev_depth=0 fun_depth=-1 anon_depth=-1 descentff=0 descentfa=0

zplg-process-buffer "$doc" 1
integer i size="${#ZPLG_PB_WORDS}"

for (( i=1; i<=size; ++ i )); do
token="${ZPLG_PB_WORDS[i]}"
spaces="${ZPLG_PB_SPACES[i]}"
next_token="${ZPLG_PB_WORDS[i+1]}"
next_spaces="${ZPLG_PB_SPACES[i+1]}"
cur_fun=0 prev_fun=0 descentff=0 descentfa=0

(( next_fun )) && { next_fun=0 cur_fun=1 prev_fun=0 anon_depth=-1 }

# Explicit future function
if [[ "$token" = "function" ]]; then
next_fun=1 cur_fun=0 prev_fun=0 anon_depth=-1
# Detect function if not already in function
elif [[ "$token" = "()" && ( "$fun_depth" -lt 0 ) && ( $anon_depth -lt 0 ) ]]; then
if [[ "$spaces" = *$'\n'* || -z "$prev_token" ]]; then
next_fun=0 cur_fun=0 prev_fun=0 anon_depth=$depth
else
next_fun=0 cur_fun=0 prev_fun=1 anon_depth=-1
fi
elif [[ "$token" = "{" ]]; then
(( ++ depth ))
elif [[ "$token" = "}" ]]; then
(( -- depth ))
fi

if (( cur_fun )); then
fun_name="$token"
fun_depth="$depth"
elif (( prev_fun )); then
fun_name="$prev_token"
fun_depth="$depth"
fi

# Ascent to function - skip '{'
if (( fun_depth >= 0 && depth == (fun_depth + 1) )) && [[ "$token" = "{" ]]; then
:
# In-function
elif (( fun_depth >= 0 && depth > fun_depth )); then
if [[ "$token" != [[:space:]]#\#* ]]; then
funs[$fun_name]+="${spaces}${token}"
fi
# Descent from function - skip '}'
elif (( fun_depth >= 0 && depth == fun_depth && prev_depth == fun_depth + 1 )); then
descentff=1
# Descent from anon
elif (( anon_depth >= 0 && depth == anon_depth && prev_depth == anon_depth + 1 )); then
descentfa=1
fi

# Anon function in top-level
if (( anon_depth >= 0 && fun_depth < 0 )); then
[[ "$token" != [[:space:]]#\#* ]] && preamble+="${spaces}${token}"
fi

# Late disable of (anon)
if (( descentfa )); then
anon_depth=-1
elif (( descentff )); then
fun_name=""
fun_depth=-1
# No-function printing
elif (( next_fun == 0 && cur_fun == 0 && prev_fun == 0 && anon_depth < 0 && fun_depth < 0 )); then
if [[ "$next_token" != "()" || "$next_spaces" = *$'\n'* ]]; then
[[ "$token" != [[:space:]]#\#* ]] && preamble+="${spaces}${token}"
fi
fi

prev_depth="$depth"
prev_token="$token"
prev_spaces="$spaces"
done

print -r -- "$preamble" >| "preamble.zini"

for fun_name in "${(ko@)funs}"; do
print -r -- "[${fun_name}"$'\C-A'"fun]"
print -r -- "${funs[$fun_name]}"
print -r -- "PLG_END_F"
print
done >| "functions.zini"
23 changes: 14 additions & 9 deletions zi.zsh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ cdclear|delete) ]]; then

reply=( ${ZI_EXTS[(I)z-annex subcommand:*]} )

[[ -n $1 && $1 != (-h|--help|help|analytics|man|self-update|times|zstatus|load|light|unload|snippet|ls|ice|\
[[ -n $1 && $1 != (-h|--help|help|analytics|control|man|self-update|times|zstatus|load|light|unload|snippet|ls|ice|\
update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|\
completions|cclear|cdisable|cenable|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|\
dunload|dreport|dclear|compile|uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|\
Expand Down Expand Up @@ -2774,12 +2774,6 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice
(self-update)
.zi-self-update
;;
(analytics)
.zi-analytics-menu
;;
(control)
.zi-control-menu
;;
(unload)
(( ${+functions[.zi-unload]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
if [[ -z $2 && -z $3 ]]; then
Expand Down Expand Up @@ -2949,6 +2943,12 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice
shift
.zi-recently "$@"; ___retval=$?
;;
(control)
.zi-control-menu
;;
(analytics)
.zi-analytics-menu
;;
(-h|help)
.zi-help
;;
Expand Down Expand Up @@ -3018,12 +3018,16 @@ zicompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
}
# ]]]
# Compatibility functions. [[[
#zinit() { zi "$@"; }
zinit() { zi "$@"; }
zpcdreplay() { .zi-compdef-replay -q; }
zpcdclear() { .zi-compdef-clear -q; }
zpcompinit() { autoload -Uz compinit; compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"; }
zpcompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
# ]]]
# FUNCTION: zt. [[[
# Common ICE modifier to simplify Turbo mode.
zt() { zi depth'3' lucid ${1/#[0-9][a-d]/wait"${1}"} "${@:2}"; }
# ]]]

#
# Source-executed code.
Expand All @@ -3042,7 +3046,8 @@ zmodload zsh/zpty zsh/system 2>/dev/null
zmodload -F zsh/stat b:zstat 2>/dev/null && ZI[HAVE_ZSTAT]=1

# code. [[[
builtin alias zpl=zi zplg=zi zini=zi zinit=zi
builtin alias zpl=zi zplg=zi zini=zi

.zi-prepare-home

# Remember source's timestamps for the automatic-reload feature.
Expand Down

0 comments on commit 6023cb9

Please sign in to comment.