Compare commits
92 Commits
info
...
ea774fdd8b
Author | SHA1 | Date | |
---|---|---|---|
ea774fdd8b
|
|||
d872b655c9
|
|||
47b2170058
|
|||
0289d90fb9
|
|||
a54be4863a
|
|||
d05065f3aa
|
|||
af26648283
|
|||
b9b056d10d
|
|||
f77e4a54bc
|
|||
9725317a4a
|
|||
aea9334649
|
|||
8af457ab05
|
|||
d65860c0ac
|
|||
9d1de60648
|
|||
d5209414e9
|
|||
ad4acd935a
|
|||
9bd1bb79ea
|
|||
19571a4046
|
|||
7a8ba289fa
|
|||
086279d721
|
|||
d2061dda65
|
|||
5fd6a13726
|
|||
e10445bf10
|
|||
80ae65a3fa
|
|||
25c314caa9
|
|||
e76ed11c36
|
|||
2ef127fe7a
|
|||
3220c72f6f
|
|||
55324be58e
|
|||
ac9d7a7de6
|
|||
5041d2c7e7
|
|||
f6a2541e4f
|
|||
732d00440e
|
|||
e59ee51009
|
|||
de28616e6c
|
|||
d524b4255a
|
|||
724df8e2d8
|
|||
0ec196bef2
|
|||
23275ec9fc
|
|||
2622b6e7e8
|
|||
4a2b874478
|
|||
48a90c3981
|
|||
f0a6c78243
|
|||
faae072861
|
|||
a70347e7f7
|
|||
3b50183a0d
|
|||
113ce00644
|
|||
e6fef308ef
|
|||
5e2f600eba
|
|||
27137da435
|
|||
cf3e5623ab
|
|||
731471aee7
|
|||
95d73f7f64
|
|||
59c691e5df
|
|||
5e64dfe3fe
|
|||
e1ac7abd92
|
|||
7f0793da39
|
|||
3c91a3f5ae
|
|||
deed34735d
|
|||
54ae3affd0
|
|||
6ecf110b2c
|
|||
bc5e07f76e
|
|||
f07d2d3b35
|
|||
e9ba43b038
|
|||
1c849b0404
|
|||
765d07a7b8
|
|||
6530af46f0
|
|||
5addb3ae5e
|
|||
5626190a83
|
|||
2e41d859c9
|
|||
b0e681a87a
|
|||
786277961d
|
|||
e014ff180f
|
|||
17ef24e460
|
|||
5a06ade27b
|
|||
83a61a4c2f
|
|||
5394f208b6
|
|||
a312de64e1
|
|||
04b31f7a24
|
|||
a6b87e2330
|
|||
4cc414b20d
|
|||
100187ca04
|
|||
ac12fc459b
|
|||
7bf6262945
|
|||
26f29d0514
|
|||
ad82f32828
|
|||
87d9c7f978
|
|||
eeaa54993a
|
|||
32bd17a702
|
|||
9e79767704
|
|||
467332a5ec
|
|||
28231f278c
|
0
.cache/zsh/compcache/.keep
Normal file
0
.cache/zsh/compcache/.keep
Normal file
0
.cache/zsh/completion/.keep
Normal file
0
.cache/zsh/completion/.keep
Normal file
0
.cache/zsh/compzwc/.keep
Normal file
0
.cache/zsh/compzwc/.keep
Normal file
0
.cache/zsh/dots/.keep
Normal file
0
.cache/zsh/dots/.keep
Normal file
0
.config/dotfiles/bin/.keep
Normal file
0
.config/dotfiles/bin/.keep
Normal file
32
.config/dotfiles/gen-gitignore.sh
Executable file
32
.config/dotfiles/gen-gitignore.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
set -ef
|
||||
|
||||
path_gitignore='.config/dotfiles/gitignore'
|
||||
|
||||
gen_gitignore() {
|
||||
git rev-parse --git-dir >/dev/null 2>&1
|
||||
touch "$1"
|
||||
{
|
||||
echo '*'
|
||||
git ls-files | sed -E 's:^:!/:'
|
||||
} > "$1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
me=$(readlink -e "$0")
|
||||
topdir=$(printf '%s' "${me}" | sed -E 's:/[^/]+/[^/]+/[^/]+$::')
|
||||
cd "${topdir}"
|
||||
|
||||
export GIT_OPTIONAL_LOCKS=0
|
||||
|
||||
dir="${me%/*}/repo.git"
|
||||
if [ -d "${dir}" ] ; then
|
||||
## end-point installation
|
||||
GIT_DIR="${dir}"
|
||||
GIT_WORK_TREE="${topdir}"
|
||||
export GIT_DIR GIT_WORK_TREE
|
||||
gen_gitignore "${GIT_WORK_TREE}/${path_gitignore}"
|
||||
else
|
||||
## development tree
|
||||
gen_gitignore "${path_gitignore}"
|
||||
fi
|
0
.config/dotfiles/gitattributes
Normal file
0
.config/dotfiles/gitattributes
Normal file
83
.config/dotfiles/gitignore
Normal file
83
.config/dotfiles/gitignore
Normal file
@@ -0,0 +1,83 @@
|
||||
*
|
||||
!/.cache/zsh/compcache/.keep
|
||||
!/.cache/zsh/completion/.keep
|
||||
!/.cache/zsh/compzwc/.keep
|
||||
!/.cache/zsh/dots/.keep
|
||||
!/.config/dotfiles/bin/.keep
|
||||
!/.config/dotfiles/gen-gitignore.sh
|
||||
!/.config/dotfiles/gitattributes
|
||||
!/.config/dotfiles/gitignore
|
||||
!/.config/dotfiles/install.sh
|
||||
!/.config/dotfiles/scripts/.keep
|
||||
!/.config/dotfiles/woodpecker.yml
|
||||
!/.config/htop/htoprc.dist
|
||||
!/.config/mc/ini.dist
|
||||
!/.config/zsh/_.zsh
|
||||
!/.config/zsh/_wip/enclave.zsh.wip
|
||||
!/.config/zsh/_wip/starship.zsh.sample
|
||||
!/.config/zsh/alias.zsh
|
||||
!/.config/zsh/alias/containers.zsh
|
||||
!/.config/zsh/alias/diff.zsh
|
||||
!/.config/zsh/alias/directories.zsh
|
||||
!/.config/zsh/alias/git.zsh
|
||||
!/.config/zsh/alias/gpg.zsh
|
||||
!/.config/zsh/alias/grep.zsh
|
||||
!/.config/zsh/alias/history.zsh
|
||||
!/.config/zsh/alias/idle.zsh
|
||||
!/.config/zsh/alias/k8s.zsh
|
||||
!/.config/zsh/alias/kconfig.zsh
|
||||
!/.config/zsh/alias/ls.zsh
|
||||
!/.config/zsh/alias/quilt.zsh
|
||||
!/.config/zsh/alias/sbuild.zsh
|
||||
!/.config/zsh/alias/sudo.zsh
|
||||
!/.config/zsh/alias/telnet.zsh
|
||||
!/.config/zsh/completion/.keep
|
||||
!/.config/zsh/completion/bash.zsh
|
||||
!/.config/zsh/completion/external.zsh
|
||||
!/.config/zsh/completion/system.zsh
|
||||
!/.config/zsh/env.zsh
|
||||
!/.config/zsh/env/aux.zsh
|
||||
!/.config/zsh/env/containers.zsh
|
||||
!/.config/zsh/env/gopath.zsh
|
||||
!/.config/zsh/env/history.zsh
|
||||
!/.config/zsh/env/ld.so.zsh
|
||||
!/.config/zsh/env/pager.zsh
|
||||
!/.config/zsh/env/quilt.zsh
|
||||
!/.config/zsh/env/xdg.zsh
|
||||
!/.config/zsh/lib.zsh
|
||||
!/.config/zsh/lib/alternatives.zsh
|
||||
!/.config/zsh/lib/cmdtime.zsh
|
||||
!/.config/zsh/lib/completion.zsh
|
||||
!/.config/zsh/lib/curl.zsh
|
||||
!/.config/zsh/lib/git.zsh
|
||||
!/.config/zsh/lib/history.zsh
|
||||
!/.config/zsh/lib/prompt.zsh
|
||||
!/.config/zsh/lib/pswalk.zsh
|
||||
!/.config/zsh/lib/say-my.zsh
|
||||
!/.config/zsh/lib/selfservice.zsh
|
||||
!/.config/zsh/lib/term.zsh
|
||||
!/.config/zsh/lib/time.zsh
|
||||
!/.config/zsh/lib/title.zsh
|
||||
!/.config/zsh/local.zsh.example
|
||||
!/.config/zsh/local/.keep
|
||||
!/.config/zsh/local/completion/.keep
|
||||
!/.config/zsh/opt.zsh
|
||||
!/.config/zsh/opt/chase.zsh
|
||||
!/.config/zsh/opt/completion.zsh
|
||||
!/.config/zsh/opt/directories.zsh
|
||||
!/.config/zsh/opt/history.zsh
|
||||
!/.config/zsh/opt/prompt.zsh
|
||||
!/.config/zsh/rc.zsh
|
||||
!/.config/zsh/rc/completion.zsh
|
||||
!/.config/zsh/rc/keyboard.zsh
|
||||
!/.config/zsh/rc/pager.zsh
|
||||
!/.config/zsh/rc/prompt.zsh
|
||||
!/.config/zsh/rc/terminal.zsh
|
||||
!/.config/zsh/var/.keep
|
||||
!/.gdbinit
|
||||
!/.gitconfig
|
||||
!/.screenrc
|
||||
!/.selected_editor
|
||||
!/.vimrc
|
||||
!/.zshenv
|
||||
!/.zshrc
|
236
.config/dotfiles/install.sh
Executable file
236
.config/dotfiles/install.sh
Executable file
@@ -0,0 +1,236 @@
|
||||
#!/bin/sh
|
||||
set -ef
|
||||
|
||||
gh_repo='rockdrilla/dotfiles'
|
||||
gh_br='main'
|
||||
|
||||
f_gitignore='.config/dotfiles/gitignore'
|
||||
u_gitignore="${GITHUB_RAW:-https://raw.githubusercontent.com}/${gh_repo}/${gh_br}/${f_gitignore}"
|
||||
|
||||
u_repo="https://github.com/${gh_repo}.git"
|
||||
d_repo='.config/dotfiles/repo.git'
|
||||
|
||||
u_tarball="${GITHUB:-https://github.com}/${gh_repo}/archive/refs/heads/${gh_br}.tar.gz"
|
||||
|
||||
have_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
fetch() {
|
||||
if have_cmd curl ; then
|
||||
curl -sSL ${2:+ -o "$2" } "$1"
|
||||
return
|
||||
fi
|
||||
if have_cmd wget ; then
|
||||
if [ -n "$2" ] ; then
|
||||
wget -q -O - "$1" > "$2"
|
||||
else
|
||||
wget -q -O - "$1"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
if have_cmd /usr/lib/apt/apt-helper ; then
|
||||
if [ -n "$2" ] ; then
|
||||
/usr/lib/apt/apt-helper download-file "$1" "$2"
|
||||
return
|
||||
fi
|
||||
__fetch_t=$(mktemp) || return 1
|
||||
set +e
|
||||
(
|
||||
set -e
|
||||
/usr/lib/apt/apt-helper download-file "$1" "${__fetch_t}"
|
||||
cat "${__fetch_t}"
|
||||
)
|
||||
__fetch_r=$?
|
||||
rm -f "${__fetch_t}" ; unset __fetch_t
|
||||
return ${__fetch_r}
|
||||
fi
|
||||
echo 'no method is available to fetch URLs' >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
main() {
|
||||
## dry run to test connectivity
|
||||
fetch "${u_gitignore}" >/dev/null
|
||||
|
||||
umask 0077
|
||||
|
||||
if have_cmd git ; then
|
||||
if [ -s "${HOME}/${d_repo}/HEAD" ] ; then
|
||||
dot_update
|
||||
else
|
||||
dot_install
|
||||
fi
|
||||
else
|
||||
echo 'git is missing, proceed "raw" installation.' >&2
|
||||
dot_install_raw
|
||||
fi
|
||||
|
||||
propagate_dist_files
|
||||
|
||||
echo 'installed.' >&2
|
||||
}
|
||||
|
||||
dot_install() {
|
||||
backup_unconditionally
|
||||
git_env
|
||||
mkdir -p "${GIT_DIR}"
|
||||
git init
|
||||
git branch -M "${gh_br}" || true
|
||||
git_config_init
|
||||
git_update
|
||||
}
|
||||
|
||||
dot_update() {
|
||||
git_env
|
||||
git_update
|
||||
}
|
||||
|
||||
find_fast() {
|
||||
find "$@" -printf . -quit | grep -Fq .
|
||||
}
|
||||
|
||||
dot_install_raw() {
|
||||
tf_tar=$(mktemp)
|
||||
fetch "${u_tarball}" "${tf_tar}"
|
||||
|
||||
td_tree=$(mktemp -d)
|
||||
|
||||
if ! tar_try_extract "${tf_tar}" "${td_tree}" "${f_gitignore}" ; then
|
||||
rm -rf "${tf_tar}" "${td_tree}"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "${tf_tar}"
|
||||
|
||||
tf_list=$(mktemp)
|
||||
fetch "${u_gitignore}" \
|
||||
| sed -En '/^!\/(.+)$/{s//\1/;p;}' \
|
||||
> "${tf_list}"
|
||||
|
||||
td_backup=$(mktemp -d)
|
||||
while read -r f ; do
|
||||
if [ -f "${HOME}/$f" ] ; then
|
||||
if cmp_files "${td_tree}" "${HOME}" "$f" ; then
|
||||
continue
|
||||
fi
|
||||
d=$(dirname "$f")
|
||||
if [ -n "$d" ] ; then
|
||||
mkdir -p "${td_backup}/$d"
|
||||
fi
|
||||
cat < "${HOME}/$f" > "${td_backup}/$f"
|
||||
fi
|
||||
done < "${tf_list}"
|
||||
rm -f "${tf_list}" ; unset tf_list
|
||||
|
||||
tar -C "${td_tree}" -cf . - | tar -C "${HOME}" -xf -
|
||||
rm -rf "${td_tree}"
|
||||
|
||||
if find_fast "${td_backup}/" -mindepth 1 ; then
|
||||
echo "backed-up files are here: ${td_backup}/"
|
||||
find "${td_backup}/" -mindepth 1 -ls
|
||||
else
|
||||
rmdir "${td_backup}"
|
||||
fi
|
||||
}
|
||||
|
||||
git_env() {
|
||||
GIT_DIR="${HOME}/${d_repo}"
|
||||
GIT_WORK_TREE="${HOME}"
|
||||
export GIT_DIR GIT_WORK_TREE
|
||||
}
|
||||
|
||||
git_config_init() {
|
||||
## remote
|
||||
git remote add origin "${u_repo}"
|
||||
git config remote.origin.fetch "+refs/heads/${gh_br}:refs/remotes/origin/${gh_br}"
|
||||
git config remote.origin.tagopt '--no-tags'
|
||||
git config "branch.${gh_br}.remote" origin
|
||||
## repo-specific
|
||||
git config core.worktree "${GIT_WORK_TREE}"
|
||||
git config core.excludesfile "${f_gitignore}"
|
||||
}
|
||||
|
||||
git_config() {
|
||||
## repo-specific
|
||||
git config core.attributesfile .config/dotfiles/gitattributes
|
||||
## migration (remove later)
|
||||
git config --unset gc.auto
|
||||
git config --unset pull.ff
|
||||
## size optimization
|
||||
git config core.compression 9
|
||||
git config pack.compression 9
|
||||
## generic
|
||||
git config receive.denyNonFastForwards true
|
||||
}
|
||||
|
||||
git_update() {
|
||||
git_config
|
||||
git remote update -p
|
||||
git pull || git reset --hard "origin/${gh_br}"
|
||||
git gc --aggressive --prune=all --force || git gc || true
|
||||
}
|
||||
|
||||
tar_test() {
|
||||
tar --wildcards -tf "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
tar_try_extract() {
|
||||
if tar_test "$1" "$3" ; then
|
||||
tar -C "$2" -xf "$2"
|
||||
return
|
||||
fi
|
||||
opt='--strip-components=1'
|
||||
if tar_test "$1" ${opt} "*/$3" ; then
|
||||
tar -C "$2" ${opt} -xf "$2"
|
||||
return
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
cmp_files() {
|
||||
cmp -s "$1/$3" "$2/$3" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
backup_unconditionally() {
|
||||
tf_list=$(mktemp)
|
||||
fetch "${u_gitignore}" \
|
||||
| sed -En '/^!\/(.+)$/{s//\1/;p;}' \
|
||||
> "${tf_list}"
|
||||
|
||||
td_backup=$(mktemp -d)
|
||||
while read -r f ; do
|
||||
if [ -f "${HOME}/$f" ] ; then
|
||||
d=$(dirname "$f")
|
||||
if [ -n "$d" ] ; then
|
||||
mkdir -p "${td_backup}/$d"
|
||||
fi
|
||||
mv -f "${HOME}/$f" "${td_backup}/$f"
|
||||
fi
|
||||
done < "${tf_list}"
|
||||
rm -f "${tf_list}" ; unset tf_list
|
||||
|
||||
if find_fast "${td_backup}/" -mindepth 1 ; then
|
||||
echo "backed-up files are here: ${td_backup}/"
|
||||
find "${td_backup}/" -mindepth 1 -ls
|
||||
else
|
||||
rmdir "${td_backup}"
|
||||
fi
|
||||
}
|
||||
|
||||
propagate_dist_files() {
|
||||
tf_list=$(mktemp)
|
||||
sed -En '/^!\/(.+\.dist)$/{s//\1/;p;}' < "${HOME}/${f_gitignore}" > "${tf_list}"
|
||||
|
||||
while read -r f_dist ; do
|
||||
[ -n "${f_dist}" ] || continue
|
||||
[ -f "${f_dist}" ] || continue
|
||||
|
||||
f=${f_dist%.dist}
|
||||
if [ -f "$f" ] ; then continue ; fi
|
||||
|
||||
cp "${f_dist}" "$f"
|
||||
done < "${tf_list}"
|
||||
rm -f "${tf_list}" ; unset tf_list
|
||||
}
|
||||
|
||||
main "$@"
|
0
.config/dotfiles/scripts/.keep
Normal file
0
.config/dotfiles/scripts/.keep
Normal file
38
.config/dotfiles/woodpecker.yml
Normal file
38
.config/dotfiles/woodpecker.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
steps:
|
||||
- name: check
|
||||
image: debian:bookworm-slim
|
||||
environment:
|
||||
DEBCONF_NONINTERACTIVE_SEEN: "true"
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
DEBIAN_PRIORITY: critical
|
||||
TERM: linux
|
||||
MALLOC_ARENA_MAX: "4"
|
||||
commands:
|
||||
- |
|
||||
: # install required packages
|
||||
apt-get -y update
|
||||
apt-get -y install file findutils git shellcheck zsh
|
||||
apt-get -y clean
|
||||
- |
|
||||
: # verify that repo doesn't contain "garbage"
|
||||
find_fast() {
|
||||
find "$@" -printf . -quit | grep -Fq .
|
||||
}
|
||||
if find_fast ./ -type f -name '*.zwc' ; then
|
||||
echo 'found *.zwc' >&2
|
||||
find ./ -type f -name '*.zwc'
|
||||
exit 1
|
||||
fi
|
||||
- |
|
||||
: # try zsh compile
|
||||
git ls-files | sort -uV | xargs -r file -N -i | grep text/x-shellscript | cut -d: -f1 \
|
||||
| xargs -r -n1 zsh -efc 'zcompile -UR "$@"' --
|
||||
find ./ -type f -name '*.zwc' -delete
|
||||
- |
|
||||
: # try shellcheck (except for *.zsh)
|
||||
git ls-files | grep -Fv '.zsh' | sort -uV | xargs -r file -N -i | grep text/x-shellscript | cut -d: -f1 \
|
||||
| xargs -r -n1 shellcheck
|
||||
|
||||
## personal tweaks :)
|
||||
labels:
|
||||
network: dmz
|
65
.config/htop/htoprc.dist
Normal file
65
.config/htop/htoprc.dist
Normal file
@@ -0,0 +1,65 @@
|
||||
# Beware! This file is rewritten by htop when settings are changed in the interface.
|
||||
# The parser is also very primitive, and not human-friendly.
|
||||
htop_version=3.3.0
|
||||
config_reader_min_version=3
|
||||
fields=0 48 17 18 38 39 40 2 46 47 49 1
|
||||
hide_kernel_threads=1
|
||||
hide_userland_threads=1
|
||||
hide_running_in_container=0
|
||||
shadow_other_users=0
|
||||
show_thread_names=1
|
||||
show_program_path=1
|
||||
highlight_base_name=1
|
||||
highlight_deleted_exe=1
|
||||
shadow_distribution_path_prefix=1
|
||||
highlight_megabytes=1
|
||||
highlight_threads=1
|
||||
highlight_changes=0
|
||||
highlight_changes_delay_secs=5
|
||||
find_comm_in_cmdline=1
|
||||
strip_exe_from_cmdline=1
|
||||
show_merged_command=0
|
||||
header_margin=1
|
||||
screen_tabs=1
|
||||
detailed_cpu_time=1
|
||||
cpu_count_from_one=0
|
||||
show_cpu_usage=1
|
||||
show_cpu_frequency=1
|
||||
show_cpu_temperature=1
|
||||
degree_fahrenheit=0
|
||||
update_process_names=0
|
||||
account_guest_in_cpu_meter=1
|
||||
color_scheme=0
|
||||
enable_mouse=1
|
||||
delay=11
|
||||
hide_function_bar=0
|
||||
header_layout=three_30_40_30
|
||||
column_meters_0=Hostname System DateTime Uptime Blank Tasks LoadAverage FileDescriptors
|
||||
column_meter_modes_0=2 2 2 2 2 2 2 2
|
||||
column_meters_1=Memory HugePages Swap Blank AllCPUs2
|
||||
column_meter_modes_1=1 1 1 2 1
|
||||
column_meters_2=DiskIO NetworkIO Battery Blank PressureStallCPUSome PressureStallMemorySome PressureStallMemoryFull PressureStallIOSome PressureStallIOFull
|
||||
column_meter_modes_2=2 2 2 2 2 2 2 2 2
|
||||
tree_view=1
|
||||
sort_key=46
|
||||
tree_sort_key=0
|
||||
sort_direction=-1
|
||||
tree_sort_direction=1
|
||||
tree_view_always_by_pid=1
|
||||
all_branches_collapsed=0
|
||||
screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command
|
||||
.sort_key=PERCENT_CPU
|
||||
.tree_sort_key=PID
|
||||
.tree_view_always_by_pid=1
|
||||
.tree_view=1
|
||||
.sort_direction=-1
|
||||
.tree_sort_direction=1
|
||||
.all_branches_collapsed=0
|
||||
screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command
|
||||
.sort_key=PID
|
||||
.tree_sort_key=PID
|
||||
.tree_view_always_by_pid=1
|
||||
.tree_view=1
|
||||
.sort_direction=-1
|
||||
.tree_sort_direction=1
|
||||
.all_branches_collapsed=0
|
2
.config/mc/ini.dist
Normal file
2
.config/mc/ini.dist
Normal file
@@ -0,0 +1,2 @@
|
||||
[Midnight-Commander]
|
||||
skin=dark
|
52
.config/zsh/_.zsh
Normal file
52
.config/zsh/_.zsh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -gA ZSHU
|
||||
|
||||
ZSHU[t_begin]=${(%):-%D{%s.%6.}}
|
||||
|
||||
ZSHU[d_zdot]="${ZDOTDIR}"
|
||||
ZSHU[d_dotfiles]="${ZDOTDIR}/.config/dotfiles"
|
||||
ZSHU[d_conf]="${ZDOTDIR}/.config/zsh"
|
||||
ZSHU[d_cache]="${ZDOTDIR}/.cache/zsh"
|
||||
|
||||
ZSHU[d_var]="${ZSHU[d_conf]}/var"
|
||||
ZSHU[d_bin]="${ZSHU[d_dotfiles]}/bin"
|
||||
ZSHU[d_scripts]="${ZSHU[d_dotfiles]}/scripts"
|
||||
|
||||
## early escape
|
||||
unsetopt global_rcs
|
||||
|
||||
## safety measure:
|
||||
## redirect all following activity within ZDOTDIR to cache
|
||||
export ZDOTDIR="${ZSHU[d_cache]}/dots"
|
||||
|
||||
## cleanup: start from scratch
|
||||
for i ( a s f d ) ; do unhash -$i -m '*' ; done ; unset i
|
||||
|
||||
## set default umask
|
||||
umask 0022
|
||||
|
||||
zshu_parts=( env opt lib rc alias local )
|
||||
|
||||
for n ( ${zshu_parts} ) ; do
|
||||
[ -s "${ZSHU[d_conf]}/$n.zsh" ] || continue
|
||||
source "${ZSHU[d_conf]}/$n.zsh"
|
||||
done ; unset n
|
||||
|
||||
for n ( ${zshu_parts} ) ; do
|
||||
[ -d "${ZSHU[d_conf]}/$n" ] || continue
|
||||
for i ( "${ZSHU[d_conf]}/$n"/*.zsh(N.r) ) ; do
|
||||
source "$i"
|
||||
done
|
||||
done ; unset i n
|
||||
|
||||
unset zshu_parts
|
||||
|
||||
hash -f
|
||||
|
||||
t=${(%):-%D{%s.%6.}}
|
||||
t=$[ t - ZSHU[t_begin] ]
|
||||
unset 'ZSHU[t_begin]'
|
||||
n=${t#*.}
|
||||
ZSHU[t_load]=${t%.*}.${n:0:4}
|
||||
unset n t
|
63
.config/zsh/_wip/enclave.zsh.wip
Normal file
63
.config/zsh/_wip/enclave.zsh.wip
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/bin/zsh
|
||||
|
||||
if autoload -Uz add-zsh-hook ; then
|
||||
|
||||
ZSHU[f_enclave]="${ZSHU[d_var]}/enclave"
|
||||
[ -f "${ZSHU[f_enclave]}" ] || touch "${ZSHU[f_enclave]}"
|
||||
[ -s "${ZSHU[f_enclave]}" ] && . "${ZSHU[f_enclave]}"
|
||||
|
||||
## <test data>
|
||||
test_enclave_enter() { echo "you are in $1 enclave" 1>&2 ; }
|
||||
test_enclave_leave() { echo "you are left $1 enclave" 1>&2 ; }
|
||||
|
||||
zstyle ":enclave:box1:path:${HOME}/prj/*" ''
|
||||
zstyle ":enclave:box1:path:${HOME}/prj/_stale/*" exclude
|
||||
zstyle ':enclave:box1:env:unset' 'var2'
|
||||
zstyle ':enclave:box1:env:set' 'var1' 1
|
||||
zstyle ':enclave:box1:on_enter' test_enclave_enter
|
||||
zstyle ':enclave:box1:on_leave' test_enclave_leave
|
||||
|
||||
zstyle ":enclave:box2:path:${HOME}/doc/*" ''
|
||||
zstyle ":enclave:box2:path:${HOME}/doc/work/*" exclude
|
||||
zstyle ':enclave:box2:env:unset' 'var1'
|
||||
zstyle ':enclave:box2:env:set' 'var2' 1
|
||||
zstyle ':enclave:box2:on_enter' test_enclave_enter
|
||||
zstyle ':enclave:box2:on_leave' test_enclave_leave
|
||||
|
||||
typeset -g var1=0
|
||||
typeset -g var2=0
|
||||
## </test data>
|
||||
|
||||
__z_enclave_list() {
|
||||
local -aU list=( $(zstyle -L ':enclave:*' \
|
||||
| sed -En "/^zstyle '?:enclave:([^:]+):.*\$/{s//\1/;p;}") )
|
||||
printf '%s' "${(j: :)list}"
|
||||
}
|
||||
|
||||
__z_chpwd_enclave() {
|
||||
[ -z "${PWD}" ] && return
|
||||
## enclave changed? if no - do nothing
|
||||
[ -z "${OLDPWD}" ] && return
|
||||
[ "${PWD}" = "${OLDPWD}" ] && return
|
||||
|
||||
local a
|
||||
zstyle -s ":enclave:*:path:$PWD" '' a && \
|
||||
declare -p a
|
||||
|
||||
## call on_leave()
|
||||
## unset previously set
|
||||
## set previously set
|
||||
|
||||
env > /tmp/env
|
||||
}
|
||||
|
||||
# zstyle -L ':enclave:*'
|
||||
# echo
|
||||
|
||||
|
||||
add-zsh-hook chpwd __z_chpwd_enclave
|
||||
__z_chpwd_enclave
|
||||
|
||||
else
|
||||
echo "enclaves are disabled due to missing hook support" 1>&2
|
||||
fi
|
205
.config/zsh/_wip/starship.zsh.sample
Normal file
205
.config/zsh/_wip/starship.zsh.sample
Normal file
@@ -0,0 +1,205 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## inspired by 'https://starship.rs/install.sh' as of 2021-03-07
|
||||
|
||||
ZSHU[starship_baseurl]='https://github.com/starship/starship/releases'
|
||||
## ZSHU[starship_target] is auto-detected
|
||||
## ZSHU[starship_path] defaults to ZSHU[d_bin] which is in PATH already
|
||||
|
||||
# export STARSHIP_CONFIG="$HOME/.config/starship.toml"
|
||||
# export STARSHIP_CACHE="$HOME/.cache/starship"
|
||||
|
||||
__z_starship_auto_path() {
|
||||
echo "${ZSHU[starship_path]:-${ZSHU[d_bin]}}"
|
||||
}
|
||||
|
||||
__z_starship() {
|
||||
local x=$(__z_starship_auto_path)
|
||||
x="$x/starship"
|
||||
[ -x "$x" ] || x=starship
|
||||
[ -x "$x" ] || return 127
|
||||
"$x" "$@"
|
||||
}
|
||||
|
||||
__z_starship_test() { __z_starship -V &>/dev/null ; }
|
||||
|
||||
## NB: supply TARGET environment variable to call
|
||||
__z_starship_url_latest() {
|
||||
printf '%s/latest/download/starship-%s.tar.gz' \
|
||||
"${ZSHU[starship_baseurl]}" "${TARGET}"
|
||||
}
|
||||
|
||||
## NB: supply TARGET environment variable to call
|
||||
## $1 - version (semver like '0.50.0')
|
||||
__z_starship_url_versioned() {
|
||||
printf '%s/download/v%s/starship-%s.tar.gz' \
|
||||
"${ZSHU[starship_baseurl]}" "$1" "${TARGET}"
|
||||
}
|
||||
|
||||
## NB: install starship somewhere in PATH ;)
|
||||
__z_starship_ver_installed() {
|
||||
__z_starship -V 2>/dev/null \
|
||||
| sed -En '/^starship v?(\S.+)$/{s//\1/;p;}'
|
||||
}
|
||||
|
||||
## NB: supply TARGET environment variable to call
|
||||
__z_starship_ver_latest() {
|
||||
local x=$(__z_starship_url_latest)
|
||||
local y=$(__z_curl_location "$x")
|
||||
## hackish strip, e.g.:
|
||||
## from: https://github.com/starship/starship/releases/download/v0.50.0/starship-x86_64-unknown-linux-musl.tar.gz
|
||||
## to: v0.50.0
|
||||
y=${y:h:t}
|
||||
[ "${y:0:1}" = 'v' ] && y=${y:1}
|
||||
echo "$y"
|
||||
}
|
||||
|
||||
__z_starship_detect_arch() {
|
||||
local arch=${ZSHU[mach]}
|
||||
case "${arch}" in
|
||||
x86_64) [ "$(getconf LONG_BIT)" -eq 32 ] && arch=i686 ;;
|
||||
aarch64) [ "$(getconf LONG_BIT)" -eq 32 ] && arch=arm ;;
|
||||
esac
|
||||
echo "${arch}"
|
||||
}
|
||||
|
||||
__z_starship_detect_platform() {
|
||||
local platform=${ZSHU[uname]}
|
||||
case "${ZSHU[uname]}" in
|
||||
msys_nt*) platform=pc-windows-msvc ;;
|
||||
cygwin_nt*) platform=pc-windows-msvc ;;
|
||||
mingw*) platform=pc-windows-msvc ;;
|
||||
linux) platform=unknown-linux-musl ;; ## static builds
|
||||
darwin) platform=apple-darwin ;;
|
||||
freebsd) platform=unknown-freebsd ;;
|
||||
esac
|
||||
echo "${platform}"
|
||||
}
|
||||
|
||||
## $1 - arch
|
||||
## $2 - platform
|
||||
__z_starship_detect_target() {
|
||||
local target="$1-$2"
|
||||
case "${target}" in
|
||||
arm-unknown-linux-musl) target="${target}eabihf" ;;
|
||||
esac
|
||||
echo "${target}"
|
||||
}
|
||||
|
||||
__z_starship_auto_target() {
|
||||
[ -n "${ZSHU[starship_target]}" ] && echo "${ZSHU[starship_target]}" && return
|
||||
local arch=$(__z_starship_detect_arch)
|
||||
local platform=$(__z_starship_detect_platform)
|
||||
local target=$(__z_starship_detect_target "${arch}" "${platform}")
|
||||
echo "${target}"
|
||||
}
|
||||
|
||||
__z_starship_install() {
|
||||
local ver=${1:-latest}
|
||||
local target url resp
|
||||
target=$(__z_starship_auto_target)
|
||||
if [ "${ver}" = 'latest' ] ; then
|
||||
url=$(TARGET=${target} __z_starship_url_latest)
|
||||
resp=$(__z_curl_response "${url}")
|
||||
resp=${resp:-400}
|
||||
[ ${resp} -ge 400 ] && return 1
|
||||
else
|
||||
url=$(TARGET=${target} __z_starship_url_versioned "${ver}")
|
||||
resp=$(__z_curl_response "${url}")
|
||||
resp=${resp:-400}
|
||||
if [ ${resp} -ge 400 ] ; then
|
||||
## last resort: try messing with version ;D
|
||||
if [ "${ver:0:1}" = 'v' ] ; then
|
||||
ver=${ver:1}
|
||||
else
|
||||
ver="v${ver}"
|
||||
fi
|
||||
url=$(TARGET=${target} __z_starship_url_versioned "${ver}")
|
||||
resp=$(__z_curl_response "${url}")
|
||||
resp=${resp:-400}
|
||||
[ ${resp} -ge 400 ] && return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local t=$(mktemp -d)
|
||||
local f="$t/starship.tar.gz"
|
||||
command curl -sqL "${url}" > "$f"
|
||||
command tar -C "$t" -xf "$f" starship &>/dev/null
|
||||
if [ $? -ne 0 ] ; then
|
||||
## last resort
|
||||
command tar -C "$t" --strip-components=1 --wildcards -xf "$f" '*/starship' &>/dev/null
|
||||
if [ $? -ne 0 ] ; then
|
||||
rm -rf "$t"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
local d=$(__z_starship_auto_path)
|
||||
mv "$t/starship" "$d/"
|
||||
local r=$?
|
||||
if [ $r -eq 0 ] ; then
|
||||
[ "${ver:0:1}" = 'v' ] && ver=${ver:1}
|
||||
echo "starship: installed ${ver} version in $d/" 1>&2
|
||||
fi
|
||||
rm -rf "$t"
|
||||
return $r
|
||||
}
|
||||
|
||||
z-starship-target-available() {
|
||||
local target url resp
|
||||
target=$(__z_starship_auto_target)
|
||||
url=$(TARGET=${target} __z_starship_url_latest)
|
||||
resp=$(__z_curl_response "${url}")
|
||||
resp=${resp:-400}
|
||||
if [ ${resp} -lt 400 ] ; then
|
||||
echo "starship: available for ${target}" 1>&2
|
||||
return 0
|
||||
else
|
||||
echo "starship: NOT available for ${target}" 1>&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
z-starship-update-available() {
|
||||
local target=$(__z_starship_auto_target)
|
||||
local installed=$(__z_starship_ver_installed)
|
||||
local latest=$(TARGET=${target} __z_starship_ver_latest)
|
||||
if [ -z "${latest}" ] ; then
|
||||
echo "starship: update is NOT available" 1>&2
|
||||
return 1
|
||||
fi
|
||||
if [ -z "${installed}" ] ; then
|
||||
echo "starship: NOT installed, install it 1st" 1>&2
|
||||
return 0
|
||||
fi
|
||||
local tailver=$(printf '%s\n' "${installed}" "${latest}" | sort -Vu | tail -n 1)
|
||||
if [ "${installed}" = "${tailver}" ] ; then
|
||||
if [ "${installed}" = "${latest}" ] ; then
|
||||
echo "starship: local version is up to date" 1>&2
|
||||
else
|
||||
echo "starship: local version is newer! o_O" 1>&2
|
||||
fi
|
||||
return 1
|
||||
else
|
||||
echo "starship: update is available (${installed} -> ${latest})" 1>&2
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
z-starship-init() {
|
||||
[ -n "${ZSHU[starship_init]}" ] && return
|
||||
__z_starship_test || return
|
||||
eval "$(__z_starship init zsh)"
|
||||
ZSHU[starship_init]=1
|
||||
}
|
||||
|
||||
z-starship-install() {
|
||||
z-starship-target-available || return
|
||||
__z_starship_install || \
|
||||
echo "starship: unable to install" 1>&2
|
||||
}
|
||||
|
||||
z-starship-update() {
|
||||
z-starship-update-available || return 0
|
||||
__z_starship_install || \
|
||||
echo "starship: unable to update" 1>&2
|
||||
}
|
5
.config/zsh/alias.zsh
Normal file
5
.config/zsh/alias.zsh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
alias which='whence -p '
|
||||
alias which-command='whence -p '
|
||||
alias zsh-which='whence -c '
|
51
.config/zsh/alias/containers.zsh
Normal file
51
.config/zsh/alias/containers.zsh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/bin/zsh
|
||||
|
||||
alias bud='buildah bud --isolation chroot --network host --format docker -f '
|
||||
|
||||
alias pod-run='podman run -e "TERM=${TERM:-linux}" --rm -it '
|
||||
alias pod-run-sh="pod-run --network host --entrypoint='[\"/bin/sh\"]' --user=0:0 "
|
||||
alias pod-ps='podman ps '
|
||||
alias pod-images='podman images --format "table {{.ID}} {{.Repository}}:{{.Tag}} {{.Size}} {{.Created}} |{{.CreatedAt}}" '
|
||||
alias pod-inspect='podman inspect '
|
||||
alias pod-logs='podman logs '
|
||||
|
||||
sko-inspect() {
|
||||
local i
|
||||
i="${1:?}" ; shift
|
||||
command skopeo inspect "docker://$i" "$@"
|
||||
}
|
||||
|
||||
sko-list-tags() {
|
||||
local i
|
||||
i="${1:?}" ; shift
|
||||
command skopeo list-tags "docker://$i" "$@"
|
||||
}
|
||||
|
||||
pod-dive() {
|
||||
local i
|
||||
i="${1:?}" ; shift
|
||||
command dive "podman://$i" "$@"
|
||||
}
|
||||
|
||||
jq-visual() {
|
||||
jq -C | less
|
||||
}
|
||||
|
||||
jq-config() {
|
||||
jq '.[].Config'
|
||||
}
|
||||
|
||||
jq-tags() {
|
||||
jq -r '.Tags[]'
|
||||
}
|
||||
|
||||
if [ ${UID} -ne 0 ] ; then
|
||||
alias docker='sudo docker '
|
||||
fi
|
||||
alias dkr='docker '
|
||||
alias dkr-run='dkr run -e "TERM=${TERM:-linux}" --network host --rm -it '
|
||||
alias dkr-run-sh="dkr-run --entrypoint='' --user=0:0 "
|
||||
alias dkr-ps='dkr ps '
|
||||
alias dkr-images='dkr images --format "table {{.ID}}\\t{{.Repository}}:{{.Tag}}\\t{{.Size}}\\t{{.CreatedAt}}" '
|
||||
alias dkr-inspect='dkr inspect '
|
||||
alias dkr-logs='dkr logs '
|
5
.config/zsh/alias/diff.zsh
Normal file
5
.config/zsh/alias/diff.zsh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-alt-set-static \
|
||||
'diff|. .' \
|
||||
'diff --color=auto|diff'
|
31
.config/zsh/alias/directories.zsh
Normal file
31
.config/zsh/alias/directories.zsh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## alias -g ...='../..'
|
||||
## alias -g ....='../../..'
|
||||
## ...
|
||||
for (( i=3 ; i < 10 ; i++ )) ; do
|
||||
alias -g ${(l:i::.:)}='..'${(l:3*(i-2)::/..:)}
|
||||
done ; unset i
|
||||
|
||||
alias -- -='cd -'
|
||||
alias 1='cd -'
|
||||
## alias 2='cd -2'
|
||||
## ...
|
||||
for (( i=2 ; i < 10 ; i++ )) ; do
|
||||
alias $i="cd -$i"
|
||||
done ; unset i
|
||||
|
||||
## "Go to Dir" - create path if missing
|
||||
gd() {
|
||||
[ $# -lt 2 ] || echo "# gd() takes no more than one argument, seen instead: $#" >&2
|
||||
|
||||
case "$#" in
|
||||
0 ) cd ;;
|
||||
* )
|
||||
if ! [ -d "$1" ] ; then
|
||||
mkdir -p "$1" || return $?
|
||||
fi
|
||||
cd "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
54
.config/zsh/alias/git.zsh
Normal file
54
.config/zsh/alias/git.zsh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/zsh
|
||||
|
||||
git-dir-usage() {
|
||||
local gitdir x topdir
|
||||
gitdir=$(__z_git rev-parse --git-dir) || return $?
|
||||
x=$(__z_git rev-parse --path-format=absolute 2>/dev/null) || return $?
|
||||
if [ -n "$x" ] ; then
|
||||
## older git version which does not support "--path-format=absolute"
|
||||
: TODO
|
||||
else
|
||||
gitdir=$(__z_git rev-parse --path-format=absolute --git-dir) || return $?
|
||||
fi
|
||||
|
||||
case "${gitdir}" in
|
||||
*/* ) topdir=${gitdir:h} ; gitdir=${gitdir:t} ;;
|
||||
esac
|
||||
|
||||
local -a subdirs
|
||||
subdirs+="${gitdir}/logs/refs"
|
||||
subdirs+="${gitdir}/objects/info"
|
||||
subdirs+="${gitdir}/objects/pack"
|
||||
|
||||
if [ -n "${topdir}" ] ; then
|
||||
env -C "${topdir}" du -d1 "${gitdir}"
|
||||
env -C "${topdir}" du -d1 "${subdirs[@]}"
|
||||
else
|
||||
du -d1 "${gitdir}"
|
||||
du -d1 "${subdirs[@]}"
|
||||
fi | grep -Ev '^[0-9]\s' | sort -Vk2
|
||||
}
|
||||
|
||||
git-gc() {
|
||||
git-dir-usage || return $?
|
||||
echo
|
||||
idle git gc "$@"
|
||||
echo
|
||||
git-dir-usage
|
||||
}
|
||||
|
||||
git-gc-force() {
|
||||
git-gc --aggressive --force
|
||||
}
|
||||
|
||||
git-archive-ref() {
|
||||
local name ver gitref topdir c_hash c_time out
|
||||
name="${1:?}" ver="${2:?}" gitref="${3:?}"
|
||||
topdir=$(__z_git rev-parse --show-toplevel) || return $?
|
||||
c_hash=$(__z_git log -n 1 --format='%h' --abbrev=8 "${gitref}") || return $?
|
||||
c_time=$(__z_git log -n 1 --format='%cd' --date='format:%Y%m%d.%H%M%S' "${gitref}") || return $?
|
||||
out="${name}_${ver}+git.${c_time}.${c_hash}.tar"
|
||||
topdir=${topdir:h}
|
||||
git archive --format=tar -o "${topdir}/${out}" --prefix="${name}-${ver}-git.${c_hash}/" "${gitref}" || return $?
|
||||
echo "archived to ${out} in ${topdir}/" >&2
|
||||
}
|
14
.config/zsh/alias/gpg.zsh
Normal file
14
.config/zsh/alias/gpg.zsh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/zsh
|
||||
|
||||
gpg-warmup() {
|
||||
(( ${+commands[gpg]} )) || return 1
|
||||
|
||||
local t r
|
||||
|
||||
t=$(mktemp)
|
||||
command gpg -abs "$t"
|
||||
r=$?
|
||||
rm -f "$t" "$t.asc"
|
||||
|
||||
return "$r"
|
||||
}
|
31
.config/zsh/alias/grep.zsh
Normal file
31
.config/zsh/alias/grep.zsh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-alt-grep() {
|
||||
local -a a
|
||||
local n
|
||||
|
||||
a=( ${(@s:|:)1} )
|
||||
[ ${#a} = 0 ] && a=( "$1" )
|
||||
n=${#a}
|
||||
[ -z "$1" ] && n=0
|
||||
case "$n" in
|
||||
0 ) ;;
|
||||
* )
|
||||
z-alt-set-static \
|
||||
"grep|-q -e ' ' ${ZSHU[d_conf]}/_.zsh" \
|
||||
"$1" \
|
||||
"GREP_OPTIONS='' command" \
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
## TODO: add --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}
|
||||
GREP_GNU='--color=auto'
|
||||
|
||||
z-alt-grep "grep ${GREP_GNU}|grep"
|
||||
unfunction z-alt-grep
|
||||
unset GREP_GNU
|
||||
|
||||
alias grep='grep '
|
||||
alias egrep='grep -E '
|
||||
alias fgrep='grep -F '
|
5
.config/zsh/alias/history.zsh
Normal file
5
.config/zsh/alias/history.zsh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
fc() { builtin fc -i "$@" ; }
|
||||
|
||||
# history() { builtin fc -il "$@" ; }
|
42
.config/zsh/alias/idle.zsh
Normal file
42
.config/zsh/alias/idle.zsh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/zsh
|
||||
|
||||
idle() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local f
|
||||
|
||||
f=$(type "$1")
|
||||
case "$f" in
|
||||
"$1 is /"* )
|
||||
z-idle-ext "$@"
|
||||
;;
|
||||
* )
|
||||
z-idle-int "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
z-idle-ext() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local -a s
|
||||
|
||||
s+=( $(z-alt-find 'nice -n +40') )
|
||||
s+=( $(z-alt-find 'chrt -i 0' ) )
|
||||
s+=( $(z-alt-find 'ionice -c 3') )
|
||||
command ${s[@]} "$@"
|
||||
}
|
||||
|
||||
z-idle-int() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
## execute in subshell
|
||||
(
|
||||
{
|
||||
command renice -n +40 -p ${sysparams[pid]}
|
||||
command chrt -i -p 0 ${sysparams[pid]}
|
||||
command ionice -c 3 -p ${sysparams[pid]}
|
||||
} </dev/null &>/dev/null
|
||||
"$@"
|
||||
)
|
||||
}
|
3
.config/zsh/alias/k8s.zsh
Normal file
3
.config/zsh/alias/k8s.zsh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
|
||||
alias k='kubectl '
|
25
.config/zsh/alias/kconfig.zsh
Normal file
25
.config/zsh/alias/kconfig.zsh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/zsh
|
||||
|
||||
kconf-set() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local n=$1 v=$2
|
||||
shift 2
|
||||
|
||||
[ $# -gt 0 ] || return 2
|
||||
|
||||
command grep -ElZ "^((CONFIG_)?$n=|# (CONFIG_)?$n is not set)" "$@" \
|
||||
| xargs -0 -r sed -i -E -e "s/^(((CONFIG_)?$n)=.+|# ((CONFIG_)?$n) is not set)\$/\\2\\4=$v/"
|
||||
}
|
||||
|
||||
kconf-unset() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local n=$1
|
||||
shift
|
||||
|
||||
[ $# -gt 0 ] || return 2
|
||||
|
||||
command grep -ElZ "^(CONFIG_)?$n=" "$@" \
|
||||
| xargs -0 -r sed -i -E -e "s/^((CONFIG_)?$n)=.+\$/# \\1 is not set/"
|
||||
}
|
57
.config/zsh/alias/ls.zsh
Normal file
57
.config/zsh/alias/ls.zsh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/zsh
|
||||
|
||||
if [ -z "${LS_COLORS}" ] ; then
|
||||
(( $+commands[dircolors] )) && eval "$(dircolors -b)"
|
||||
fi
|
||||
|
||||
case "${ZSHU[os_family]}" in
|
||||
bsd | darwin ) export LSCOLORS="Gxfxcxdxbxegedabagacad" ;;
|
||||
esac
|
||||
|
||||
z-alt-ls() {
|
||||
local -a a
|
||||
local n
|
||||
|
||||
a=( ${(@s:|:)1} )
|
||||
[ ${#a} = 0 ] && a=( "$1" )
|
||||
n=${#a}
|
||||
[ -z "$1" ] && n=0
|
||||
case "$n" in
|
||||
0 ) ;;
|
||||
* )
|
||||
z-alt-set-static \
|
||||
'ls|-d .' \
|
||||
"$1" \
|
||||
"LS_OPTIONS='' command"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
LS_GNU='--color=tty --group-directories-first'
|
||||
|
||||
case "${ZSHU[os_type]}" in
|
||||
linux* ) alt="ls ${LS_GNU}|ls" ;;
|
||||
netbsd* ) alt="gls ${LS_GNU}|ls" ;;
|
||||
openbsd* ) alt="gls ${LS_GNU}|colorls -G|ls" ;;
|
||||
freebsd* ) alt="gls ${LS_GNU}|ls -G|ls" ;;
|
||||
darwin* ) alt="gls ${LS_GNU}|ls -G|ls" ;;
|
||||
* ) alt="ls ${LS_GNU}|ls" ;;
|
||||
esac
|
||||
|
||||
z-alt-ls "${alt}"
|
||||
unset -f z-alt-ls
|
||||
unset alt LS_GNU
|
||||
|
||||
[ -n "${LS_COLORS}" ] && zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
|
||||
case "${ZSHU[os_family]}" in
|
||||
linux ) alias l='ls -lhF ' ;;
|
||||
bsd ) alias l='ls -lhIF ' ;;
|
||||
esac
|
||||
|
||||
alias ll='ls -lAF '
|
||||
|
||||
case "${ZSHU[os_family]}" in
|
||||
linux ) alias lll='ls -lAn --full-time ' ;;
|
||||
bsd ) alias lll='ls -lAnT ' ;;
|
||||
esac
|
79
.config/zsh/alias/quilt.zsh
Normal file
79
.config/zsh/alias/quilt.zsh
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/bin/zsh
|
||||
|
||||
quilt-series-strip-comments() {
|
||||
sed -E '/^[[:space:]]*(#|$)/d' "$@"
|
||||
}
|
||||
|
||||
quilt-series-auto() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
find "$1/" -follow -type f -printf '%P\0' \
|
||||
| sed -zEn '/\.(diff|patch)$/p' \
|
||||
| sort -zuV | xargs -0r -n1
|
||||
}
|
||||
|
||||
krd-quilt() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
(( $+commands[quilt] )) || return 2
|
||||
|
||||
local patchdir series tmp_series
|
||||
|
||||
if [ -d "$1" ] ; then
|
||||
patchdir="$1/debian/patches"
|
||||
if [ -d "${patchdir}" ] ; then
|
||||
[ -f "${patchdir}/series" ] || return 3
|
||||
else
|
||||
patchdir="$1"
|
||||
fi
|
||||
|
||||
series="${patchdir}/series"
|
||||
if ! [ -f "${series}" ] ; then
|
||||
tmp_series=1
|
||||
series=$(mktemp)
|
||||
quilt-series-auto "${patchdir}" > "${series}"
|
||||
fi
|
||||
elif [ -f "$1" ] ; then
|
||||
[ -s "$1" ] || return 3
|
||||
|
||||
series="$1"
|
||||
patchdir=${series:h}
|
||||
else
|
||||
return 3
|
||||
fi
|
||||
|
||||
local r
|
||||
(
|
||||
z-quilt-default-env
|
||||
set -a
|
||||
QUILT_SERIES="${series}"
|
||||
QUILT_PATCHES="${patchdir}"
|
||||
set +a
|
||||
|
||||
command quilt pop -a ; echo
|
||||
|
||||
r=0
|
||||
while read -r i ; do
|
||||
[ -n "$i" ] || continue
|
||||
|
||||
k="${patchdir}/$i"
|
||||
command quilt --fuzz=0 push "$k"
|
||||
r=$? ; [ $r -eq 0 ] || exit $r
|
||||
command quilt refresh "$k"
|
||||
r=$? ; [ $r -eq 0 ] || exit $r
|
||||
|
||||
sed -E -i \
|
||||
-e 's#^(-{3} )[^/][^/]*/(.*)$#\1a/\2#;' \
|
||||
-e 's#^(\+{3} )[^/][^/]*/(.*)$#\1b/\2#' \
|
||||
"$k"
|
||||
|
||||
rm -f "$k"'~'
|
||||
done <<< $(quilt-series-strip-comments "${series}")
|
||||
exit $r
|
||||
)
|
||||
r=$?
|
||||
|
||||
[ -z "${tmp_series}" ] || rm -f "${series}"
|
||||
|
||||
return $r
|
||||
}
|
67
.config/zsh/alias/sbuild.zsh
Normal file
67
.config/zsh/alias/sbuild.zsh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/zsh
|
||||
|
||||
krd-debsrc() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
|
||||
local dstdir
|
||||
case "$1" in
|
||||
*/* ) dstdir="$1/src" ;;
|
||||
* ) dstdir="/tmp/$1/src" ;;
|
||||
esac
|
||||
rm -rf "${dstdir}"
|
||||
deb-src-export "${dstdir}"
|
||||
}
|
||||
|
||||
krd-sbuild() {
|
||||
[ -n "${1:?}" ] || return 1
|
||||
[ -n "${2:?}" ] || return 1
|
||||
|
||||
(( $+commands[sbuild] )) || return 2
|
||||
(( $+commands[xz] )) || return 2
|
||||
|
||||
local topdir
|
||||
case "$1" in
|
||||
*/* ) topdir="$1" ;;
|
||||
* ) topdir="/tmp/$1" ;;
|
||||
esac
|
||||
[ -d "${topdir}" ] || return 3
|
||||
|
||||
local srcdir="${topdir}/src"
|
||||
[ -d "${srcdir}" ] || return 3
|
||||
|
||||
arch="$2"
|
||||
|
||||
## done with args
|
||||
shift 2
|
||||
|
||||
local -a sbuild_env sbuild_args
|
||||
local i
|
||||
for i ; do
|
||||
## naive splitting args and env
|
||||
case "$i" in
|
||||
*=* ) sbuild_env+=( $i ) ;;
|
||||
*) sbuild_args+=( $i ) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
(
|
||||
for i ( ${sbuild_env} ) ; do
|
||||
export "$i"
|
||||
done
|
||||
|
||||
z-set-tmpdir /tmp
|
||||
|
||||
builddir="${topdir}/${arch}"
|
||||
mkdir -p "${topdir}/all" "${builddir}" "${builddir}-debug"
|
||||
|
||||
cd "${builddir}"
|
||||
for i ( "${srcdir}"/*.dsc(N.r) ) ; do
|
||||
idle sbuild --arch-all --arch-any --arch=${arch} ${sbuild_args[@]} "$i"
|
||||
find -name '*.build' -type l -exec rm -f {} +
|
||||
find -name '*.build' -type f -exec xz -9vv {} +
|
||||
done
|
||||
|
||||
find -name '*dbgsym*.deb' -type f -exec mv -nvt "../${arch}-debug" {} +
|
||||
find -name '*_all.deb' -type f -exec mv -nvt '../all' {} +
|
||||
)
|
||||
}
|
10
.config/zsh/alias/sudo.zsh
Normal file
10
.config/zsh/alias/sudo.zsh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/zsh
|
||||
|
||||
function {
|
||||
local c
|
||||
if [ ${UID} -ne 0 ] ; then
|
||||
c='sudo -i '
|
||||
fi
|
||||
alias sudo-i="$c"
|
||||
alias sudoi="$c"
|
||||
}
|
6
.config/zsh/alias/telnet.zsh
Normal file
6
.config/zsh/alias/telnet.zsh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
case "${ZSHU[os_type]}" in
|
||||
linux-gnu ) alias tl='telnet -K ' ;;
|
||||
*bsd* ) alias tl='telnet -K -N -y ' ;;
|
||||
esac
|
0
.config/zsh/completion/.keep
Normal file
0
.config/zsh/completion/.keep
Normal file
5
.config/zsh/completion/bash.zsh
Normal file
5
.config/zsh/completion/bash.zsh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
for i ( buildah ) ; do
|
||||
__z_comp_bash $i
|
||||
done ; unset i
|
17
.config/zsh/completion/external.zsh
Normal file
17
.config/zsh/completion/external.zsh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -A ZSHU_COMP_EXTERNAL
|
||||
|
||||
for i ( kubectl podman skopeo docker ) ; do
|
||||
ZSHU_COMP_EXTERNAL[$i]="command $i completion zsh"
|
||||
done ; unset i
|
||||
|
||||
## example of "automatic" shell completion generation
|
||||
# ZSHU_COMP_EXTERNAL[yq]='command yq shell-completion zsh'
|
||||
__z_comp_ext__yq() { command yq shell-completion zsh ; }
|
||||
|
||||
## example of more complex shell completion generation
|
||||
# __z_comp__shifty_nifty() { command shifty-nifty completion zsh | sed -E 's/shifty_nifty/shifty-nifty/g' ; }
|
||||
# ZSHU_COMP_EXTERNAL[shifty-nifty]='__z_comp__shifty_nifty'
|
||||
|
||||
z-comp-auto
|
5
.config/zsh/completion/system.zsh
Normal file
5
.config/zsh/completion/system.zsh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
for i ( fd fdfind hyperfine ) ; do
|
||||
__z_comp_system $i
|
||||
done ; unset i
|
88
.config/zsh/env.zsh
Normal file
88
.config/zsh/env.zsh
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## sort-n-fill PATH
|
||||
function {
|
||||
local -a p
|
||||
local -aU t npath games
|
||||
|
||||
p=( ${path} )
|
||||
|
||||
## strip "games" first :)
|
||||
t=( ${(@)p:#*games*} )
|
||||
games+=( ${(@)p:|t} )
|
||||
p=( $t )
|
||||
|
||||
## process in-home part
|
||||
t=( ${(@)p:#${HOME}/*} )
|
||||
npath+=( "${ZSHU[d_scripts]}" "${ZSHU[d_bin]}" "${HOME}/bin" )
|
||||
npath+=( ${(@)p:|t} )
|
||||
p=( $t )
|
||||
|
||||
## process /usr/local/*
|
||||
t=( ${(@)p:#/usr/local/*} )
|
||||
npath+=( /usr/local/sbin /usr/local/bin )
|
||||
npath+=( ${(@)p:|t} )
|
||||
p=( $t )
|
||||
|
||||
## process /usr/*
|
||||
t=( ${(@)p:#/usr/*} )
|
||||
npath+=( /usr/sbin /usr/bin )
|
||||
npath+=( ${(@)p:|t} )
|
||||
p=( $t )
|
||||
|
||||
## now we're with /sbin and /bin... probably :)
|
||||
npath+=( /sbin /bin )
|
||||
npath+=( $p )
|
||||
|
||||
## finally... games! xD
|
||||
npath+=( /usr/local/games /usr/games )
|
||||
npath+=( ${games} )
|
||||
|
||||
path=( ${npath} )
|
||||
hash -f
|
||||
}
|
||||
|
||||
unset GREP_OPTIONS
|
||||
unset LS_OPTIONS
|
||||
|
||||
unset LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
|
||||
unset LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
|
||||
export LANG=C.UTF-8
|
||||
export LC_ALL=C.UTF-8
|
||||
|
||||
z-set-tmpdir() {
|
||||
TMPDIR="$1"
|
||||
TMP="$1"
|
||||
TEMPDIR="$1"
|
||||
TEMP="$1"
|
||||
export TMPDIR TMP TEMPDIR TEMP
|
||||
}
|
||||
z-set-tmpdir "${TMPDIR:=/tmp}"
|
||||
|
||||
ZSHU[uname]=$(uname -s 2>/dev/null)
|
||||
ZSHU[uname]=${ZSHU[uname]:l}
|
||||
|
||||
ZSHU[mach]=$(uname -m 2>/dev/null)
|
||||
ZSHU[mach]=${ZSHU[mach]:l}
|
||||
case "${ZSHU[mach]}" in
|
||||
amd64 ) ZSHU[mach]=x86_64 ;;
|
||||
arm64 ) ZSHU[mach]=aarch64 ;;
|
||||
armv* ) ZSHU[mach]=arm ;;
|
||||
esac
|
||||
|
||||
ZSHU[os_type]=${OSTYPE:l}
|
||||
|
||||
ZSHU[os_family]=${ZSHU[uname]:l}
|
||||
case "${ZSHU[os_family]}" in
|
||||
*bsd ) ZSHU[os_family]=bsd ;;
|
||||
esac
|
||||
|
||||
ZSHU[host_name]=${(%):-%m}
|
||||
ZSHU[host_fqdn]=${(%):-%M}
|
||||
ZSHU[host]=${ZSHU[host_name]}
|
||||
function {
|
||||
[ "${ZSHU[uname]}" = darwin ] || return
|
||||
ZSHU[host]=$(scutil --get ComputerName 2>/dev/null) && return
|
||||
## last resort
|
||||
ZSHU[host]=${ZSHU[host_name]}
|
||||
}
|
8
.config/zsh/env/aux.zsh
vendored
Normal file
8
.config/zsh/env/aux.zsh
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/zsh
|
||||
|
||||
set -a
|
||||
NO_AT_BRIDGE=1
|
||||
QT_ACCESSIBILITY=0
|
||||
|
||||
MENUCONFIG_COLOR=blackbg
|
||||
set +a
|
6
.config/zsh/env/containers.zsh
vendored
Normal file
6
.config/zsh/env/containers.zsh
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
BUILD_IMAGE_NETWORK=host
|
||||
BUILD_IMAGE_PUSH=0
|
||||
|
||||
typeset -x -m 'BUILD_IMAGE*'
|
21
.config/zsh/env/gopath.zsh
vendored
Normal file
21
.config/zsh/env/gopath.zsh
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-gobin-fixup() {
|
||||
(( ${+commands[go]} )) || return 0
|
||||
local gobin
|
||||
gobin=$(go env GOBIN)
|
||||
if [ -z "${gobin}" ] ; then
|
||||
local gopath
|
||||
gopath=$(go env GOPATH)
|
||||
[ -n "${gopath}" ] || return 1
|
||||
[ -d "${gopath}" ] || return 0
|
||||
gobin="${gopath}/bin"
|
||||
fi
|
||||
[ -d "${gobin}" ] || mkdir "${gobin}" || return 1
|
||||
## already in PATH?
|
||||
[ "${path[(I)${gobin}]}" = 0 ] || return 0
|
||||
path=( "${gobin}" ${path} )
|
||||
hash -f
|
||||
}
|
||||
|
||||
z-gobin-fixup
|
10
.config/zsh/env/history.zsh
vendored
Normal file
10
.config/zsh/env/history.zsh
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## kinda unlimited history
|
||||
HISTSIZE=10000000
|
||||
SAVEHIST=10000000
|
||||
|
||||
ZSHU[f_hist]="${ZSHU[d_var]}/history"
|
||||
[ -f "${ZSHU[f_hist]}" ] || touch "${ZSHU[f_hist]}"
|
||||
|
||||
HISTFILE="${ZSHU[f_hist]}"
|
5
.config/zsh/env/ld.so.zsh
vendored
Normal file
5
.config/zsh/env/ld.so.zsh
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -T LD_LIBRARY_PATH ld_library_path
|
||||
typeset -T LD_PRELOAD ld_preload
|
||||
typeset -T LD_AUDIT ld_audit
|
3
.config/zsh/env/pager.zsh
vendored
Normal file
3
.config/zsh/env/pager.zsh
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
|
||||
export LESS=RSF
|
15
.config/zsh/env/quilt.zsh
vendored
Normal file
15
.config/zsh/env/quilt.zsh
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-quilt-default-env() {
|
||||
set -a
|
||||
QUILT_PATCHES='debian/patches'
|
||||
QUILT_NO_DIFF_INDEX=1
|
||||
QUILT_NO_DIFF_TIMESTAMPS=1
|
||||
QUILT_PATCH_OPTS='--reject-format=unified'
|
||||
QUILT_DIFF_ARGS='-pab --no-timestamps --no-index --color=auto'
|
||||
QUILT_REFRESH_ARGS='-pab --no-timestamps --no-index'
|
||||
QUILT_COLORS='diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33'
|
||||
set +a
|
||||
}
|
||||
|
||||
z-quilt-default-env
|
13
.config/zsh/env/xdg.zsh
vendored
Normal file
13
.config/zsh/env/xdg.zsh
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/zsh
|
||||
|
||||
: ${XDG_CONFIG_HOME:=${HOME}/.config}
|
||||
: ${XDG_CACHE_HOME:=${HOME}/.cache}
|
||||
: ${XDG_DATA_HOME:=${HOME}/.local/share}
|
||||
: ${XDG_RUNTIME_DIR:=${TMPDIR}}
|
||||
: ${XDG_DATA_DIRS:=/usr/local/share:/usr/share}
|
||||
: ${XDG_CONFIG_DIRS:=/etc/xdg}
|
||||
|
||||
typeset -x -m 'XDG*'
|
||||
|
||||
export -T XDG_DATA_DIRS xdg_data_dirs
|
||||
export -T XDG_CONFIG_DIRS xdg_config_dirs
|
6
.config/zsh/lib.zsh
Normal file
6
.config/zsh/lib.zsh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/zsh
|
||||
|
||||
disable which
|
||||
which() { builtin whence -p "$@"; }
|
||||
which-command() { builtin whence -p "$@"; }
|
||||
zsh-which() { builtin whence -c "$@"; }
|
87
.config/zsh/lib/alternatives.zsh
Normal file
87
.config/zsh/lib/alternatives.zsh
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## alternatives list is pipe-separated list of commands/binaries
|
||||
|
||||
## find (first) candidate in alternatives
|
||||
## $1 - alternatives list
|
||||
## $2 - arguments to test command (USE WITH CAUTION!)
|
||||
z-alt-find() {
|
||||
local -a v a
|
||||
local i c r t
|
||||
|
||||
v=( ${(@s:|:)1} )
|
||||
[ ${#v} = 0 ] && v=( "$1" )
|
||||
for i ( $v ) ; do
|
||||
a=( ${(@s: :)i} )
|
||||
|
||||
c=$(which "${a[1]}")
|
||||
[ -z "$c" ] && continue
|
||||
a[1]="$c"
|
||||
|
||||
# r=$(readlink -f "$c" 2>/dev/null)
|
||||
# [ -z "$r" ] && continue
|
||||
# a[1]="$r"
|
||||
|
||||
if [ -n "$2" ] ; then
|
||||
t="$a $2"
|
||||
command ${(@s: :)t} </dev/null &>/dev/null || continue
|
||||
fi
|
||||
|
||||
echo "${a[@]}"
|
||||
return 0
|
||||
done
|
||||
|
||||
return 127
|
||||
}
|
||||
|
||||
## set function alias for alternative (one-time static resolve)
|
||||
## $1 - function name
|
||||
## $2 - alternatives list
|
||||
## $3 - command wrapper
|
||||
## $4 - function prologue
|
||||
## $5 - function epilogue
|
||||
z-alt-set-static() {
|
||||
local -a s
|
||||
local n t a r
|
||||
|
||||
n="$1" ; t=''
|
||||
if [[ "$n" =~ '\|' ]] ; then
|
||||
t=${n:${MBEGIN}} ; n=${n:0:${MBEGIN}-1}
|
||||
fi
|
||||
a=$(z-alt-find "$2" "$t")
|
||||
if [ -n "$a" ] ; then
|
||||
r=0
|
||||
[ -n "$4" ] && s+=( "$4 ;" )
|
||||
s+=( "${3:-command}" )
|
||||
s+=( "$a \"\$@\" || return 127" )
|
||||
[ -n "$5" ] && s+=( "; $5" )
|
||||
else
|
||||
r=127
|
||||
s+=( 'return 127' )
|
||||
fi
|
||||
eval "$n () { ${s[@]} ; } ; typeset -g $n"
|
||||
|
||||
return $r
|
||||
}
|
||||
|
||||
## set function alias for alternative (dynamic resolve)
|
||||
## $1 - function name
|
||||
## $2 - alternatives list
|
||||
## $3 - command wrapper
|
||||
## $4 - function prologue
|
||||
## $5 - function epilogue
|
||||
z-alt-set-dynamic() {
|
||||
local -a s
|
||||
local n t
|
||||
|
||||
n="$1" ; t=''
|
||||
if [[ "$n" =~ '\|' ]] ; then
|
||||
t=${n:${MBEGIN}} ; n=${n:0:${MBEGIN}-1}
|
||||
fi
|
||||
[ -n "$4" ] && s+=( "$4 ;" )
|
||||
s+=( 'local a=$(z-alt-find' "${(qq)2}" "${t:+' $t'} ) ;" )
|
||||
s+=( "${3:-command}" )
|
||||
s+=( '${(@s: :)a} "$@" || return 127' )
|
||||
[ -n "$5" ] && s+=( "; $5" )
|
||||
eval "$n () { ${s[@]} ; } ; typeset -g $n"
|
||||
}
|
53
.config/zsh/lib/cmdtime.zsh
Normal file
53
.config/zsh/lib/cmdtime.zsh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-time() {
|
||||
local a r
|
||||
|
||||
a=${EPOCHREALTIME}
|
||||
"$@" ; r=$?
|
||||
a=$[ EPOCHREALTIME - a ]
|
||||
a=$(z-ts-to-human "$a" 6)
|
||||
echo >&2
|
||||
echo "time took: $a" >&2
|
||||
|
||||
return $r
|
||||
}
|
||||
|
||||
if autoload -Uz add-zsh-hook ; then
|
||||
|
||||
typeset -gA ZSHU_PS
|
||||
ZSHU_PS[cmd_threshold]=3
|
||||
|
||||
__z_cmdtime_measure() {
|
||||
local t x
|
||||
|
||||
x=${EPOCHREALTIME}
|
||||
|
||||
unset 'ZSHU[cmd_dt]' 'ZSHU_PS[elapsed]'
|
||||
(( ${+ZSHU[cmd_ts]} )) || return
|
||||
|
||||
t=$[ x - ZSHU[cmd_ts] ]
|
||||
ZSHU[cmd_ts]=$x
|
||||
|
||||
x=${ZSHU_PS[cmd_threshold]}
|
||||
x=$[ x + 0 ] || x=0
|
||||
[ "$x" = 0 ] && return
|
||||
|
||||
x=$[ t - x ]
|
||||
[ "${x:0:1}" = '-' ] && return
|
||||
|
||||
t=$(z-ts-to-human "$t")
|
||||
ZSHU[cmd_dt]=$t
|
||||
ZSHU_PS[elapsed]=" %f[%B%F{yellow}+$t%b%f]"
|
||||
}
|
||||
|
||||
__z_cmdtime_set() {
|
||||
ZSHU[cmd_ts]=${EPOCHREALTIME}
|
||||
}
|
||||
|
||||
add-zsh-hook precmd __z_cmdtime_measure
|
||||
add-zsh-hook preexec __z_cmdtime_set
|
||||
|
||||
else
|
||||
echo "cmd time measurement is disabled due to missing hook support" >&2
|
||||
fi
|
143
.config/zsh/lib/completion.zsh
Normal file
143
.config/zsh/lib/completion.zsh
Normal file
@@ -0,0 +1,143 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -gA ZSHU_COMP_FORCE
|
||||
|
||||
ZSHU[f_compdump]="${ZSHU[d_cache]}/compdump"
|
||||
ZSHU[d_completion]="${ZSHU[d_cache]}/completion"
|
||||
ZSHU[d_compzwc]="${ZSHU[d_cache]}/compzwc"
|
||||
ZSHU[d_compcache]="${ZSHU[d_cache]}/compcache"
|
||||
|
||||
typeset -a ZSHU_SYS_FPATH=( ${fpath} )
|
||||
fpath=( "${ZSHU[d_compzwc]}" "${ZSHU[d_completion]}" ${fpath} )
|
||||
|
||||
__z_compdump_print() { printf '#zshu %s %s\n' "$1" "${(P)1}" ; }
|
||||
|
||||
__z_compdump_invalidate() {
|
||||
rm -f "${ZSHU[f_compdump]}"
|
||||
find "${ZSHU[d_compcache]}/" -xdev -type f '!' -name '.keep' -delete
|
||||
ZSHU[compdump_refresh]=1
|
||||
}
|
||||
|
||||
__z_compdump_verify() {
|
||||
local i s
|
||||
|
||||
unset 'ZSHU[compdump_refresh]'
|
||||
ZSHU[compdump_meta]='ZSH_VERSION ZSH_PATCHLEVEL FPATH PATH'
|
||||
for i ( ${(s: :)ZSHU[compdump_meta]} ) ; do
|
||||
s=$(__z_compdump_print "$i")
|
||||
command grep -Fx -e "$s" "${ZSHU[f_compdump]}" &>/dev/null && continue
|
||||
__z_compdump_invalidate
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
__z_compdump_finalize() {
|
||||
local i
|
||||
|
||||
if (( ${+ZSHU[compdump_refresh]} )) ; then
|
||||
{
|
||||
echo
|
||||
for i ( ${(s: :)ZSHU[compdump_meta]} ) ; do
|
||||
__z_compdump_print "$i"
|
||||
done
|
||||
} | tee -a "${ZSHU[f_compdump]}" &>/dev/null
|
||||
unset 'ZSHU[compdump_refresh]'
|
||||
fi
|
||||
unset 'ZSHU[compdump_meta]'
|
||||
}
|
||||
|
||||
## TODO: refactor (e.g. buildah completion is a "bit" broken)
|
||||
__z_comp_bash() {
|
||||
local f p x
|
||||
|
||||
(( ${+commands[$1]} )) || return 1
|
||||
(( ${+_comps[$1]} )) && return 2
|
||||
(( ${+ZSHU[compdump_bash]} )) || return 3
|
||||
(( ${+2} )) && return 0
|
||||
|
||||
f=0
|
||||
for p ( /usr/share/bash-completion/completions ) ; do
|
||||
x="_$1" ; [ -s "$p/$x" ] && f=1 && break
|
||||
x="$1" ; [ -s "$p/$x" ] && f=1 && break
|
||||
done
|
||||
[ "$f" = 0 ] && return 4
|
||||
complete -C "$x" "$1"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
__z_comp_external() {
|
||||
local c f
|
||||
c="$1" ; shift
|
||||
|
||||
[ $# -gt 0 ] || return 1
|
||||
|
||||
(( ${+commands[$c]} )) || return 2
|
||||
|
||||
if ! (( ${+ZSHU_COMP_FORCE[$c]} )) ; then
|
||||
(( ${+_comps[$c]} )) && return 0
|
||||
fi
|
||||
|
||||
f="${ZSHU[d_completion]}/_$c"
|
||||
if ! [ -s "$f" ] ; then
|
||||
if ! "$@" > "$f" ; then
|
||||
rm -f "$f"
|
||||
return 3
|
||||
fi
|
||||
fi
|
||||
# zcompile -zR "$f"
|
||||
# mv -f "$f.zwc" "${ZSHU[d_compzwc]}/$c.zwc"
|
||||
# emulate zsh -c "autoload -Uz _$c"
|
||||
autoload -Uz "_$c"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
__z_comp_system() {
|
||||
local d
|
||||
|
||||
(( ${+commands[$1]} )) || return 1
|
||||
(( ${+_comps[$1]} )) && return 2
|
||||
|
||||
(( ${+ZSHU_COMP_FORCE[$c]} )) && return 0
|
||||
|
||||
local -a _fpath
|
||||
_fpath=( ${fpath} )
|
||||
fpath=( ${ZSHU_SYS_FPATH} )
|
||||
|
||||
for d ( ${fpath} ) ; do
|
||||
[ -s "$d/_$1" ] || continue
|
||||
# emulate zsh -c "autoload -Uz _$1"
|
||||
autoload -Uz "_$1"
|
||||
fpath=( ${_fpath} )
|
||||
return 0
|
||||
done
|
||||
fpath=( ${_fpath} )
|
||||
return 3
|
||||
}
|
||||
|
||||
## reload or new session are required to regenerate compcache
|
||||
z-comp-invalidate() {
|
||||
[ -n "$1" ] || return 1
|
||||
|
||||
# rm -f "${ZSHU[d_completion]}/_$1" "${ZSHU[d_compzwc]}/_$1.zwc" "${ZSHU[d_compzwc]}/$1.zwc"
|
||||
rm -f "${ZSHU[d_completion]}/_$1"
|
||||
}
|
||||
|
||||
## reload or new session are required to regenerate completions
|
||||
z-comp-flush() {
|
||||
find "${ZSHU[d_completion]}/" "${ZSHU[d_compzwc]}/" -xdev -type f '!' -name '.keep' -delete
|
||||
}
|
||||
|
||||
z-comp-auto() {
|
||||
local c f
|
||||
|
||||
for c ( ${(k)ZSHU_COMP_EXTERNAL} ) ; do
|
||||
__z_comp_external "$c" "${(@s: :)ZSHU_COMP_EXTERNAL[$c]}" && unset "ZSHU_COMP_EXTERNAL[$c]"
|
||||
done
|
||||
|
||||
for f ( ${functions[(I)__z_comp_ext__*]} ) ; do
|
||||
c=${f#__z_comp_ext__}
|
||||
__z_comp_external $c $f && unset -f "$f"
|
||||
done
|
||||
}
|
14
.config/zsh/lib/curl.zsh
Normal file
14
.config/zsh/lib/curl.zsh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/zsh
|
||||
|
||||
__z_curl_headers() {
|
||||
command curl -qsI "$@" 2>/dev/null
|
||||
}
|
||||
__z_curl_location() {
|
||||
__z_curl_headers "$1" \
|
||||
| sed -En '/^[Ll]ocation: (.+)$/{s//\1/;p}'
|
||||
}
|
||||
__z_curl_response() {
|
||||
__z_curl_headers -L "$1" \
|
||||
| sed -En '/^HTTP\/[0-9.]+ ([1-5][0-9]{2})( .+)?$/{s//\1/;p}' \
|
||||
| tail -n 1
|
||||
}
|
155
.config/zsh/lib/git.zsh
Normal file
155
.config/zsh/lib/git.zsh
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## fancy and manageable PS1 for git
|
||||
typeset -gA ZSHU_GIT ZSHU_PM ZSHU_PS
|
||||
ZSHU_PS[git]=0
|
||||
ZSHU_PM[git_branch]='🞷'
|
||||
ZSHU_PM[git_ahead]='↱'
|
||||
ZSHU_PM[git_behind]='↴'
|
||||
ZSHU_PM[git_detach]='☈'
|
||||
ZSHU_PM[git_tag]='🗹'
|
||||
ZSHU_PM[git_commit]='⌽'
|
||||
|
||||
__z_git_avail() { (( $+commands[git] )) ; }
|
||||
|
||||
__z_git() { GIT_OPTIONAL_LOCKS=0 command git "$@"; }
|
||||
|
||||
__z_git_is_repo() { __z_git rev-parse --git-dir &>/dev/null ; }
|
||||
|
||||
__z_git_desc_tag() { __z_git describe --tags "$@" ; }
|
||||
|
||||
z-git-test() {
|
||||
[ "${ZSHU_PS[git]}" = '1' ] || return 1
|
||||
|
||||
__z_git_avail || return 2
|
||||
|
||||
__z_git_is_repo || return 3
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
__z_git_pwd() {
|
||||
unset 'ZSHU_PS[git_ref]' 'ZSHU_PS[git_changes]' 'ZSHU_PS[git_tag]'
|
||||
ZSHU_GIT=()
|
||||
z-git-test || return
|
||||
|
||||
|
||||
local x
|
||||
x=$(__z_git rev-parse --short HEAD 2>/dev/null)
|
||||
[ -n "$x" ] || return
|
||||
ZSHU_GIT[commit]=$x
|
||||
|
||||
## git ref
|
||||
while : ; do
|
||||
ZSHU_GIT[detached]=1
|
||||
x=$(__z_git symbolic-ref --short HEAD 2>/dev/null)
|
||||
if [ -n "$x" ] ; then
|
||||
ZSHU_GIT[detached]=0
|
||||
ZSHU_GIT[ref]=$x
|
||||
ZSHU_PS[git_ref]="%F{green}%B${ZSHU_PM[git_branch]}%b ${ZSHU_GIT[ref]}%f"
|
||||
break
|
||||
fi
|
||||
|
||||
x=$(__z_git for-each-ref --format='%(refname:short)' --count=1 --points-at=${ZSHU_GIT[commit]} refs/heads/ refs/remotes/)
|
||||
if [ -n "$x" ] ; then
|
||||
ZSHU_GIT[detached]=0
|
||||
ZSHU_GIT[ref]=$x
|
||||
ZSHU_PS[git_ref]="%F{yellow}%B${ZSHU_PM[git_branch]}%b ${ZSHU_GIT[ref]}%f"
|
||||
break
|
||||
fi
|
||||
|
||||
ZSHU_GIT[ref]=${ZSHU_GIT[commit]}
|
||||
ZSHU_PS[git_ref]="%F{red}%B${ZSHU_PM[git_detach]}%b ${ZSHU_GIT[ref]}%f"
|
||||
|
||||
break
|
||||
done
|
||||
|
||||
## local<->remote changes
|
||||
while [ ${ZSHU_GIT[detached]} = 0 ] ; do
|
||||
x=$(__z_git for-each-ref --format='%(upstream:short)' --count=1 --points-at=${ZSHU_GIT[commit]} refs/heads/ refs/remotes/)
|
||||
[ -n "$x" ] || break
|
||||
ZSHU_GIT[remote]=$x
|
||||
|
||||
x=$(__z_git rev-list --left-right "${ZSHU_GIT[ref]}...${ZSHU_GIT[remote]}" 2>/dev/null) || break
|
||||
ZSHU_GIT[ref_ahead]=$(echo "$x" | grep -Ec '^<')
|
||||
ZSHU_GIT[ref_behind]=$(echo "$x" | grep -Ec '^>')
|
||||
ZSHU_GIT[ref_changes]=$[ ZSHU_GIT[ref_ahead] + ZSHU_GIT[ref_behind] ]
|
||||
[ ${ZSHU_GIT[ref_changes]} -eq 0 ] && break
|
||||
|
||||
x=''
|
||||
[ ${ZSHU_GIT[ref_ahead]} -eq 0 ] || x="$x${x:+ }%B%F{green}${ZSHU_PM[git_ahead]} ${ZSHU_GIT[ref_ahead]}%b"
|
||||
[ ${ZSHU_GIT[ref_behind]} -eq 0 ] || x="$x${x:+ }%B%F{red}${ZSHU_PM[git_behind]} ${ZSHU_GIT[ref_behind]}%b"
|
||||
ZSHU_PS[git_changes]=$x
|
||||
|
||||
break
|
||||
done
|
||||
|
||||
## git tag
|
||||
while [ ${ZSHU_GIT[detached]} = 1 ] ; do
|
||||
x=$(__z_git_desc_tag --exact-match HEAD 2>/dev/null)
|
||||
if [ -n "$x" ] ; then
|
||||
ZSHU_GIT[tag]=$x
|
||||
ZSHU_PS[git_tag]="%F{green}%B${ZSHU_PM[git_tag]}%b ${ZSHU_GIT[tag]}%f"
|
||||
break
|
||||
fi
|
||||
|
||||
x=$(__z_git_desc_tag HEAD 2>/dev/null)
|
||||
if [ -n "$x" ] ; then
|
||||
ZSHU_GIT[tag]=${x%-*}
|
||||
ZSHU_PS[git_tag]="%F{yellow}%B${ZSHU_PM[git_commit]}%b ${ZSHU_GIT[tag]}%f"
|
||||
break
|
||||
fi
|
||||
|
||||
break
|
||||
done
|
||||
|
||||
## try to fancy split current path
|
||||
while : ; do
|
||||
x=${(%):-%~}
|
||||
[[ "$x" =~ '/.+' ]] || break
|
||||
|
||||
local pfx last mid
|
||||
pfx=$(__z_git rev-parse --show-prefix)
|
||||
pfx="${pfx%/}"
|
||||
if [ -n "${pfx}" ] ; then
|
||||
x=${x%/${pfx}}
|
||||
last="${pfx:t}"
|
||||
mid="${pfx%${last}}"
|
||||
mid="${mid%/}"
|
||||
mid="/${mid}${mid:+/}"
|
||||
|
||||
ZSHU_GIT[path_mid]=${mid}
|
||||
ZSHU_GIT[path_last]=${last}
|
||||
else
|
||||
ZSHU_GIT[path_last]='/'
|
||||
fi
|
||||
break
|
||||
done
|
||||
ZSHU_GIT[path_root]=$x
|
||||
|
||||
x="%F{magenta}${ZSHU_GIT[path_root]:gs/%/%%}"
|
||||
x="$x%F{cyan}${ZSHU_GIT[path_mid]:gs/%/%%}"
|
||||
x="$x%B${ZSHU_GIT[path_last]:gs/%/%%}%f%b"
|
||||
ZSHU_PS[pwd]=$x
|
||||
|
||||
local -a ary
|
||||
ary+="${ZSHU_PS[git_ref]}"
|
||||
ary+="${ZSHU_PS[git_changes]}"
|
||||
ary+="${ZSHU_PS[git_tag]}"
|
||||
x="${(j: :)ary}"
|
||||
[ -z "$x" ] || ZSHU_PS[pwd_extra]=" $x"
|
||||
}
|
||||
|
||||
z-git-enable() { ZSHU_PS[git]=1 ; }
|
||||
z-git-disable() { ZSHU_PS[git]=0 ; }
|
||||
|
||||
z-git-status() {
|
||||
__z_git_avail
|
||||
echo "Git binary: "${(%):-%(?..NOT )}"found in PATH"
|
||||
[ "${ZSHU_PS[git]}" = 1 ]
|
||||
echo "Git prompt: "${(%):-%(?.enabled.disabled)}
|
||||
__z_git_is_repo
|
||||
echo "Git repo: "${(%):-%(?..NOT )}"present"
|
||||
}
|
||||
|
||||
ZSHU[pwd_hook]="${ZSHU[pwd_hook]}${ZSHU[pwd_hook]:+ }__z_git_pwd"
|
19
.config/zsh/lib/history.zsh
Normal file
19
.config/zsh/lib/history.zsh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-history() {
|
||||
local list
|
||||
|
||||
zparseopts -E l=list
|
||||
if [ -n "${list}" ]; then
|
||||
builtin fc "$@"
|
||||
else
|
||||
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -il "$@" || builtin fc -il "$@" 1
|
||||
fi
|
||||
}
|
||||
|
||||
z-grephist() {
|
||||
local x
|
||||
|
||||
x=$1 ; shift
|
||||
z-history -m "*${x}*" "$@"
|
||||
}
|
51
.config/zsh/lib/prompt.zsh
Normal file
51
.config/zsh/lib/prompt.zsh
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -gA ZSHU_PM ZSHU_PS
|
||||
|
||||
ZSHU_PM[rst]='%b%k%u%s%f'
|
||||
ZSHU_PM[crlf]=$'\n'
|
||||
|
||||
ZSHU_PS[shlvl]='%(2L.%B%F{white}|%F{cyan}%L%b%f.)'
|
||||
|
||||
ZSHU_PM[status]='▪'
|
||||
ZSHU_PS[lastcmd]="%B%(?.%F{green}.%F{red})${ZSHU_PM[status]}%f%b"
|
||||
|
||||
ZSHU_PS[pwd_std]='%F{cyan}%B%~%f%b'
|
||||
|
||||
ZSHU_PM[cmd_user]='%F{white}$'
|
||||
ZSHU_PM[cmd_root]='%F{red}#'
|
||||
ZSHU_PS[cmd]="%k%B%(!.${ZSHU_PM[cmd_root]}.${ZSHU_PM[cmd_user]})${ZSHU_PM[rst]} "
|
||||
|
||||
ZSHU_PM[user]='%(!.%F{magenta}.%F{green})%n%f'
|
||||
ZSHU_PM[host]="%B%(!.%F{red}.%F{blue})${ZSHU[host]}%f%b"
|
||||
|
||||
if autoload -Uz add-zsh-hook ; then
|
||||
|
||||
__z_pwd() {
|
||||
local p pfx last
|
||||
|
||||
p=${(%):-%~}
|
||||
[[ "$p" =~ '/.+' ]] || return
|
||||
pfx="${p:h}"
|
||||
pfx="${pfx%%/}"
|
||||
last="${p:t}"
|
||||
ZSHU_PS[pwd]="%F{cyan}${pfx}/%B${last}%f%b"
|
||||
}
|
||||
|
||||
# ZSHU[pwd_hook]=''
|
||||
__z_pwd_hook() {
|
||||
local i
|
||||
|
||||
unset 'ZSHU_PS[pwd]'
|
||||
for i ( ${(s: :)ZSHU[pwd_hook]} __z_pwd ) ; do
|
||||
unset 'ZSHU_PS[pwd_extra]'
|
||||
"$i"
|
||||
(( ${+ZSHU_PS[pwd]} )) && return
|
||||
done
|
||||
}
|
||||
|
||||
add-zsh-hook precmd __z_pwd_hook
|
||||
|
||||
else
|
||||
echo "shiny pwd's are disabled due to missing hook support" >&2
|
||||
fi
|
41
.config/zsh/lib/pswalk.zsh
Normal file
41
.config/zsh/lib/pswalk.zsh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -Uga ZSHU_PARENTS_PID
|
||||
typeset -ga ZSHU_PARENTS_NAME
|
||||
|
||||
function {
|
||||
local i c g
|
||||
|
||||
i=${PPID}
|
||||
while : ; do
|
||||
[ -n "$i" ] || break
|
||||
## don't deal with PID1
|
||||
[ "$i" = 1 ] && break
|
||||
|
||||
ZSHU_PARENTS_PID+=( $i )
|
||||
read -r i c g <<< $(ps -o 'ppid=,comm=' -p "$i" 2>/dev/null)
|
||||
[ -n "$c" ] && ZSHU_PARENTS_NAME+=( "${c:t}" )
|
||||
done
|
||||
|
||||
typeset -r ZSHU_PARENTS_PID ZSHU_PARENTS_NAME
|
||||
}
|
||||
|
||||
typeset -gA ZSHU_RUN
|
||||
|
||||
z-run-test() {
|
||||
local k i
|
||||
|
||||
k=$1 ; shift
|
||||
for i ( ${ZSHU_PARENTS_NAME} ) ; do
|
||||
(( ${+argv[(r)$i]} )) || continue
|
||||
|
||||
ZSHU_RUN[$k]=1
|
||||
return
|
||||
done
|
||||
ZSHU_RUN[$k]=0
|
||||
}
|
||||
|
||||
z-run-test gui konsole xterm x-terminal-emulator
|
||||
z-run-test nested screen tmux mc
|
||||
z-run-test nested1L mc
|
||||
z-run-test elevated sudo su
|
17
.config/zsh/lib/say-my.zsh
Normal file
17
.config/zsh/lib/say-my.zsh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/zsh
|
||||
|
||||
say_my_name() {
|
||||
set -a
|
||||
GIT_COMMITTER_NAME="$1"
|
||||
GIT_AUTHOR_NAME="$1"
|
||||
DEBFULLNAME="$1"
|
||||
set +a
|
||||
}
|
||||
|
||||
say_my_email() {
|
||||
set -a
|
||||
GIT_COMMITTER_EMAIL="$1"
|
||||
GIT_AUTHOR_EMAIL="$1"
|
||||
DEBEMAIL="$1"
|
||||
set +a
|
||||
}
|
67
.config/zsh/lib/selfservice.zsh
Normal file
67
.config/zsh/lib/selfservice.zsh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/zsh
|
||||
|
||||
dotfiles-update() {
|
||||
"${ZSHU[d_dotfiles]}/install.sh" "$@"
|
||||
}
|
||||
|
||||
dotfiles-git() { (
|
||||
cd "${ZSHU[d_zdot]}/"
|
||||
set -a
|
||||
GIT_DIR="${ZSHU[d_dotfiles]}/repo.git"
|
||||
GIT_WORK_TREE="${ZSHU[d_zdot]}"
|
||||
set +a
|
||||
zsh -i
|
||||
) }
|
||||
|
||||
dotfiles-gen-gitignore() {
|
||||
local x='.config/dotfiles/gen-gitignore.sh'
|
||||
[ -x "$x" ] || {
|
||||
echo "${x:t} is somewhere else" >&2
|
||||
return 1
|
||||
}
|
||||
if [ -d .config/dotfiles/repo.git ] ; then
|
||||
echo "NOT going to change dotfiles installation" >&2
|
||||
return 1
|
||||
fi
|
||||
"$x" "$@"
|
||||
}
|
||||
|
||||
z-zwc-gen() {
|
||||
local i
|
||||
for i ( "${ZSHU[d_conf]}"/**/*.zsh(N.r) ) ; do
|
||||
zcompile -UR "$i"
|
||||
done
|
||||
# for i ( "${ZSHU[d_completion]}"/*(N.r) ) ; do
|
||||
# case "$i" in
|
||||
# *.zwc )
|
||||
# # likely a remnant
|
||||
# rm -f "$i"
|
||||
# continue
|
||||
# ;;
|
||||
# esac
|
||||
# zcompile -UR "$i"
|
||||
# mv -f "$i.zwc" "${ZSHU[d_compzwc]}/"
|
||||
# done
|
||||
}
|
||||
|
||||
z-zwc-flush() {
|
||||
rm -f "${ZSHU[d_conf]}"/**/*.zwc(N.r)
|
||||
}
|
||||
|
||||
z-update() {
|
||||
dotfiles-update
|
||||
z-cache-flush
|
||||
}
|
||||
|
||||
z-reload() {
|
||||
exec -a "${ZSH_ARGZERO}" "${ZSH_NAME}" "${argv[@]}"
|
||||
echo "unable to reload (something went wrong), code $?" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
## reload or new session are required to regenerate compcache
|
||||
z-cache-flush() {
|
||||
find "${ZSHU[d_cache]}/" -xdev -type f '!' -name '.keep' -delete
|
||||
z-zwc-flush
|
||||
z-zwc-gen
|
||||
}
|
18
.config/zsh/lib/term.zsh
Normal file
18
.config/zsh/lib/term.zsh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -Uga ZSHU_TERM_MISSING
|
||||
|
||||
z-ti-test() {
|
||||
local r i
|
||||
|
||||
r=0
|
||||
for i ; do
|
||||
[ -z "$i" ] && continue
|
||||
if ! (( ${+terminfo[$i]} )) ; then
|
||||
ZSHU_TERM_MISSING+=( "$1" )
|
||||
r=1
|
||||
fi
|
||||
done
|
||||
|
||||
return $r
|
||||
}
|
41
.config/zsh/lib/time.zsh
Normal file
41
.config/zsh/lib/time.zsh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-ts-to-human() {
|
||||
local t s n d h m f x
|
||||
|
||||
t=$1
|
||||
t=$[ float(t) ]
|
||||
s=$[ int(t) ]
|
||||
n=$[ int((t - s) * (10**9)) ]
|
||||
t=$s
|
||||
|
||||
d=0 h=0 m=0
|
||||
if [ $t -ge 86400 ] ; then
|
||||
d=$[ t / 86400 ]
|
||||
t=$[ t % 86400 ]
|
||||
fi
|
||||
if [ $t -ge 3600 ] ; then
|
||||
h=$[ t / 3600 ]
|
||||
t=$[ t % 3600 ]
|
||||
fi
|
||||
if [ $t -ge 60 ] ; then
|
||||
m=$[ t / 60 ]
|
||||
t=$[ t % 60 ]
|
||||
fi
|
||||
|
||||
## strftime does desired rounding for $n/(10**9) internally
|
||||
f=$(strftime '%s.%6.' $t $n)
|
||||
## keep math in sync with format above
|
||||
x=3
|
||||
case "$2" in
|
||||
0 ) x=7 ;;
|
||||
[1-6] ) x=$[ 6 - $2 ] ;;
|
||||
esac
|
||||
[ $x -gt 0 ] && f="${f:0:-$x}s"
|
||||
|
||||
[ $s -ge 60 ] && f="${m}m:$f"
|
||||
[ $s -ge 3600 ] && f="${h}h:$f"
|
||||
[ $s -ge 86400 ] && f="${d}d:$f"
|
||||
|
||||
echo "$f"
|
||||
}
|
58
.config/zsh/lib/title.zsh
Normal file
58
.config/zsh/lib/title.zsh
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/bin/zsh
|
||||
|
||||
ZSHU[title_tab]='%15<..<%~%<<'
|
||||
ZSHU[title_window]='%n@%m:%~'
|
||||
|
||||
z-title-tab() {
|
||||
emulate -L zsh
|
||||
|
||||
case "${TERM}" in
|
||||
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
|
||||
print -Pn "\e]1;${1:q}\a"
|
||||
;;
|
||||
screen* | tmux* )
|
||||
## hardstatus
|
||||
print -Pn "\ek${1:q}\e\\"
|
||||
;;
|
||||
* )
|
||||
z-ti-test fsl tsl || return
|
||||
|
||||
echoti tsl
|
||||
print -Pn "$1"
|
||||
echoti fsl
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
z-title-window() {
|
||||
emulate -L zsh
|
||||
|
||||
case "${TERM}" in
|
||||
cygwin | xterm* | putty* | rxvt* | konsole* | ansi | mlterm* | alacritty | st* )
|
||||
print -Pn "\e]2;${1:q}\a"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
z-title() {
|
||||
emulate -L zsh
|
||||
|
||||
## if $2 is unset use $1 as default
|
||||
## if it is set and empty, leave it as is
|
||||
: ${2=$1}
|
||||
|
||||
z-title-tab "$1"
|
||||
z-title-window "$2"
|
||||
}
|
||||
|
||||
if autoload -Uz add-zsh-hook ; then
|
||||
|
||||
__z_title_precmd() {
|
||||
z-title "${ZSHU[title_tab]}" "${ZSHU[title_window]}"
|
||||
}
|
||||
|
||||
add-zsh-hook precmd __z_title_precmd
|
||||
|
||||
else
|
||||
echo "tab/window title handling is disabled due to missing hook support" 1>&2
|
||||
fi
|
10
.config/zsh/local.zsh.example
Normal file
10
.config/zsh/local.zsh.example
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/zsh
|
||||
|
||||
## skip system-wide podman completion and produce own
|
||||
ZSHU_COMP_FORCE[podman]=1
|
||||
|
||||
## systemctl status podman.socket
|
||||
export DOCKER_HOST=unix:///run/podman/podman.sock
|
||||
|
||||
## systemctl --user status podman.socket
|
||||
export DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/podman/podman.sock
|
0
.config/zsh/local/.keep
Normal file
0
.config/zsh/local/.keep
Normal file
0
.config/zsh/local/completion/.keep
Normal file
0
.config/zsh/local/completion/.keep
Normal file
13
.config/zsh/opt.zsh
Normal file
13
.config/zsh/opt.zsh
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/zsh
|
||||
|
||||
unsetopt err_exit
|
||||
unsetopt err_return
|
||||
unsetopt multios
|
||||
|
||||
setopt bsd_echo
|
||||
setopt interactive_comments
|
||||
setopt long_list_jobs
|
||||
setopt monitor
|
||||
setopt prompt_subst
|
||||
setopt zle
|
||||
# setopt magic_equal_subst
|
5
.config/zsh/opt/chase.zsh
Normal file
5
.config/zsh/opt/chase.zsh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/zsh
|
||||
|
||||
chase() { setopt chase_dots chase_links ; }
|
||||
nochase() { unsetopt chase_dots chase_links ; }
|
||||
nochase
|
8
.config/zsh/opt/completion.zsh
Normal file
8
.config/zsh/opt/completion.zsh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/zsh
|
||||
|
||||
unsetopt flow_control
|
||||
unsetopt menu_complete
|
||||
|
||||
setopt always_to_end
|
||||
setopt auto_menu
|
||||
setopt complete_in_word
|
7
.config/zsh/opt/directories.zsh
Normal file
7
.config/zsh/opt/directories.zsh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/zsh
|
||||
|
||||
setopt auto_cd
|
||||
setopt auto_pushd
|
||||
setopt cdable_vars
|
||||
setopt pushd_ignore_dups
|
||||
setopt pushd_minus
|
11
.config/zsh/opt/history.zsh
Normal file
11
.config/zsh/opt/history.zsh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/zsh
|
||||
|
||||
setopt append_history
|
||||
setopt extended_history
|
||||
setopt hist_expire_dups_first
|
||||
setopt hist_ignore_all_dups
|
||||
setopt hist_ignore_dups
|
||||
setopt hist_ignore_space
|
||||
setopt hist_verify
|
||||
setopt inc_append_history
|
||||
setopt share_history
|
3
.config/zsh/opt/prompt.zsh
Normal file
3
.config/zsh/opt/prompt.zsh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/zsh
|
||||
|
||||
setopt prompt_subst
|
28
.config/zsh/rc.zsh
Normal file
28
.config/zsh/rc.zsh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -Ua zshu_modules
|
||||
zshu_modules+=(
|
||||
complete
|
||||
complist
|
||||
computil
|
||||
datetime
|
||||
langinfo
|
||||
main
|
||||
mathfunc
|
||||
parameter
|
||||
stat
|
||||
system
|
||||
terminfo
|
||||
zle
|
||||
zutil
|
||||
)
|
||||
for i ( ${zshu_modules} ) ; do
|
||||
case "$i" in
|
||||
*/* ) ;;
|
||||
* ) i="zsh/$i" ;;
|
||||
esac
|
||||
zmodload -i "$i"
|
||||
done
|
||||
unset i zshu_modules
|
||||
|
||||
autoload -Uz +X colors && colors
|
40
.config/zsh/rc/completion.zsh
Normal file
40
.config/zsh/rc/completion.zsh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/zsh
|
||||
|
||||
__z_compdump_verify
|
||||
|
||||
## :completion:<function-name>:<completer>:<command>:<argument>:<tag>
|
||||
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':completion::complete:*' cache-path "${ZSHU[d_compcache]}"
|
||||
|
||||
bindkey -M menuselect '^o' accept-and-infer-next-history
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
|
||||
|
||||
zstyle ':completion:*' special-dirs true
|
||||
|
||||
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||
|
||||
zstyle ':completion:*:*:*:users' ignored-patterns adm amanda apache at avahi avahi-autoipd backup beaglidx bin bind cacti canna clamav colord daemon dbus distcache dnsmasq dovecot fax ftp games gdm gkrellmd gnats gopher hacluster haldaemon halt hplip hsqldb ident irc junkbust kdm ldap list lp mail mailman mailnull man messagebus mldonkey mysql nagios named netdump news nfsnobody nginx nobody nscd ntp ntpsec nut nx obsrun openvpn operator pcap polkitd postfix postgres privoxy proxy pulse pvm quagga radvd redsocks rpc rpcuser rpm rtkit saned sbuild sbws scard sddm shutdown speech-dispatcher squid sshd statd svn sync sys tcpdump tftp tss usbmux uucp uuidd vcsa wwwrun www-data x2gouser xfs '_*' 'systemd-*' 'debian-*' 'Debian-*'
|
||||
zstyle '*' single-ignored show
|
||||
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u ${USER} -o pid,user,comm -w -w"
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||
zstyle ':completion:*:kill:*' command 'ps -u ${USER} -o pid,%cpu,tty,cputime,cmd'
|
||||
|
||||
autoload -Uz +X compinit && \
|
||||
compinit -i -C -d "${ZSHU[f_compdump]}"
|
||||
|
||||
if autoload -Uz +X bashcompinit ; then
|
||||
bashcompinit && ZSHU[compdump_bash]=1
|
||||
fi
|
||||
|
||||
for i ( "${ZSHU[d_conf]}"/completion/*.zsh(N.r) ) ; do
|
||||
source "$i"
|
||||
done ; unset i
|
||||
for i ( "${ZSHU[d_conf]}"/local/completion/*.zsh(N.r) ) ; do
|
||||
source "$i"
|
||||
done ; unset i
|
||||
|
||||
__z_compdump_finalize
|
138
.config/zsh/rc/keyboard.zsh
Normal file
138
.config/zsh/rc/keyboard.zsh
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -A ZSHU_TI_KEYS
|
||||
typeset -A ZSHU_FB_KEYS
|
||||
|
||||
if z-ti-test smkx rmkx ; then
|
||||
zle-line-init() { emulate -L zsh ; echoti smkx ; }
|
||||
zle-line-finish() { emulate -L zsh ; echoti rmkx ; }
|
||||
# zle-line-init() { echoti smkx ; }
|
||||
# zle-line-finish() { echoti rmkx ; }
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
||||
fi
|
||||
|
||||
## key [sequence] via terminfo
|
||||
z-kseq-ti() {
|
||||
[ -z "$1" ] && return
|
||||
[ -z "$2" ] && return
|
||||
|
||||
z-ti-test "$2" && ZSHU_TI_KEYS[${terminfo[$2]}]=$1
|
||||
}
|
||||
|
||||
## key [sequence] via fallback
|
||||
z-kseq-fb() {
|
||||
[ -z "$1" ] && return
|
||||
[ -z "$2" ] && return
|
||||
|
||||
ZSHU_FB_KEYS[$2]=$1
|
||||
}
|
||||
|
||||
z-kseq-ti Backspace kbs
|
||||
|
||||
z-kseq-ti Home khome
|
||||
z-kseq-ti End kend
|
||||
z-kseq-ti Insert kich1
|
||||
z-kseq-ti Delete kdch1
|
||||
|
||||
z-kseq-ti Up kcuu1
|
||||
z-kseq-ti Down kcud1
|
||||
z-kseq-ti Left kcub1
|
||||
z-kseq-ti Right kcuf1
|
||||
|
||||
z-kseq-ti PageUp kpp
|
||||
z-kseq-ti PageDown knp
|
||||
|
||||
z-kseq-ti Shift-Tab kcbt
|
||||
|
||||
z-kseq-fb Backspace '^?'
|
||||
z-kseq-fb Home '^[[H'
|
||||
z-kseq-fb End '^[[F'
|
||||
z-kseq-fb Insert '^[[2~'
|
||||
z-kseq-fb Delete '^[[3~'
|
||||
z-kseq-fb Delete # '^[3;5~'
|
||||
|
||||
z-kseq-fb Up '^[[A'
|
||||
z-kseq-fb Down '^[[B'
|
||||
z-kseq-fb Left '^[[D'
|
||||
z-kseq-fb Right '^[[C'
|
||||
|
||||
z-kseq-fb PageUp '^[[5~'
|
||||
z-kseq-fb PageDown '^[[6~'
|
||||
|
||||
z-kseq-fb Ctrl-Delete '^[[3;5~'
|
||||
z-kseq-fb Ctrl-RightArrow '^[[1;5C'
|
||||
z-kseq-fb Ctrl-LeftArrow '^[[1;5D'
|
||||
|
||||
z-kseq-fb Esc-w '\ew'
|
||||
|
||||
z-bind () {
|
||||
local -a maps
|
||||
local -Ua keys
|
||||
local widget i k
|
||||
|
||||
while [ "$1" != "--" ] ; do
|
||||
maps+=( "$1" )
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
||||
widget="$2"
|
||||
|
||||
keys+=( ${(k)ZSHU_TI_KEYS[(r)$1]} )
|
||||
keys+=( ${(k)ZSHU_FB_KEYS[(r)$1]} )
|
||||
|
||||
[ ${#keys} -eq 0 ] && return 1
|
||||
|
||||
case "${widget}" in
|
||||
/* )
|
||||
widget=${widget:1}
|
||||
emulate zsh -c "autoload -RUz ${widget}"
|
||||
zle -N "${widget}"
|
||||
;;
|
||||
esac
|
||||
|
||||
for i in "${maps[@]}" ; do
|
||||
for k in "${keys[@]}" ; do
|
||||
bindkey -M "$i" "$k" "${widget}"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
z-bind emacs -- Backspace backward-delete-char
|
||||
z-bind viins -- Backspace vi-backward-delete-char
|
||||
z-bind vicmd -- Backspace vi-backward-char
|
||||
z-bind emacs -- Home beginning-of-line
|
||||
z-bind viins vicmd -- Home vi-beginning-of-line
|
||||
z-bind emacs -- End end-of-line
|
||||
z-bind viins vicmd -- End vi-end-of-line
|
||||
z-bind emacs viins -- Insert overwrite-mode
|
||||
z-bind vicmd -- Insert vi-insert
|
||||
z-bind emacs -- Delete delete-char
|
||||
z-bind viins vicmd -- Delete vi-delete-char
|
||||
z-bind emacs viins vicmd -- Up /up-line-or-beginning-search
|
||||
z-bind emacs viins vicmd -- Down /down-line-or-beginning-search
|
||||
z-bind emacs -- Left backward-char
|
||||
z-bind viins vicmd -- Left vi-backward-char
|
||||
z-bind emacs -- Right forward-char
|
||||
z-bind viins vicmd -- Right vi-forward-char
|
||||
z-bind emacs viins vicmd -- PageUp up-line-or-history
|
||||
z-bind emacs viins vicmd -- PageDown down-line-or-history
|
||||
|
||||
z-bind emacs viins vicmd -- Shift-Tab reverse-menu-complete
|
||||
|
||||
z-bind emacs viins vicmd -- Ctrl-Delete kill-word
|
||||
z-bind emacs -- Ctrl-RightArrow forward-word
|
||||
z-bind viins vicmd -- Ctrl-RightArrow vi-forward-word
|
||||
z-bind emacs -- Ctrl-LeftArrow backward-word
|
||||
z-bind viins vicmd -- Ctrl-LeftArrow vi-backward-word
|
||||
|
||||
z-bind emacs viins vicmd -- Esc-w kill-region
|
||||
|
||||
## use emacs key bindings
|
||||
bindkey -e
|
||||
|
||||
for i ( /usr/share/doc/fzf/examples/key-bindings.zsh ) ; do
|
||||
[ -s "$i" ] || continue
|
||||
source $i
|
||||
done ; unset i
|
9
.config/zsh/rc/pager.zsh
Normal file
9
.config/zsh/rc/pager.zsh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/zsh
|
||||
|
||||
PAGER=$(z-alt-find 'less|pager|more')
|
||||
if [ -n "${PAGER}" ] ; then
|
||||
export PAGER
|
||||
READNULLCMD=$(which "${PAGER}" | xargs -r readlink -e)
|
||||
else
|
||||
unset PAGER READNULLCMD NULLCMD
|
||||
fi
|
100
.config/zsh/rc/prompt.zsh
Normal file
100
.config/zsh/rc/prompt.zsh
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/bin/zsh
|
||||
|
||||
typeset -gA ZSHU_PS1
|
||||
|
||||
## three-line prompt
|
||||
function {
|
||||
local -a line
|
||||
|
||||
line+="${ZSHU_PM[rst]}"
|
||||
line+="%B%F{black}┌[%b"
|
||||
line+="%F{yellow}%D{%y.%m.%d} %B%D{%H:%M:%S}%f%b"
|
||||
line+="%B%F{black}|%b"
|
||||
line+='${ZSHU_PM[id]:+"%B%F{white}${ZSHU_PM[id]}${ZSHU_PM[rst]}%B%F{black}|%b%f"}'
|
||||
line+="${ZSHU_PM[user]}%F{white}@${ZSHU_PM[host]}"
|
||||
line+='${ZSHU_PS[elapsed]}'
|
||||
line+="${ZSHU_PM[rst]}"
|
||||
|
||||
line+="${ZSHU_PM[crlf]}"
|
||||
|
||||
line+="%B%F{black}┝%f%b "
|
||||
line+='${ZSHU_PS[pwd]:-${ZSHU_PS[pwd_std]}}'
|
||||
line+='${ZSHU_PS[pwd_extra]}'
|
||||
line+="${ZSHU_PM[rst]}"
|
||||
|
||||
line+="${ZSHU_PM[crlf]}"
|
||||
|
||||
line+="%B%F{black}└[%f%b"
|
||||
line+="${ZSHU_PS[lastcmd]}"
|
||||
line+='${ZSHU_PS[shlvl]}'
|
||||
line+="%B%F{black}|%b%f"
|
||||
line+="${ZSHU_PS[cmd]}"
|
||||
|
||||
ZSHU_PS1[3L]="${(j::)line}"
|
||||
}
|
||||
|
||||
## two-line prompt
|
||||
function {
|
||||
local -a line
|
||||
|
||||
line+="${ZSHU_PM[rst]}"
|
||||
line+="%B%F{black}┌[%b"
|
||||
line+='${ZSHU_PM[id]:+"%B%F{white}${ZSHU_PM[id]}${ZSHU_PM[rst]}%B%F{black}|%b%f"}'
|
||||
line+="${ZSHU_PM[user]}%F{white}@${ZSHU_PM[host]}"
|
||||
line+="%B%F{black}|%b"
|
||||
line+='${ZSHU_PS[pwd]:-${ZSHU_PS[pwd_std]}}'
|
||||
line+='${ZSHU_PS[pwd_extra]}'
|
||||
line+='${ZSHU_PS[elapsed]}'
|
||||
line+="${ZSHU_PM[rst]}"
|
||||
|
||||
line+="${ZSHU_PM[crlf]}"
|
||||
|
||||
line+="%B%F{black}└[%f%b"
|
||||
line+="${ZSHU_PS[lastcmd]}"
|
||||
line+='${ZSHU_PS[shlvl]}'
|
||||
line+="%B%F{black}|%b%f"
|
||||
line+="${ZSHU_PS[cmd]}"
|
||||
|
||||
ZSHU_PS1[2L]="${(j::)line}"
|
||||
}
|
||||
|
||||
## one-line prompt
|
||||
function {
|
||||
local -a line
|
||||
|
||||
line+="${ZSHU_PM[rst]}"
|
||||
line+="${ZSHU_PS[lastcmd]}"
|
||||
line+='${ZSHU_PS[shlvl]}'
|
||||
line+="%B%F{black}|%b"
|
||||
line+="${ZSHU_PM[user]}"
|
||||
line+="%B%F{black}|%b"
|
||||
line+='${ZSHU_PM[id]:+"%B%F{white}${ZSHU_PM[id]}${ZSHU_PM[rst]}%B%F{black}|%b%f"}'
|
||||
line+='${ZSHU_PS[pwd]:-${ZSHU_PS[pwd_std]}}'
|
||||
line+='${ZSHU_PS[pwd_extra]}'
|
||||
line+='${ZSHU_PS[elapsed]}'
|
||||
line+="%B%F{black}|%b"
|
||||
line+="${ZSHU_PS[cmd]}"
|
||||
|
||||
ZSHU_PS1[1L]="${(j::)line}"
|
||||
}
|
||||
|
||||
z-ps1() {
|
||||
[ -n "$1" ] || {
|
||||
echo "${ZSHU_PS[ps1]}"
|
||||
return
|
||||
}
|
||||
|
||||
local k
|
||||
for k ( "$1" "${1}L" ) ; do
|
||||
(( ${+ZSHU_PS1[$k]} )) || continue
|
||||
|
||||
ZSHU_PS[ps1]=$k
|
||||
PS1=${ZSHU_PS1[$k]}
|
||||
return
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
z-ps1 3
|
||||
[ "${ZSHU_RUN[nested]}" = 1 ] && z-ps1 2
|
||||
[ "${ZSHU_RUN[nested1L]}" = 1 ] && z-ps1 1
|
23
.config/zsh/rc/terminal.zsh
Normal file
23
.config/zsh/rc/terminal.zsh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-orig-term() {
|
||||
local -a a
|
||||
local i x
|
||||
|
||||
for i ( ${ZSHU_PARENTS_PID} ) ; do
|
||||
[ -r "/proc/$i/environ" ] || continue
|
||||
x=$(sed -zEn '/^TERM=(.+)$/{s//\1/;p;}' "/proc/$i/environ" 2>/dev/null | tr -d '\0')
|
||||
[ -n "$x" ] || continue
|
||||
a+=( "$x" )
|
||||
done
|
||||
case "$1" in
|
||||
\* | @ )
|
||||
local ORIG_TERM=( $a )
|
||||
declare -p ORIG_TERM
|
||||
;;
|
||||
* )
|
||||
i='-1' ; x="${1:-$i}"
|
||||
echo "${a[$x]}"
|
||||
;;
|
||||
esac
|
||||
}
|
0
.config/zsh/var/.keep
Normal file
0
.config/zsh/var/.keep
Normal file
6
.gdbinit
Normal file
6
.gdbinit
Normal file
@@ -0,0 +1,6 @@
|
||||
undisplay
|
||||
display /i $pc
|
||||
set disassembly-flavor intel
|
||||
layout asm
|
||||
layout regs
|
||||
set debuginfod enabled on
|
35
.gitconfig
Normal file
35
.gitconfig
Normal file
@@ -0,0 +1,35 @@
|
||||
[commit]
|
||||
gpgSign = false
|
||||
[core]
|
||||
abbrev = 8
|
||||
bigFileThreshold = 16m
|
||||
compression = 5
|
||||
[credential]
|
||||
helper = cache --timeout=86400
|
||||
[fetch]
|
||||
writeCommitGraph = true
|
||||
[gc]
|
||||
aggressiveDepth = 100
|
||||
aggressiveWindow = 500
|
||||
auto = 0
|
||||
bigPackThreshold = 512m
|
||||
pruneExpire = now
|
||||
[init]
|
||||
defaultBranch = main
|
||||
[maintainance]
|
||||
auto = false
|
||||
[pack]
|
||||
compression = 7
|
||||
packSizeLimit = 1g
|
||||
threads = 4
|
||||
useSparse = true
|
||||
writeReverseIndex = true
|
||||
[pull]
|
||||
ff = only
|
||||
[push]
|
||||
default = simple
|
||||
gpgSign = false
|
||||
[receive]
|
||||
autogc = false
|
||||
[repack]
|
||||
writeBitmaps = true
|
10
.screenrc
Normal file
10
.screenrc
Normal file
@@ -0,0 +1,10 @@
|
||||
startup_message off
|
||||
# term screen-256color-s
|
||||
bce off
|
||||
defutf8 on
|
||||
utf8 on on
|
||||
defscrollback 8192
|
||||
defflow off
|
||||
deflogin off
|
||||
# defshell -zsh
|
||||
hardstatus alwaysfirstline "%{= ky}%y.%m.%d%{= kK}|%{= kY}%c:%s%{= kK}|%{= kB}%H%{= kK}|%{= kG}%S%{= kK}|%{= kM}#%w%{-}%= %{= kK}|%{= kr}%l%{= kG}"
|
2
.selected_editor
Normal file
2
.selected_editor
Normal file
@@ -0,0 +1,2 @@
|
||||
# Generated by /usr/bin/select-editor
|
||||
SELECTED_EDITOR="/usr/bin/vim.basic"
|
5
.vimrc
Normal file
5
.vimrc
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax on
|
||||
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
|
||||
set nolist
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
7
.zshenv
Normal file
7
.zshenv
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/zsh
|
||||
if [[ -o interactive ]] ; then
|
||||
## early redirect
|
||||
: "${ZDOTDIR:=${HOME}}"
|
||||
[ "${ZDOTDIR}" = "${HOME}/.cache/zsh/dots" ] && ZDOTDIR="${HOME}"
|
||||
source "${ZDOTDIR}/.config/zsh/_.zsh"
|
||||
fi
|
Reference in New Issue
Block a user