1
0

Compare commits

..

130 Commits

Author SHA1 Message Date
403b8a7e6c dotfiles: update git config
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-05-02 16:19:30 +03:00
8137c7efde zsh: git branch snippet 2025-05-02 16:13:31 +03:00
b12c01b3cb git: refresh
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-05-02 15:27:13 +03:00
88262ef200 sbuild: improve changes from fa00d72c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-03-14 10:38:58 +03:00
fa00d72cbc sbuild: enforce random build directory
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-03-14 02:33:22 +03:00
e9e9b7fc51 dotfiles: cleanup
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-01-27 11:24:41 +03:00
5662040673 dotfiles: sbuild
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-01-17 04:16:11 +03:00
5cfbe03d71 zsh: optimize gpg-agent initialization
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-19 20:50:46 +03:00
4e67805847 dotfiles: update gitignore 2024-12-19 20:49:51 +03:00
8956cd7280 dotfiles: separate gitignore for vcs 2024-12-19 20:49:08 +03:00
61fb51b3eb zsh: update sbuild once more
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-08-03 14:08:31 +03:00
4e8515debe zsh: correct sbuild snippet
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-08-03 13:51:01 +03:00
bc90303dc1 ci: minor adjust
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2024-07-28 21:28:58 +03:00
055de153b1 ci: update
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2024-07-28 19:43:09 +03:00
6c0ac78b6e zsh: improve git snippets
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
2024-07-23 23:08:35 +03:00
e6678b1a31 fix bd1f46de
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-07-12 15:45:14 +03:00
bd1f46dec6 zsh: container goodies 2024-07-12 15:41:17 +03:00
9012696fea zsh: bit better PATH 2024-07-10 12:09:31 +03:00
0ae83ee81b dotfiles: improve forge selection 2024-07-05 17:51:22 +03:00
4112913166 git: refresh a bit 2024-07-05 15:02:09 +03:00
8378e9993d zsh: rework krd-quilt 2024-07-05 13:42:31 +03:00
e3ff1bcb69 zsh: update 2024-07-05 13:18:16 +03:00
8283b6c752 zsh: fix dc30f109 2024-06-16 12:51:37 +03:00
785294aef5 zsh: better detect gnu screen 2024-06-16 12:49:12 +03:00
dc30f109cf zsh: adjust container-related stuff 2024-06-16 12:48:58 +03:00
d9ef22abc5 dotfiles: fix copy-paste
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-03-20 12:16:19 +03:00
69ba98a9d5 dotfiles: update
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
select origin dynamically
2024-03-20 11:41:04 +03:00
b2436b9e21 zsh: minor ssh-agent fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-03-04 16:11:07 +03:00
5a9f0b08c0 zsh: ssh-agent persistence
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-03-04 16:05:08 +03:00
98deefe039 zsh: fix ssh-agent
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-03-04 15:47:43 +03:00
6d29f9afbc dotfiles: fix accounting
fixes 20aafe29
2024-03-04 15:42:02 +03:00
20aafe29e8 zsh: update examples
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-03-04 15:39:55 +03:00
8834da817c zsh: update
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-03-04 15:35:55 +03:00
25123cece2 zsh: completion
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
many thanks to blackmou5e for pointing this out
2024-02-29 12:34:20 +03:00
3f527a0c73 zsh: modules
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-02-29 11:10:03 +03:00
3321d21f8b zsh: rework ZDOTDIR redirection
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-02-29 01:04:53 +03:00
7aac214e04 dotfiles: fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-02-29 00:21:48 +03:00
0bb93c3b11 zsh: minor fixes
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-02-29 00:15:08 +03:00
ea774fdd8b dotfiles: update
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
rework htop layout :)
2024-02-29 00:02:58 +03:00
d872b655c9 zsh: update
PS: zprof rocks!
2024-02-28 23:22:33 +03:00
47b2170058 zsh: update
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-02-23 21:46:04 +03:00
0289d90fb9 zsh: zwc things
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-02-20 09:51:55 +03:00
a54be4863a dotfiles: remove unreachable code
found by CI
2024-02-20 09:35:47 +03:00
d05065f3aa ci: introduce 2024-02-20 09:35:34 +03:00
af26648283 zsh: correct podman-to-docker examples 2024-02-18 15:14:43 +03:00
b9b056d10d zsh: update 2024-02-18 15:10:19 +03:00
f77e4a54bc tools: refresh configs 2024-02-18 03:03:16 +03:00
9725317a4a zsh: update 2024-02-18 02:32:08 +03:00
aea9334649 zsh: update 2024-02-13 18:54:46 +03:00
8af457ab05 zsh: update git functions 2024-02-12 12:07:41 +03:00
d65860c0ac git: refresh a bit 2024-01-27 11:24:27 +03:00
9d1de60648 zsh: update 2024-01-27 00:10:58 +03:00
d5209414e9 zsh: git prompt 2024-01-20 13:54:23 +03:00
ad4acd935a zsh: misc git functions 2024-01-20 13:54:12 +03:00
9bd1bb79ea zsh: update 2024-01-16 02:55:39 +03:00
19571a4046 zsh: fix grep alias
fixes 086279d7
2023-12-23 11:19:21 +03:00
7a8ba289fa update tracked files list 2023-12-23 09:16:06 +03:00
086279d721 zsh: move/hide initialization
this also improves .zsh bytecode compilation
2023-12-23 09:15:33 +03:00
d2061dda65 update internal scripts 2023-12-23 09:11:04 +03:00
5fd6a13726 screen: drastically decrease scrollback 2023-12-23 09:05:19 +03:00
e10445bf10 git: refresh a bit 2023-11-23 12:26:41 +03:00
80ae65a3fa env: container-related 2023-09-22 10:21:06 +03:00
25c314caa9 minor terminal fixup 2023-07-20 00:31:30 +03:00
e76ed11c36 gdb: enable debuginfod 2022-10-23 13:16:13 +03:00
2ef127fe7a zsh: globbing 2022-09-05 11:11:57 +03:00
3220c72f6f zsh: cache tasks 2022-09-05 10:42:43 +03:00
55324be58e zsh: compile without aliases 2022-09-05 10:39:16 +03:00
ac9d7a7de6 zsh: compile cache & cache flush 2022-09-05 10:35:13 +03:00
5041d2c7e7 update tracked files list 2022-09-05 10:19:19 +03:00
f6a2541e4f git: pack.threads=4 2022-09-01 13:57:30 +03:00
732d00440e htop: add example config 2022-07-29 10:09:54 +03:00
e59ee51009 git: core.abbrev=8 2022-07-29 09:24:07 +03:00
de28616e6c git: refresh a bit 2022-07-20 00:11:48 +03:00
d524b4255a install: dumb support for local proxies 2022-07-20 00:10:20 +03:00
724df8e2d8 zsh: treewide: minor fixes/style 2022-07-19 02:41:45 +03:00
0ec196bef2 fix for select-editor
it's a bit dumb :)
2022-05-18 11:40:59 +03:00
23275ec9fc rework personal completions
also support:
- fd/fdfind
- hyperfine
2022-05-18 11:39:55 +03:00
2622b6e7e8 fd/fdfind completion 2022-05-18 11:14:55 +03:00
4a2b874478 add dumb completion routine 2022-05-18 11:13:35 +03:00
48a90c3981 guard find call in completion 2022-05-18 10:41:27 +03:00
f0a6c78243 add simple cache flush routine 2022-05-18 10:41:08 +03:00
faae072861 refactor key bindings 2022-05-18 10:29:39 +03:00
a70347e7f7 drop remnants 2022-05-18 10:21:00 +03:00
3b50183a0d drop useless placeholder 2022-05-18 09:57:25 +03:00
113ce00644 zsh: use fzf if any 2022-05-09 12:58:59 +03:00
e6fef308ef update vimrc again 2022-01-08 23:29:28 +03:00
5e2f600eba update vimrc 2022-01-08 22:51:33 +03:00
27137da435 minor fixes for gitconfig 2021-12-08 23:46:00 +03:00
cf3e5623ab fix "bud" alias 2021-12-07 11:53:52 +03:00
731471aee7 zsh: aliases and related 2021-12-07 02:46:50 +03:00
95d73f7f64 git: update conf 2021-12-05 18:58:24 +03:00
59c691e5df git: fix typo 2021-11-18 19:18:07 +03:00
5e64dfe3fe git: update conf 2021-11-08 08:32:59 +03:00
e1ac7abd92 podman run: provide TERM to container 2021-10-29 22:35:35 +03:00
7f0793da39 one more podman alias 2021-10-13 14:32:05 +03:00
3c91a3f5ae update tracked files list 2021-10-01 10:23:00 +03:00
deed34735d add k8s completion and alias 2021-10-01 10:22:25 +03:00
54ae3affd0 add gpg helper function 2021-10-01 10:22:10 +03:00
6ecf110b2c completion: allow manual invalidation 2021-10-01 10:15:45 +03:00
bc5e07f76e treewide: style (trivia) 2021-10-01 10:14:53 +03:00
f07d2d3b35 add 'podman run' alias 2021-09-29 11:26:06 +03:00
e9ba43b038 update gitignore
fixes: 765d07a7, 6530af46
2021-08-18 10:04:59 +03:00
1c849b0404 fix title function for real terminal 2021-07-29 08:53:10 +03:00
765d07a7b8 set title 2021-06-05 13:53:16 +03:00
6530af46f0 split term functions 2021-06-05 13:49:09 +03:00
5addb3ae5e fix default locale setting 2021-05-10 12:59:36 +03:00
5626190a83 add identity (icon) in prompt 2021-05-07 17:11:02 +03:00
2e41d859c9 modify cmd prompt coloring 2021-05-07 17:10:12 +03:00
b0e681a87a remove unused variable 2021-05-07 14:42:58 +03:00
786277961d extend git configuration 2021-05-04 12:33:38 +03:00
e014ff180f configure full name and email 2021-04-19 01:21:34 +03:00
17ef24e460 partially undo changes in screenrc 2021-04-19 01:01:15 +03:00
5a06ade27b force update with script 2021-04-19 01:01:15 +03:00
83a61a4c2f highlight user and host in prompt when required 2021-04-19 01:01:15 +03:00
5394f208b6 remove TERM fixup :) 2021-04-19 01:01:15 +03:00
a312de64e1 avoid interaction with PID1 2021-04-19 01:01:15 +03:00
04b31f7a24 add TERM fixup 2021-04-19 01:01:14 +03:00
a6b87e2330 add buildah alias 2021-04-19 01:01:14 +03:00
4cc414b20d add missing file to gitignore 2021-04-19 01:01:14 +03:00
100187ca04 add kconfig helper functions 2021-04-19 01:01:14 +03:00
ac12fc459b modify bash-completion loader 2021-04-19 01:01:14 +03:00
7bf6262945 modify external completion routines 2021-04-19 01:01:13 +03:00
26f29d0514 support more nesting levels 2021-04-19 01:01:13 +03:00
ad82f32828 fix fresh install with ancient git 2021-04-19 01:01:13 +03:00
87d9c7f978 rename remaining remnants 2021-04-19 01:01:13 +03:00
eeaa54993a dotfiles maintenance in subshell 2021-04-19 01:01:13 +03:00
32bd17a702 fix update logic 2021-04-19 01:01:12 +03:00
9e79767704 don't modify git remote when updating 2021-04-19 01:01:12 +03:00
467332a5ec fix fresh install with git available 2021-04-19 01:01:12 +03:00
28231f278c initial commit 2021-04-19 01:00:58 +03:00
94 changed files with 3062 additions and 81 deletions

View File

View File

0
.cache/zsh/compzwc/.keep Normal file
View File

0
.cache/zsh/ssh/.keep Normal file
View File

View File

View 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

View File

View File

@@ -0,0 +1,93 @@
*
!/.cache/zsh/compcache/.keep
!/.cache/zsh/completion/.keep
!/.cache/zsh/compzwc/.keep
!/.cache/zsh/ssh/.keep
!/.config/dotfiles/bin/.keep
!/.config/dotfiles/gen-gitignore.sh
!/.config/dotfiles/gitattributes
!/.config/dotfiles/gitignore
!/.config/dotfiles/gitignore.vcs
!/.config/dotfiles/install.sh
!/.config/dotfiles/scripts/.keep
!/.config/dotfiles/woodpecker.yml
!/.config/htop/htoprc.dist
!/.config/mc/ini.dist
!/.config/sbuild/config.pl.dist
!/.config/zsh.dots/.zshenv
!/.config/zsh/_.zsh
!/.config/zsh/_wip/enclave.zsh.wip
!/.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/sed.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/csv.zsh
!/.config/zsh/lib/curl.zsh
!/.config/zsh/lib/git.zsh
!/.config/zsh/lib/gpg.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/systemd.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/local/env.zsh.example
!/.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/gpg-agent.zsh
!/.config/zsh/rc/keyboard.zsh
!/.config/zsh/rc/pager.zsh
!/.config/zsh/rc/prompt.zsh
!/.config/zsh/rc/ssh-agent.zsh
!/.config/zsh/rc/terminal.zsh
!/.config/zsh/var/.keep
!/.gdbinit
!/.gitconfig
!/.sbuildrc.dist
!/.screenrc
!/.selected_editor
!/.vimrc
!/.zshenv
!/.zshrc

View File

@@ -0,0 +1,18 @@
!/.cache/zsh/compcache/.keep
!/.cache/zsh/completion/.keep
!/.cache/zsh/compzwc/.keep
!/.cache/zsh/ssh/.keep
!/.config/zsh/local/.keep
!/.config/zsh/local/completion/.keep
!/.config/zsh/local/env.zsh.example
!/.config/zsh/var/.keep
/.cache/zsh/compcache/*
/.cache/zsh/compdump
/.cache/zsh/completion/*
/.cache/zsh/compzwc/*
/.cache/zsh/ssh/*
/.config/zsh/**/*.zwc
/.config/zsh/local.zsh
/.config/zsh/local/*
/.config/zsh/var/*

278
.config/dotfiles/install.sh Executable file
View File

@@ -0,0 +1,278 @@
#!/bin/sh
set -ef
uri_krdsh="${GITKRDSH:-https://git.krd.sh/krd}/dotfiles"
uri_github="${GITHUB:-https://github.com/rockdrilla}/dotfiles"
git_branch='main'
d_repo='.config/dotfiles/repo.git'
f_gitignore='.config/dotfiles/gitignore'
have_cmd() {
command -v "$1" >/dev/null 2>&1 || return $?
}
fetch() {
if have_cmd curl ; then
curl -sSL ${2:+ -o "$2" } "$1" || return $?
return 0
fi
if have_cmd wget ; then
if [ -n "$2" ] ; then
wget -q -O - "$1" > "$2" || return $?
else
wget -q -O - "$1" || return $?
fi
return 0
fi
x=/usr/lib/apt/apt-helper
if have_cmd $x ; then
if [ -n "$2" ] ; then
$x download-file "$1" "$2" || return $?
return 0
fi
__fetch_t=$(mktemp) || return 1
set +e
(
set -e
$x download-file "$1" "${__fetch_t}" || return $?
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
}
test_forge() {
fetch "$1" "$2" || return 1
[ "$(head -n 1 "$2")" = '*' ] || return 1
return 0
}
select_forge() {
unset uri_gitignore uri_repo uri_tarball
__t=$(mktemp)
## try with git.krd.sh
while [ -z "${uri_repo}" ] ; do
t_gitignore="${uri_krdsh}/raw/branch/${git_branch}/${f_gitignore}"
test_forge "${t_gitignore}" "${__t}" || break
uri_repo="${uri_krdsh}.git"
uri_gitignore="${t_gitignore}"
uri_tarball="${uri_krdsh}/archive/${git_branch}.tar.gz"
break
done
## try with github.com
while [ -z "${uri_repo}" ] ; do
t_gitignore="${uri_github}/raw/${git_branch}/${f_gitignore}"
test_forge "${t_gitignore}" "${__t}" || break
uri_repo="${uri_github}.git"
uri_gitignore="${t_gitignore}"
uri_tarball="${uri_github}/archive/refs/heads/${git_branch}.tar.gz"
break
done
rm -f "${__t}" ; unset __t
unset t_gitignore
if [ -n "${uri_repo}" ] ; then
return 0
fi
echo 'no forge is available to fetch URLs' >&2
return 1
}
main() {
## test connectivity and select forge
select_forge
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 "${git_branch}" || 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 "${uri_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 "${uri_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 "${uri_repo}"
git config remote.origin.fetch "+refs/heads/${git_branch}:refs/remotes/origin/${git_branch}"
git config remote.origin.tagopt '--no-tags'
git config "branch.${git_branch}.remote" origin
## repo-specific
git config core.worktree "${GIT_WORK_TREE}"
git config core.excludesfile "${f_gitignore}"
}
git_config() {
## repo-specific
git remote set-url origin "${uri_repo}"
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.bigFileThreshold 64k
git config core.compression 9
git config core.looseCompression 8
git config pack.compression 9
git config pack.threads 2
## generic
git config receive.denyNonFastForwards true
}
git_update() {
git_config
git remote update -p
git pull || git reset --hard "origin/${git_branch}"
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 "${uri_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 "$@"

View File

View File

@@ -0,0 +1,34 @@
steps:
- name: check
image: docker.io/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' | sort -V
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

65
.config/htop/htoprc.dist Normal file
View 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
View File

@@ -0,0 +1,2 @@
[Midnight-Commander]
skin=dark

View File

@@ -0,0 +1,21 @@
$chroot_mode = "schroot";
$build_path = '';
$pgp_options = [ '-us', '-uc', '-ui' ];
$build_arch_all = 1;
$build_arch_any = 1;
$check_space = 0;
$enable_network = 1;
$run_autopkgtest = 0;
$run_lintian = 0;
$run_piuparts = 0;
$apt_distupgrade = 0;
$apt_upgrade = 0;
$purge_build_directory = 'successful';
# don't remove this, Perl needs it:
1;

6
.config/zsh.dots/.zshenv Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/zsh
if [[ -o interactive ]] ; then
## early redirect
ZDOTDIR="${ZDOTDIR%/${ZDOTDIR:t2}}"
source "${ZDOTDIR}/.zshenv"
fi

55
.config/zsh/_.zsh Normal file
View File

@@ -0,0 +1,55 @@
#!/bin/zsh
## early module load
zmodload -s zsh/zprof
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="${ZDOTDIR}/.config/zsh.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

View 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

5
.config/zsh/alias.zsh Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/zsh
alias which='whence -p '
alias which-command='whence -p '
alias zsh-which='whence -c '

View File

@@ -0,0 +1,197 @@
#!/bin/zsh
typeset -Uga ZSHU_CNTR_SHELLS=( /bin/bash /bin/sh /bin/ash )
typeset -ga ZSHU_CNTR_FALLBACK_SHELL=( /busybox/busybox sh )
alias bud='buildah bud --network=host -f '
function {
local i
for i ( run images ps top inspect logs ) ; do
alias "pod-$i"="podman $i "
done
}
z-pod() { command podman "$@" ; }
alias podman='z-podman '
z-podman() {
case "${1:-}" in
run ) shift ; z-pod-run "$@" ;;
images ) shift ; z-pod-images "$@" ;;
ps ) shift ; z-pod-ps "$@" ;;
top ) shift ; z-pod-top "$@" ;;
* ) z-pod "$@" ;;
esac
}
z-pod-run() {
z-pod run -e "TERM=${TERM:-linux}" --rm -it "$@"
}
z-pod-images() {
local have_flags=0
case "$1" in
-* ) have_flags=1 ;;
esac
if [ ${have_flags} = 1 ] ; then
z-pod images "$@"
return $?
fi
z-pod images --format 'table {{.ID}} {{.Repository}}:{{.Tag}} {{.Size}} {{.Created}} |{{.CreatedAt}}' "$@"
}
z-pod-ps() {
local have_flags=0
case "$1" in
-* ) have_flags=1 ;;
esac
if [ ${have_flags} = 1 ] ; then
z-pod ps "$@"
return $?
fi
z-pod ps -a --sort names --format 'table {{.ID}} {{.Names}} {{.Image}} {{.CreatedHuman}} {{.Status}}' "$@"
}
z-pod-top() {
local have_flags=0
case "$1" in
-* ) have_flags=1 ;;
esac
if [ ${have_flags} = 1 ] ; then
z-pod top "$@"
return $?
fi
if [ $# -eq 1 ] ; then
z-pod top "$1" 'pid,ppid,user,args,pcpu,time,stime,etime,state,nice,rss,vsz'
else
z-pod top "$@"
fi
}
pod-images-grep() {
z-pod-images \
| {
if [ -z "$1" ] ; then
head
else
sed -En "1{p;D};\\${ZSHU_XSED}$1${ZSHU_XSED}p"
fi
}
}
## NB: naive. rewrite!
pod-run-sh() {
local -a cntr_opts=( --network=host --entrypoint='[]' --user=0:0 )
local i
local -a shell
for i ( ${ZSHU_CNTR_SHELLS} ) ; do
echo "pod-run-sh: trying $i as shell" >&2
z-pod-run ${cntr_opts[@]} "$@" "$i" -c ':' 2>/dev/null || continue
shell=($i) ; break
done
while [ -z "${shell}" ] ; do
echo "pod-run-sh: trying '${ZSHU_CNTR_FALLBACK_SHELL[*]}' as last-resort shell" >&2
z-pod-run ${cntr_opts[@]} "$@" ${ZSHU_CNTR_FALLBACK_SHELL[@]} -c ':' 2>/dev/null || break
shell=(${ZSHU_CNTR_FALLBACK_SHELL})
break
done
if [ -z "${shell}" ] ; then
echo "unable to run: $*"
return 1
fi
z-pod-run ${cntr_opts[@]} "$@" ${shell[@]}
}
## NB: naive. rewrite!
sko-inspect() {
local i
i="${1:?}" ; shift
command skopeo inspect "$@" "docker://$i"
}
## NB: naive. rewrite!
sko-list-tags() {
local i
i="${1:?}" ; shift
command skopeo list-tags "$@" "docker://$i"
}
## NB: naive. rewrite!
pod-dive() {
local i
i="${1:?}" ; shift
command dive "$@" "podman://$i"
}
jq-visual() { jq -C | "${PAGER:-cat}" ; }
jq-config() { jq '.[].Config' ; }
jq-tags() { jq -r '.Tags[]' ; }
alias dkr='docker '
alias dkr-run='dkr run -e "TERM=${TERM:-linux}" --rm -it '
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 '
z-dkr() { command docker "$@" ; }
z-dkr-run() {
z-dkr run -e "TERM=${TERM:-linux}" --rm -it "$@"
}
## NB: naive. rewrite!
dkr-run-sh() {
local -a cntr_opts=( --network=host --entrypoint='' --user=0:0 )
local i
local -a shell
for i ( ${ZSHU_CNTR_SHELLS} ) ; do
echo "dkr-run-sh: trying $i as shell" >&2
z-dkr-run ${cntr_opts[@]} "$@" "$i" -c ':' 2>/dev/null || continue
shell=($i) ; break
done
while [ -z "${shell}" ] ; do
echo "dkr-run-sh: trying '${ZSHU_CNTR_FALLBACK_SHELL[*]}' as last-resort shell" >&2
z-dkr-run ${cntr_opts[@]} "$@" ${ZSHU_CNTR_FALLBACK_SHELL[@]} -c ':' 2>/dev/null || break
shell=(${ZSHU_CNTR_FALLBACK_SHELL})
break
done
if [ -z "${shell}" ] ; then
echo "unable to run: $*"
return 1
fi
z-dkr-run ${cntr_opts[@]} "$@" ${shell[@]}
}
## NB: naive. rewrite!
dkr-dive() {
local i
i="${1:?}" ; shift
command dive "$@" "docker://$i"
}
typeset -g ZSHU_GRP_DOCKER=docker
z-adjust-docker() {
[ ${UID} -eq 0 ] && return 0
getent group "${ZSHU_GRP_DOCKER}" >/dev/null || return 1
(( ${+commands[docker]} )) || return 127
local _users=$(getent group "${ZSHU_GRP_DOCKER}" | cut -d: -f4)
local -a users=("${(@s[,])_users}")
local i found
for i ( ${users}) ; do
if [ "$i" = "${USERNAME}" ] ; then
found=1
break
fi
done
[ -n "${found}" ] && return 0
(( ${+commands[sudo]} )) || return 127
alias docker='sudo docker '
z-dkr() { command sudo docker "$@" ; }
return 0
}

View File

@@ -0,0 +1,5 @@
#!/bin/zsh
z-alt-set-static \
'diff|. .' \
'diff --color=auto|diff'

View 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
}

68
.config/zsh/alias/git.zsh Normal file
View File

@@ -0,0 +1,68 @@
#!/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
for x ( logs/refs objects/info objects/pack ) ; do
[ -d "${gitdir}/$x" ] || continue
subdirs+="${gitdir}/$x"
done
(
[ -n "${topdir}" ] && cd "${topdir}/"
if [ ${#subdirs} -gt 0 ] ; then
du -d1 "${subdirs[@]}"
fi
du -d1 "${gitdir}"
) | grep -Ev '^[0-9]K?\s' | sort -Vk2
}
git-gc() {
git-dir-usage || return $?
echo
echo "# git gc $*" >&2
z-time idle git gc "$@"
echo
git-dir-usage
}
git-gc-force() {
git-dir-usage || return $?
echo
echo "# git gc --aggressive --force $*" >&2
z-time idle git gc --aggressive --force "$@"
echo
echo "# git repack -Ad" >&2
z-time idle git repack -Ad
echo
git-dir-usage
}
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
}
git-br() {
__z_git -c core.pager='cat' branch --no-abbrev "$@"
}

14
.config/zsh/alias/gpg.zsh Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/zsh
gpg-warmup() {
(( ${+commands[gpg]} )) || return 127
local t r
t=$(mktemp)
command gpg -abs "$t"
r=$?
rm -f "$t" "$t.asc"
return "$r"
}

View 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 '

View File

@@ -0,0 +1,5 @@
#!/bin/zsh
fc() { builtin fc -i "$@" ; }
# history() { builtin fc -il "$@" ; }

View File

@@ -0,0 +1,42 @@
#!/bin/zsh
idle() {
[ -n "${1:?}" ]
local f
f=$(type "$1")
case "$f" in
"$1 is /"* )
z-idle-ext "$@"
;;
* )
z-idle-int "$@"
;;
esac
}
z-idle-ext() {
[ -n "${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:?}" ]
## 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
"$@"
)
}

View File

@@ -0,0 +1,3 @@
#!/bin/zsh
alias k='kubectl '

View File

@@ -0,0 +1,23 @@
#!/bin/zsh
kconf-set() {
local n v
n="${1:?}" v=$2
shift 2
[ $# -gt 0 ] || return 1
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() {
local n
n="${1:?}"
shift
[ $# -gt 0 ] || return 1
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
View 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

View File

@@ -0,0 +1,84 @@
#!/bin/zsh
z-quilt() { command quilt "$@" ; }
quilt-series-strip-comments() {
sed -E '/^[[:space:]]*(#|$)/d' "$@"
}
quilt-series-auto() {
[ -n "${1:?}" ]
[ -d "$1" ] || return 1
find "$1/" -follow -type f -printf '%P\0' \
| sed -zEn '/\.(diff|patch)$/p' \
| sort -zuV \
| xargs -0r printf '%s\n'
}
krd-quilt() {
(( $+commands[quilt] )) || return 127
[ -n "${1:?}" ]
local patchdir series tmp_series
if [ -d "$1" ] ; then
patchdir="$1/debian/patches"
if [ -d "${patchdir}" ] ; then
[ -f "${patchdir}/series" ] || return 1
else
patchdir="$1"
fi
series="${patchdir}/series"
if ! [ -f "${series}" ] ; then
mkdir -p "$1/.pc" || return 1
series="$1/.pc/krd-quilt-series"
touch "${series}" || return 1
quilt-series-auto "${patchdir}" > "${series}"
fi
elif [ -f "$1" ] ; then
[ -s "$1" ] || return 1
series="$1"
patchdir=${series:h}
else
return 1
fi
local r
(
z-quilt-default-env
set -a
QUILT_SERIES="${series}"
QUILT_PATCHES="${patchdir}"
set +a
r=0
while read -rs i ; do
[ -n "$i" ] || continue
z-quilt --fuzz=0 push "$i"
r=$? ; [ $r -eq 0 ] || exit $r
z-quilt refresh "$i"
r=$? ; [ $r -eq 0 ] || exit $r
sed -E -i \
-e 's#^(-{3} )[^/][^/]*/(.*)$#\1a/\2#;' \
-e 's#^(\+{3} )[^/][^/]*/(.*)$#\1b/\2#' \
"$i"
rm -f "$i"'~'
done <<< $(
if ! z-quilt unapplied ; then
quilt-series-strip-comments "${series}" \
| sed -E "s${ZSHU_XSED}^${ZSHU_XSED}${patchdir}/${ZSHU_XSED}"
fi
)
exit $r
)
r=$?
return $r
}

View File

@@ -0,0 +1,74 @@
#!/bin/zsh
krd-debsrc() {
(( $+commands[deb-src-export] )) || return 127
[ -n "${1:?}" ]
local dstdir
case "$1" in
*/* ) dstdir="$1/src" ;;
* ) dstdir="/tmp/$1/src" ;;
esac
rm -rf "${dstdir}"
deb-src-export "${dstdir}"
}
krd-sbuild() {
(( $+commands[sbuild] )) || return 127
(( $+commands[xz] )) || return 127
[ -n "${1:?}" ]
[ -n "${2:?}" ]
local topdir
case "$1" in
*/* ) topdir="$1" ;;
* ) topdir="/tmp/$1" ;;
esac
[ -d "${topdir}" ] || return 1
local srcdir="${topdir}/src"
[ -d "${srcdir}" ] || return 2
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_args+=( $i ) ;;
*=* ) 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}-all" "${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 '*_all.deb' -type f -exec mv -fvt "../${arch}-all" {} +
find -name '*_all.ddeb' -type f -exec mv -fvt "../${arch}-all" {} +
find -name '*dbgsym*.deb' -type f -exec mv -fvt "../${arch}-debug" {} +
find -name '*.ddeb' -type f -exec mv -fvt "../${arch}-debug" {} +
cd "${builddir}-all"
find -type f -exec mv -nvt '../all' {} +
)
}

View 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"
}

View 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

View File

View File

@@ -0,0 +1,5 @@
#!/bin/zsh
for i ( buildah ) ; do
__z_comp_bash $i
done ; unset i

View 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

View File

@@ -0,0 +1,5 @@
#!/bin/zsh
for i ( fd fdfind hyperfine ) ; do
__z_comp_system $i
done ; unset i

96
.config/zsh/env.zsh Normal file
View File

@@ -0,0 +1,96 @@
#!/bin/zsh
## sort-n-fill PATH
z-sort-path() {
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 :)
## in case of merged /usr
[ -h /sbin ] || npath+=( /sbin )
[ -h /bin ] || npath+=( /bin )
npath+=( $p )
## finally... games! xD
npath+=( /usr/local/games /usr/games )
npath+=( ${games} )
path=( ${npath} )
hash -f
}
z-sort-path
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]}
}
case "${ZSHU[os_family]}" in
linux ) ZSHU[procfs]=/proc ;;
esac

8
.config/zsh/env/aux.zsh vendored Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/zsh
set -a
NO_AT_BRIDGE=1
QT_ACCESSIBILITY=0
MENUCONFIG_COLOR=blackbg
set +a

11
.config/zsh/env/containers.zsh vendored Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/zsh
BUILDAH_FORMAT=docker
BUILDAH_ISOLATION=chroot
typeset -x -m 'BUILDAH_*'
BUILD_IMAGE_NETWORK=host
BUILD_IMAGE_PUSH=0
typeset -x -m 'BUILD_IMAGE*'

21
.config/zsh/env/gopath.zsh vendored Normal file
View File

@@ -0,0 +1,21 @@
#!/bin/zsh
z-gobin-fixup() {
(( ${+commands[go]} )) || return 0
local gobin
gobin=$(command go env GOBIN)
if [ -z "${gobin}" ] ; then
local gopath
gopath=$(command 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} )
}
z-gobin-fixup

10
.config/zsh/env/history.zsh vendored Normal file
View 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
View 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
View File

@@ -0,0 +1,3 @@
#!/bin/zsh
export LESS=RSF

15
.config/zsh/env/quilt.zsh vendored Normal file
View 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

3
.config/zsh/env/sed.zsh vendored Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/zsh
typeset -r ZSHU_XSED=$'\027'

13
.config/zsh/env/xdg.zsh vendored Normal file
View 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
View File

@@ -0,0 +1,6 @@
#!/bin/zsh
disable which
which() { builtin whence -p "$@"; }
which-command() { builtin whence -p "$@"; }
zsh-which() { builtin whence -c "$@"; }

View 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"
}

View 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

View File

@@ -0,0 +1,145 @@
#!/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() {
# (( ${+commands[$1]} )) || return 127
local f p x
(( ${+_comps[$1]} )) && return 1
(( ${+ZSHU[compdump_bash]} )) || return 2
(( ${+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 3
complete -C "$x" "$1"
return 0
}
__z_comp_external() {
local c f
c="$1" ; shift
(( ${+commands[$c]} )) || return 127
[ $# -gt 0 ] || return 1
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 2
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() {
# (( ${+commands[$1]} )) || return 127
local d
(( ${+_comps[$1]} )) && return 1
(( ${+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 2
}
## reload or new session are required to regenerate compcache
z-comp-invalidate() {
[ -n "${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
}

33
.config/zsh/lib/csv.zsh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/zsh
## NB: set IFS manually
z-csv-select() {
local field value
field="${1:?}" value="${2:?}"
local line
local -a ary
while IFS='' read -rs line ; do
[ -n "${line}" ] || continue
ary=()
read -rs -A ary <<< "${line}"
[ "${ary[${field}]}" = "${value}" ] || continue
printf '%s' "${line}"
return 0
done
return 1
}
z-csv-field() {
local field
field="${1:?}"
local -a ary
read -rs -A ary
printf '%s' "${ary[${field}]}"
}

14
.config/zsh/lib/curl.zsh Normal file
View 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
View 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 $?
__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"

45
.config/zsh/lib/gpg.zsh Normal file
View File

@@ -0,0 +1,45 @@
#!/bin/zsh
z-gpgconf-comp-avail() {
(( ${+commands[gpgconf]} )) || return 127
local comp
comp="${1:?}"
local csv
csv=$(command gpgconf --list-components | IFS=':' z-csv-select 1 "${comp}")
[ -n "${csv}" ]
}
z-gpgconf-comp-opt-avail() {
(( ${+commands[gpgconf]} )) || return 127
local comp opt
comp="${1:?}" opt="${2:?}"
z-gpgconf-comp-avail "${comp}" || return $?
local csv
csv=$(command gpgconf --list-options "${comp}" | IFS=':' z-csv-select 1 "${opt}")
[ -n "${csv}" ]
}
## merely that command:
## gpgconf --list-options "$1" | awk -F: "/^$2:/{ print \$10 }"
z-gpgconf-getopt() {
(( ${+commands[gpgconf]} )) || return 127
local comp opt
comp="${1:?}" opt="${2:?}"
## not really necessary here
# z-gpgconf-comp-opt-avail "${comp}" "${opt}" || return $?
local csv
csv=$(command gpgconf --list-options "${comp}" | IFS=':' z-csv-select 1 "${opt}")
[ -n "${csv}" ] || return 1
local v
v=$(IFS=':' z-csv-field 10 <<< "${csv}")
printf '%s' "$v"
}

View 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}*" "$@"
}

View 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

View File

@@ -0,0 +1,83 @@
#!/bin/zsh
z-proc-exists() {
[ -n "${1:?}" ]
while [ -n "${ZSHU[procfs]}" ] ; do
[ -d "${ZSHU[procfs]}" ] || return 1
[ -f "${ZSHU[procfs]}/$1/status" ]
return $?
done
ps -o 'pid=' -p "$1" >/dev/null 2>&1
}
typeset -Uga ZSHU_PARENTS_PID
typeset -ga ZSHU_PARENTS_NAME
function {
local procfs
while [ -n "${ZSHU[procfs]}" ] ; do
[ -d "${ZSHU[procfs]}" ] || break
procfs=1 ; break
done
local i c x _unused
i=${PPID}
while : ; do
[ -n "$i" ] || break
## don't deal with PID1
[ "$i" = 1 ] && break
ZSHU_PARENTS_PID+=( $i )
c=
while [ "${procfs}" = 1 ] ; do
[ -f "${ZSHU[procfs]}/$i/cmdline" ] || break
read -d $'\0' -rs c <<< $(cat "${ZSHU[procfs]}/$i/cmdline")
break
done
if [ -z "$c" ] ; then
read -rs c _unused <<< "$(ps -o 'comm=' -p "$i" 2>/dev/null)"
fi
[ -n "$c" ] && ZSHU_PARENTS_NAME+=( "${c:t}" )
x=
while [ "${procfs}" = 1 ] ; do
[ -f "${ZSHU[procfs]}/$i/status" ] || break
# read -rs _unused x <<< "$(cat "${ZSHU[procfs]}/$i/status" | grep -F 'PPid:')"
while read -rs _unused c ; do
[ "${_unused}" = 'PPid:' ] || continue
x=$c ; break
done < "${ZSHU[procfs]}/$i/status"
break
done
if [ -z "$x" ] ; then
read -rs x _unused <<< "$(ps -o 'ppid=' -p "$i" 2>/dev/null)"
fi
i=$x
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 screen tmux mc
z-run-test nested1L mc
z-run-test elevated sudo su

View 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
}

View File

@@ -0,0 +1,71 @@
#!/bin/zsh
dotfiles-update() {
"${ZSHU[d_dotfiles]}/install.sh" "$@" || return $?
}
dotfiles-git() { (
cd "${ZSHU[d_zdot]}/"
set -a
GIT_DIR="${ZSHU[d_dotfiles]}/repo.git"
GIT_WORK_TREE="${ZSHU[d_zdot]}"
set +a
z-reload
) }
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 2
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 || return $?
z-cache-flush
}
z-reload() {
export ZDOTDIR="${ZSHU[d_zdot]}"
local r
exec -a "${ZSH_ARGZERO}" "${ZSH_NAME}" "${argv[@]}"
r=$?
echo "unable to reload (something went wrong), code $r" >&2
return $r
}
## reload or new session are required to regenerate compcache
z-cache-flush() {
find "${ZSHU[d_cache]}/" -xdev -type f '!' -name '.keep' -delete
find "${ZSHU[d_zdot]}/.config/zsh.dots/" -xdev -type f '!' -name '.zshenv' -delete
z-zwc-flush
z-zwc-gen
}

View File

@@ -0,0 +1,18 @@
#!/bin/zsh
z-systemctl() {
command systemctl --quiet --no-pager --lines=0 --no-ask-password "$@"
}
z-systemctl-status-rc() {
z-systemctl status "$@" >/dev/null 2>&1
}
z-systemctl-exists() {
z-systemctl-status-rc "$@"
case "$?" in
0 | 1 | 3 ) return 0 ;;
## also 4 = "no such unit"
* ) return 1 ;;
esac
}

18
.config/zsh/lib/term.zsh Normal file
View 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
View 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
View 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" >&2
fi

View File

@@ -0,0 +1,4 @@
#!/bin/zsh
## skip system-wide podman completion and produce own
ZSHU_COMP_FORCE[podman]=1

0
.config/zsh/local/.keep Normal file
View File

View File

View File

@@ -0,0 +1,11 @@
#!/bin/zsh
z-ssh-agent
z-gpg-agent
z-adjust-docker
## 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

13
.config/zsh/opt.zsh Normal file
View 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

View File

@@ -0,0 +1,5 @@
#!/bin/zsh
z-chase() { setopt chase_dots chase_links ; }
z-nochase() { unsetopt chase_dots chase_links ; }
z-nochase

View File

@@ -0,0 +1,9 @@
#!/bin/zsh
unsetopt flow_control
unsetopt menu_complete
setopt always_to_end
setopt auto_menu
setopt complete_aliases
setopt complete_in_word

View File

@@ -0,0 +1,7 @@
#!/bin/zsh
setopt auto_cd
setopt auto_pushd
setopt cdable_vars
setopt pushd_ignore_dups
setopt pushd_minus

View 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

View File

@@ -0,0 +1,3 @@
#!/bin/zsh
setopt prompt_subst

28
.config/zsh/rc.zsh Normal file
View 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"
done
unset i zshu_modules
autoload -Uz +X colors && colors

View File

@@ -0,0 +1,41 @@
#!/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]}"
unset 'ZSHU[compdump_bash]'
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

View File

@@ -0,0 +1,38 @@
#!/bin/zsh
z-gpg-agent() {
## don't bother with gpg agent socket if it already set
[ -z "${GPG_AGENT_INFO}" ] || return 0
(( ${+commands[gpg-agent]} )) || return 127
if (( ${+commands[systemctl]} )) ; then
local u s
for u in gpg-agent.{service,socket} ; do
s=$(z-systemctl --user is-enabled $u)
case "$s" in
disabled ) ;;
* ) continue ;;
esac
z-systemctl --user --now enable $u
done
fi
(( ${+commands[gpgconf]} )) || return 127
local agent_sock
agent_sock=$(command gpgconf --list-dirs agent-socket) || return $?
[ -n "${agent_sock}" ] || return 3
export GPG_AGENT_INFO="${agent_sock}:0:1"
## don't bother with ssh agent socket if it already set
[ -z "${SSH_AUTH_SOCK}" ] || return 0
local want_ssh_agent ssh_auth_sock
want_ssh_agent=$(z-gpgconf-getopt gpg-agent enable-ssh-support)
if [ "${want_ssh_agent}" = 1 ] ; then
ssh_auth_sock=$(command gpgconf --list-dirs agent-ssh-socket) || return $?
[ -n "${ssh_auth_sock}" ] || return 5
export SSH_AUTH_SOCK="${ssh_auth_sock}"
fi
}

138
.config/zsh/rc/keyboard.zsh Normal file
View 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
View 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
View 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

View File

@@ -0,0 +1,66 @@
#!/bin/zsh
z-ssh-agent() {
while : ; do
[ -n "${SSH_AGENT_PID}" ] || break
z-proc-exists "${SSH_AGENT_PID}" || break
[ -n "${SSH_AUTH_SOCK}" ] || break
[ -S "${SSH_AUTH_SOCK}" ] || break
## don't bother with ssh agent socket if it already set
return 0
break
done
[ -z "${SSH_AGENT_PID}" ] || kill "${SSH_AGENT_PID}"
unset SSH_AGENT_PID
(( ${+commands[ssh-agent]} )) || return 127
if [ -z "${SSH_AUTH_SOCK}" ] ; then
local sock_dir
if [ "${XDG_RUNTIME_DIR}" = "${TMPDIR}" ] ; then
sock_dir="${ZSHU[d_zdot]}/.cache/ssh"
else
sock_dir="${XDG_RUNTIME_DIR}/ssh"
fi
mkdir -p "${sock_dir}"
SSH_AUTH_SOCK="${sock_dir}/ssh-agent.sock"
fi
local pid_file
pid_file="${SSH_AUTH_SOCK:h}/ssh-agent.pid"
while : ; do
[ -s "${pid_file}" ] || break
SSH_AGENT_PID=$(cat "${pid_file}")
z-proc-exists "${SSH_AGENT_PID}" || break
[ -S "${SSH_AUTH_SOCK}" ] || break
## don't bother with ssh agent socket if it already set
export SSH_AGENT_PID SSH_AUTH_SOCK
return 0
done
unset SSH_AGENT_PID
if [ -S "${SSH_AUTH_SOCK}" ] ; then
rm -fv "${SSH_AUTH_SOCK}"
fi
{
eval "$(ssh-agent -s -a "${SSH_AUTH_SOCK}")"
} >/dev/null
while : ; do
[ -n "${SSH_AGENT_PID}" ] || break
[ -n "${SSH_AUTH_SOCK}" ] || break
[ -S "${SSH_AUTH_SOCK}" ] || break
echo "${SSH_AGENT_PID}" > "${pid_file}"
export SSH_AGENT_PID SSH_AUTH_SOCK
return 0
done
unset SSH_AGENT_PID SSH_AUTH_SOCK
return 1
}

View File

@@ -0,0 +1,24 @@
#!/bin/zsh
z-orig-term() {
local -a a
local i x
for i ( ${ZSHU_PARENTS_PID} ) ; do
i="${ZSHU[procfs]}/$i/environ"
[ -r "$i" ] || continue
x=$(sed -zEn '/^TERM=(.+)$/{s//\1/;p;}' "$i" 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
View File

6
.gdbinit Normal file
View File

@@ -0,0 +1,6 @@
undisplay
display /i $pc
set disassembly-flavor intel
layout asm
layout regs
set debuginfod enabled on

55
.gitconfig Normal file
View File

@@ -0,0 +1,55 @@
[advice]
detachedHead = false
resetNoRefresh = false
skippedCherryPicks = false
statusAheadBehind = false
statusUoption = false
suggestDetachingHead = false
[commit]
gpgSign = false
[core]
abbrev = 10
bigFileThreshold = 16m
compression = 7
deltaBaseCacheLimit = 128m
looseCompression = 2
[credential]
helper = cache --timeout=86400
[fetch]
writeCommitGraph = true
[gc]
aggressiveDepth = 100
aggressiveWindow = 500
auto = 0
bigPackThreshold = 1g
pruneExpire = now
[grep]
threads = 2
[index]
threads = 2
[init]
defaultBranch = main
[log]
showSignature = false
[maintainance]
auto = false
[pack]
compression = 7
deltaCacheLimit = 2048
packSizeLimit = 1g
threads = 4
useSparse = true
writeBitmapLookupTable = true
writeReverseIndex = true
[pull]
ff = only
[push]
default = simple
gpgSign = false
[receive]
autogc = false
keepAlive = 25
[reftable]
blockSize = 65536
[repack]
writeBitmaps = true

21
.sbuildrc.dist Normal file
View File

@@ -0,0 +1,21 @@
$chroot_mode = "schroot";
$build_path = '';
$pgp_options = [ '-us', '-uc', '-ui' ];
$build_arch_all = 1;
$build_arch_any = 1;
$check_space = 0;
$enable_network = 1;
$run_autopkgtest = 0;
$run_lintian = 0;
$run_piuparts = 0;
$apt_distupgrade = 0;
$apt_upgrade = 0;
$purge_build_directory = 'successful';
# don't remove this, Perl needs it:
1;

10
.screenrc Normal file
View 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
View File

@@ -0,0 +1,2 @@
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim.basic"

5
.vimrc Normal file
View File

@@ -0,0 +1,5 @@
syntax on
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set nolist
set tabstop=4
set shiftwidth=4

6
.zshenv Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/zsh
if [[ -o interactive ]] ; then
## early redirect
: "${ZDOTDIR:=${HOME}}"
source "${ZDOTDIR}/.config/zsh/_.zsh"
fi

2
.zshrc Normal file
View File

@@ -0,0 +1,2 @@
#!/bin/zsh
## this file is NOT used at all - job is already done by .zshenv

View File

@@ -1,9 +0,0 @@
Copyright (c) 2021 Konstantin Demin. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,72 +0,0 @@
personal dotfiles
## repo URLs
- https://git.krd.sh/krd/dotfiles (main)
- https://github.com/rockdrilla/dotfiles (mirror)
## contents
- zsh
- gnu screen
- git
- vim (very naive)
- gdb (ditto)
files are stored in separate branch (`main`)
## installation
- install dotfiles (select preferred variant):
- with `curl`:
- default URI:
```sh
curl -sSL https://dotfiles.krd.sh/get | sh -s
```
- explicit fallback to Github:
```sh
curl -sSL https://github.com/rockdrilla/dotfiles/raw/main/.config/dotfiles/install.sh | sh -s
```
- with `wget`:
- default URI:
```sh
wget -q -O - https://dotfiles.krd.sh/get | sh -s
```
- explicit fallback to Github:
```sh
wget -q -O - https://github.com/rockdrilla/dotfiles/raw/main/.config/dotfiles/install.sh | sh -s
```
- with `apt-helper` (very last-resort):
- default URI:
```sh
/usr/lib/apt/apt-helper download-file https://dotfiles.krd.sh/get "${HOME}/dotfiles.install.sh"
sh "${HOME}/dotfiles.install.sh" ; rm -f "${HOME}/dotfiles.install.sh"
```
- explicit fallback to Github:
```sh
/usr/lib/apt/apt-helper download-file https://github.com/rockdrilla/dotfiles/raw/main/.config/dotfiles/install.sh "${HOME}/dotfiles.install.sh"
sh "${HOME}/dotfiles.install.sh" ; rm -f "${HOME}/dotfiles.install.sh"
```
- switch shell to `zsh`:
```sh
chsh -s /bin/zsh
```
## license
BSD 3-Clause
| [spdx.org](https://spdx.org/licenses/BSD-3-Clause.html)
| [opensource.org](https://opensource.org/licenses/BSD-3-Clause)