From 55fcc59f26457c84d86764e48a8dd65409b4324d Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sun, 30 Jul 2023 05:06:02 +0900 Subject: [PATCH] Extract non core shell functions from rc fikes (#204) * Remove unused brew integration code (maybe) Follow #150 * Extract non core rc functions to another bash Prepare #199, #201 * Manually trim_trailing_whitespace --- home/.config/home-manager/home.nix | 9 ++++- home/.config/zsh/.zshrc | 38 ------------------- .../share/homemade/bin/bench_shells.bash | 12 ++++++ home/.local/share/homemade/bin/updeps.bash | 21 ++++++++++ 4 files changed, 41 insertions(+), 39 deletions(-) create mode 100755 home/.local/share/homemade/bin/bench_shells.bash create mode 100755 home/.local/share/homemade/bin/updeps.bash diff --git a/home/.config/home-manager/home.nix b/home/.config/home-manager/home.nix index f772a605..6f25fe57 100644 --- a/home/.config/home-manager/home.nix +++ b/home/.config/home-manager/home.nix @@ -148,6 +148,14 @@ irb-power_assert ''; + # - Tiny tools by me, they may be rewritten with another language. + # - Keep *.bash in shellscript naming in this repo for maintainability, the extname should be trimmed in the symlinks + xdg.dataFile."homemade/bin/bench_shells".source = ../../../home/.local/share/homemade/bin/bench_shells.bash; + xdg.dataFile."homemade/bin/updeps".source = ../../../home/.local/share/homemade/bin/updeps.bash; + home.sessionPath = [ + "${config.xdg.dataHome}/homemade/bin" + ]; + home.packages = [ pkgs.dprint pkgs.deno @@ -220,4 +228,3 @@ pkgs.ocrmypdf ]; } - diff --git a/home/.config/zsh/.zshrc b/home/.config/zsh/.zshrc index fa19d993..f97ee28e 100644 --- a/home/.config/zsh/.zshrc +++ b/home/.config/zsh/.zshrc @@ -2,10 +2,6 @@ # Executes commands at the start of an interactive session. # -# https://qiita.com/eumesy/items/3bb39fc783c8d4863c5f -# in ~/.zshenv, executed `unsetopt GLOBAL_RCS` and ignored /etc/zshrc -[ -r /etc/zshrc ] && . /etc/zshrc - # Do NOT use (( $+commands[sheldon] )) here. It made 1.5x slower zsh execution :< if type 'sheldon' > /dev/null; then eval "$(sheldon source)" @@ -75,40 +71,6 @@ _compinit_with_interval() { } _compinit_with_interval -update_tools() { - case ${OSTYPE} in - linux*) - sudo apt update --yes && sudo apt upgrade --yes - ;; - darwin*) - softwareupdate --install --recommended - ;; - esac - - nix-channel --update - home-manager switch - - if type 'sheldon' > /dev/null; then - sheldon lock --update - fi - if command -v rtx; then - rtx self-update - rtx plugins update - fi -} - -# Keep under 120ms...! -bench_zsh() { - hyperfine 'zsh -i -c exit' -} - -bench_shells() { - bench_zsh - # Really having same options as zsh...? - hyperfine 'bash -i -c exit' - hyperfine 'nu -i -c exit' -} - case ${OSTYPE} in darwin*) test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" diff --git a/home/.local/share/homemade/bin/bench_shells.bash b/home/.local/share/homemade/bin/bench_shells.bash new file mode 100755 index 00000000..a7b72270 --- /dev/null +++ b/home/.local/share/homemade/bin/bench_shells.bash @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# ~ my feeling ~ +# 50ms : blazing fast! +# 120ms : acceptable +# 200ms : 1980s? +# 300ms : slow! + +hyperfine 'zsh -i -c exit' +# Really having same options as zsh...? +hyperfine 'bash -i -c exit' +hyperfine 'nu -i -c exit' diff --git a/home/.local/share/homemade/bin/updeps.bash b/home/.local/share/homemade/bin/updeps.bash new file mode 100755 index 00000000..2f5aff15 --- /dev/null +++ b/home/.local/share/homemade/bin/updeps.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +case ${OSTYPE} in +linux*) + sudo apt update --yes && sudo apt upgrade --yes + ;; +darwin*) + softwareupdate --install --recommended + ;; +esac + +nix-channel --update +home-manager switch + +if type 'sheldon' >/dev/null; then + sheldon lock --update +fi +if command -v rtx; then + rtx self-update + rtx plugins update +fi