From 90e3f171da2233704245ccba1c9cfd498139593a Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Sun, 25 Oct 2026 09:02:42 +0100 Subject: [PATCH] add dot-completions and prepare upgrayyedd to live in /usr/local/bin --- dot-completions/bash/upgrayyedd.bash | 60 +++++++++++++++++ dot-completions/fish/upgrayyedd.fish | 66 +++++++++++++++++++ ...{upgrayyeddv2 => usr_local_bin_upgrayyedd} | 19 +++--- 3 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 dot-completions/bash/upgrayyedd.bash create mode 100644 dot-completions/fish/upgrayyedd.fish rename dot-local/bin/{upgrayyeddv2 => usr_local_bin_upgrayyedd} (94%) diff --git a/dot-completions/bash/upgrayyedd.bash b/dot-completions/bash/upgrayyedd.bash new file mode 100644 index 0000000..f6837f2 --- /dev/null +++ b/dot-completions/bash/upgrayyedd.bash @@ -0,0 +1,60 @@ +# Bash completion for upgrayyedd +# Install e.g. as /etc/bash_completion.d/upgrayyedd + +_upgrayyedd() +{ + local cur prev cmd + COMPREPLY=() + + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + cmd=${COMP_WORDS[1]} + + local commands='\ +check \ +sync ref refresh \ +daily all \ +world dup \ +wbdeps wbd \ +pkg in \ +skipkernel \ +preserved \ +wholeworld \ +search se \ +clean rm \ +checkclean \ +live \ +flatpaks \ +kernel-live kernel-gentoo kernel-llvm kernel-git kernel-server \ +clean-kernels \ +log unlog \ +testify' + + # First argument: upgrayyedd subcommand. + if (( COMP_CWORD == 1 )); then + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + return 0 + fi + + # Commands which forward additional arguments to emerge. Do not restrict + # them here; let normal shell/file completion remain available. + case "$cmd" in + daily|all|world|dup|wbdeps|wbd|pkg|in|skipkernel|search|se|clean|rm|checkclean) + if [[ $cur == -* ]]; then + local emerge_opts='\ +--ask --verbose --update --deep --newuse --changed-use \ +--getbinpkg --usepkg --usepkgonly --keep-going \ +--with-bdeps --binpkg-changed-deps --exclude --oneshot \ +--pretend --tree --emptytree --nodeps --depclean --search' + COMPREPLY=( $(compgen -W "$emerge_opts" -- "$cur") ) + else + COMPREPLY=( $(compgen -f -- "$cur") ) + fi + return 0 + ;; + esac + + return 0 +} + +complete -F _upgrayyedd upgrayyedd diff --git a/dot-completions/fish/upgrayyedd.fish b/dot-completions/fish/upgrayyedd.fish new file mode 100644 index 0000000..dd74544 --- /dev/null +++ b/dot-completions/fish/upgrayyedd.fish @@ -0,0 +1,66 @@ +# Fish completion for upgrayyedd +# Install as ~/.config/fish/completions/upgrayyedd.fish + +# Do not fall back to file completion for the command selector itself. +complete -c upgrayyedd -f + +function __upgrayyedd_no_command + test (count (commandline -opc)) -eq 1 +end + +# Commands / aliases +complete -c upgrayyedd -n __upgrayyedd_no_command -a check -d 'Check for world updates' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'sync ref refresh' -d 'Force synchronization of all repositories' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'daily all' -d 'Sync enabled repositories and update world' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'world dup' -d 'Update world without repository sync' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'wbdeps wbd' -d 'Update world including build dependencies' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'pkg in' -d 'Install packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a skipkernel -d 'Update world except kernel packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a preserved -d 'Rebuild preserved libraries' +complete -c upgrayyedd -n __upgrayyedd_no_command -a wholeworld -d 'Rebuild world from scratch using all CPUs' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'search se' -d 'Search packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a 'clean rm' -d 'Depclean orphaned packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a checkclean -d 'Show packages eligible for depclean' +complete -c upgrayyedd -n __upgrayyedd_no_command -a live -d 'Update live packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a flatpaks -d 'Update Flatpaks' +complete -c upgrayyedd -n __upgrayyedd_no_command -a kernel-live -d 'Build current kernel tree/config' +complete -c upgrayyedd -n __upgrayyedd_no_command -a kernel-gentoo -d 'Build gentoo kernel flavor' +complete -c upgrayyedd -n __upgrayyedd_no_command -a kernel-llvm -d 'Build llvm kernel flavor' +complete -c upgrayyedd -n __upgrayyedd_no_command -a kernel-git -d 'Build git kernel flavor' +complete -c upgrayyedd -n __upgrayyedd_no_command -a kernel-server -d 'Build server kernel flavor' +complete -c upgrayyedd -n __upgrayyedd_no_command -a clean-kernels -d 'Remove old kernels' +complete -c upgrayyedd -n __upgrayyedd_no_command -a log -d 'Show recently emerged packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a unlog -d 'Show recently unmerged packages' +complete -c upgrayyedd -n __upgrayyedd_no_command -a testify -d 'Show build cgroup placement' + +# Common emerge options for commands forwarding arguments to emerge. +function __upgrayyedd_emerge_command + set -l words (commandline -opc) + test (count $words) -ge 2; or return 1 + + switch $words[2] + case daily all world dup wbdeps wbd pkg in skipkernel search se clean rm checkclean + return 0 + end + + return 1 +end + +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l ask -d 'Ask before performing actions' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l verbose -d 'Verbose output' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l update -d 'Update packages' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l deep -d 'Consider dependencies deeply' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l newuse -d 'Rebuild for USE flag changes' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l changed-use -d 'Rebuild for changed USE flags' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l getbinpkg -d 'Fetch binary packages' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l usepkg -d 'Use binary packages when available' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l usepkgonly -d 'Use only binary packages' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l keep-going -d 'Continue after build failures' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l with-bdeps -d 'Include build dependencies' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l binpkg-changed-deps -d 'Respect changed binary package dependencies' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l exclude -r -d 'Exclude package atom' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l oneshot -d 'Do not add package to world set' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l pretend -d 'Show what would be done' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l tree -d 'Display dependency tree' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l emptytree -d 'Rebuild dependency tree from scratch' +complete -c upgrayyedd -n __upgrayyedd_emerge_command -l nodeps -d 'Ignore dependencies' diff --git a/dot-local/bin/upgrayyeddv2 b/dot-local/bin/usr_local_bin_upgrayyedd similarity index 94% rename from dot-local/bin/upgrayyeddv2 rename to dot-local/bin/usr_local_bin_upgrayyedd index b756955..a3fea9e 100755 --- a/dot-local/bin/upgrayyeddv2 +++ b/dot-local/bin/usr_local_bin_upgrayyedd @@ -55,7 +55,7 @@ sync_all_repos() { emaint sync -A } -sync_repos_auto() { +sync_repos() { emaint sync -a } @@ -64,7 +64,7 @@ update_world() { } daily_update() { - sync_repos_auto && update_world "$@" + sync_repos && update_world "$@" } update_world_with_bdeps() { @@ -154,7 +154,7 @@ kernel_build() { build_kernel_in_cgroup || die "Kernel build failed" - emerge_build -avuDNg @module-rebuild || + emerge_build @module-rebuild || die "Module rebuild failed" echo @@ -289,13 +289,16 @@ case "${1:-}" in ;; log) - grep -i --color=auto "completed" /var/log/emerge.log - echo "note: use 'date -d @[unixtime]' to convert the timestamp" + grep -i "completed" /var/log/emerge.log | + while IFS=' ' read -r ts rest; do + printf '%s %s\n' "$(date -d "@${ts%:}" '+%Y-%m-%d %H:%M:%S')" "$rest" + done ;; - unlog) - grep -i --color=auto "unmerging" /var/log/emerge.log - echo "note: use 'date -d @[unixtime]' to convert the timestamp" + grep -i "unmerging" /var/log/emerge.log | + while IFS=' ' read -r ts rest; do + printf '%s %s\n' "$(date -d "@${ts%:}" '+%Y-%m-%d %H:%M:%S')" "$rest" + done ;; testify) -- 2.56.0