Skip to content

Commit

Permalink
Extract non core shell functions from rc fikes (#204)
Browse files Browse the repository at this point in the history
* Remove unused brew integration code (maybe)

Follow #150

* Extract non core rc functions to another bash

Prepare #199, #201

* Manually trim_trailing_whitespace
  • Loading branch information
kachick authored Jul 29, 2023
1 parent ffb7895 commit 55fcc59
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
9 changes: 8 additions & 1 deletion home/.config/home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -220,4 +228,3 @@
pkgs.ocrmypdf
];
}

38 changes: 0 additions & 38 deletions home/.config/zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions home/.local/share/homemade/bin/bench_shells.bash
Original file line number Diff line number Diff line change
@@ -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'
21 changes: 21 additions & 0 deletions home/.local/share/homemade/bin/updeps.bash
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 55fcc59

Please sign in to comment.