1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
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
20 changed files with 153 additions and 83 deletions

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

View File

View File

@ -2,15 +2,19 @@
!/.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.example
!/.config/mc/ini.example
!/.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
@ -34,6 +38,7 @@
!/.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
@ -44,14 +49,12 @@
!/.config/zsh/lib/cmdtime.zsh
!/.config/zsh/lib/completion.zsh
!/.config/zsh/lib/curl.zsh
!/.config/zsh/lib/enclave.zsh.wip
!/.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/starship.zsh.sample
!/.config/zsh/lib/term.zsh
!/.config/zsh/lib/time.zsh
!/.config/zsh/lib/title.zsh

View File

@ -56,7 +56,7 @@ main() {
umask 0077
if have_cmd git ; then
if [ -s "${HOME}/${d_repo}/info/refs" ] ; then
if [ -s "${HOME}/${d_repo}/HEAD" ] ; then
dot_update
else
dot_install
@ -66,6 +66,8 @@ main() {
dot_install_raw
fi
propagate_dist_files
echo 'installed.' >&2
}
@ -75,7 +77,7 @@ dot_install() {
mkdir -p "${GIT_DIR}"
git init
git branch -M "${gh_br}" || true
git_config
git_config_init
git_update
}
@ -118,7 +120,7 @@ dot_install_raw() {
cat < "${HOME}/$f" > "${td_backup}/$f"
fi
done < "${tf_list}"
rm -f "${tf_list}"
rm -f "${tf_list}" ; unset tf_list
tar -C "${td_tree}" -cf . - | tar -C "${HOME}" -xf -
rm -rf "${td_tree}"
@ -137,7 +139,7 @@ git_env() {
export GIT_DIR GIT_WORK_TREE
}
git_config() {
git_config_init() {
## remote
git remote add origin "${u_repo}"
git config remote.origin.fetch "+refs/heads/${gh_br}:refs/remotes/origin/${gh_br}"
@ -146,13 +148,23 @@ git_config() {
## 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 gc.auto 0
git config pull.ff only
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
@ -195,7 +207,7 @@ backup_unconditionally() {
mv -f "${HOME}/$f" "${td_backup}/$f"
fi
done < "${tf_list}"
rm -f "${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}/"
@ -205,4 +217,20 @@ backup_unconditionally() {
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

@ -1,6 +1,6 @@
# 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.2.1
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
@ -28,20 +28,18 @@ show_cpu_frequency=1
show_cpu_temperature=1
degree_fahrenheit=0
update_process_names=0
account_guest_in_cpu_meter=0
account_guest_in_cpu_meter=1
color_scheme=0
enable_mouse=1
delay=11
hide_function_bar=0
header_layout=four_25_25_25_25
column_meters_0=Hostname System DateTime Blank LeftCPUs2
column_meter_modes_0=2 2 2 2 1
column_meters_1=Uptime Tasks LoadAverage Blank RightCPUs2
column_meter_modes_1=2 2 2 2 1
column_meters_2=Memory Swap PressureStallMemorySome PressureStallMemoryFull
column_meter_modes_2=1 1 2 2
column_meters_3=DiskIO NetworkIO PressureStallIOSome PressureStallIOFull Blank Battery
column_meter_modes_3=2 2 2 2 2 2
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
@ -52,16 +50,16 @@ 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=1
.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=1
.tree_view_always_by_pid=1
.tree_view=1
.sort_direction=-1
.tree_sort_direction=1
.all_branches_collapsed=0

View File

@ -1,28 +1,24 @@
#!/bin/zsh
: "${ZDOTDIR:=${HOME}}"
typeset -gA ZSHU
ZSHU[t_begin]=${(%):-%D{%s.%6.}}
ZSHU[d_zdot]="${ZDOTDIR}"
ZSHU[d_cache]="${ZDOTDIR}/.cache/zsh"
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]="${ZDOTDIR}/.config/dotfiles/bin"
ZSHU[d_scripts]="${ZDOTDIR}/.config/dotfiles/scripts"
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
## (probably) these files are safe to remove
ZDOTDIR="${ZSHU[d_cache]}"
rm -f "${ZDOTDIR}/.zshrc" "${ZDOTDIR}/.zlogin"
export ZDOTDIR="${ZSHU[d_cache]}/dots"
## cleanup: start from scratch
for i ( a s f d ) ; do unhash -$i -m '*' ; done ; unset i
@ -33,23 +29,24 @@ umask 0022
zshu_parts=( env opt lib rc alias local )
for n ( ${zshu_parts} ) ; do
f="${ZSHU[d_conf]}/$n.zsh"
[ -s "$f" ] && source "$f"
done ; unset n f
[ -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"
[ -d "$d" ] || continue
for i ( "$d"/*.zsh(N.r) ) ; do
[ -d "${ZSHU[d_conf]}/$n" ] || continue
for i ( "${ZSHU[d_conf]}/$n"/*.zsh(N.r) ) ; do
source "$i"
done
done ; unset i n d
done ; unset i n
unset zshu_parts
ZSHU[t_end]=${(%):-%D{%s.%6.}}
hash -f
ZSHU[t_load]=$[ ZSHU[t_end] - ZSHU[t_begin] ]
ZSHU[t_load]=${ZSHU[t_load]:0:6}
unset 'ZSHU[t_begin]' 'ZSHU[t_end]'
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

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

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=$(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

View File

@ -29,12 +29,12 @@ z-git-test() {
}
__z_git_pwd() {
local x
unset 'ZSHU_PS[git_ref]' 'ZSHU_PS[git_changes]' 'ZSHU_PS[git_tag]' 'ZSHU_GIT[path_root]' 'ZSHU_GIT[path_mid]' 'ZSHU_GIT[path_last]' 'ZSHU_GIT[commit]' 'ZSHU_GIT[detached]' 'ZSHU_GIT[ref]' 'ZSHU_GIT[remote]' 'ZSHU_GIT[tag]' 'ZSHU_GIT[ref_behind]' 'ZSHU_GIT[ref_ahead]' 'ZSHU_GIT[ref_changes]'
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

View File

@ -4,25 +4,20 @@ typeset -Uga ZSHU_PARENTS_PID
typeset -ga ZSHU_PARENTS_NAME
function {
local i c
local i c g
i=$$ ; while : ; do
i=$(ps -o ppid= -p $i 2>/dev/null) || :
i=${i//[^0-9]}
[[ "$i" =~ '^[1-9][0-9]*$' ]] || break
i=${PPID}
while : ; do
[ -n "$i" ] || break
## don't deal with PID1
[ "$i" = 1 ] && continue
[ "$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
for i ( ${ZSHU_PARENTS_PID} ) ; do
c=$(ps -o comm= -p $i 2>/dev/null) || :
[ -n "$c" ] || continue
ZSHU_PARENTS_NAME+=( "${c:t}" )
done
typeset -r ZSHU_PARENTS_PID
typeset -r ZSHU_PARENTS_NAME
typeset -r ZSHU_PARENTS_PID ZSHU_PARENTS_NAME
}
typeset -gA ZSHU_RUN

View File

@ -1,15 +1,17 @@
#!/bin/zsh
say_my_name() {
set -a
GIT_COMMITTER_NAME="$1"
GIT_AUTHOR_NAME="$1"
DEBFULLNAME="$1"
export GIT_COMMITTER_NAME GIT_AUTHOR_NAME DEBFULLNAME
set +a
}
say_my_email() {
set -a
GIT_COMMITTER_EMAIL="$1"
GIT_AUTHOR_EMAIL="$1"
DEBEMAIL="$1"
export GIT_COMMITTER_EMAIL GIT_AUTHOR_EMAIL DEBEMAIL
set +a
}

View File

@ -1,16 +1,31 @@
#!/bin/zsh
dotfiles-update() {
"${ZSHU[d_zdot]}/.config/dotfiles/install.sh"
"${ZSHU[d_dotfiles]}/install.sh" "$@"
}
dotfiles-git() { (
cd "${ZSHU[d_zdot]}/"
export GIT_DIR="${ZSHU[d_zdot]}/.config/dotfiles/repo.git"
export GIT_WORK_TREE="${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

View File

@ -23,13 +23,13 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u ${USER} -o pid,user,comm -
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
autoload -Uz +X compinit && \
compinit -i -C -d "${ZSHU[f_compdump]}"
for i ( "${ZSHU[d_conf]}"/completion/*.zsh(N.r) ) ; do
source "$i"
done ; unset i

View File

@ -5,6 +5,5 @@ if [ -n "${PAGER}" ] ; then
export PAGER
READNULLCMD=$(which "${PAGER}" | xargs -r readlink -e)
else
unset READNULLCMD
unset NULLCMD
unset PAGER READNULLCMD NULLCMD
fi

View File

@ -78,7 +78,7 @@ function {
ZSHU_PS1[1L]="${(j::)line}"
}
z-ps() {
z-ps1() {
[ -n "$1" ] || {
echo "${ZSHU_PS[ps1]}"
return
@ -95,6 +95,6 @@ z-ps() {
return 1
}
z-ps 3
[ "${ZSHU_RUN[nested]}" = 1 ] && z-ps 2
[ "${ZSHU_RUN[nested1L]}" = 1 ] && z-ps 1
z-ps1 3
[ "${ZSHU_RUN[nested]}" = 1 ] && z-ps1 2
[ "${ZSHU_RUN[nested1L]}" = 1 ] && z-ps1 1

View File

@ -1,14 +1,23 @@
#!/bin/zsh
function {
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)
x=$(sed -zEn '/^TERM=(.+)$/{s//\1/;p;}' "/proc/$i/environ" 2>/dev/null | tr -d '\0')
[ -n "$x" ] || continue
a+=( "$x" )
done
export ORIG_TERM="${a[-1]}"
case "$1" in
\* | @ )
local ORIG_TERM=( $a )
declare -p ORIG_TERM
;;
* )
i='-1' ; x="${1:-$i}"
echo "${a[$x]}"
;;
esac
}

View File

@ -2,5 +2,6 @@
if [[ -o interactive ]] ; then
## early redirect
: "${ZDOTDIR:=${HOME}}"
[ "${ZDOTDIR}" = "${HOME}/.cache/zsh/dots" ] && ZDOTDIR="${HOME}"
source "${ZDOTDIR}/.config/zsh/_.zsh"
fi