diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-09-08 09:46:55 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-09-08 09:46:55 +0200 |
commit | ef3143c38ef615481b50da7e71924b54f5fade30 (patch) | |
tree | 25ff79522dfd55df831b032cb9cfd5d4ec9b40ac | |
parent | 5bb1e8834b5f953b21e882eb4610642499a441c4 (diff) | |
download | dotfiles-ef3143c38ef615481b50da7e71924b54f5fade30.tar.gz dotfiles-ef3143c38ef615481b50da7e71924b54f5fade30.tar.xz |
zshrc: make ch* functions more useful
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r-- | .zshrc | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -406,42 +406,59 @@ short_ii() { echo } +__CHROOTS="$HOME/misc/chroots" + __genchroot() { sudo mkdir -p "$copydir" sudo rsync -a --delete -q -W "$chrootdir/root/" "$copydir" } chshell() { - chrootdir="$HOME/misc/chroots/arch$1" + chrootdir="$__CHROOTS/arch$1" copydir="$chrootdir/copy/" [ -d "$copydir" ] || __genchroot sudo mkarchroot -r "/bin/bash" "$copydir" } chbuild() { - chrootdir="$HOME/misc/chroots/arch$1" + chrootdir="$__CHROOTS/arch$1" linux${1[1,2]} sudo makechrootpkg -r "$chrootdir" -- -f } chinstall() { - chrootdir="$HOME/misc/chroots/arch$1" + chrootdir="$__CHROOTS/arch$1" linux${1[1,2]} sudo makechrootpkg -r "$chrootdir" -I "$2" } chclean() { - chrootdir="$HOME/misc/chroots/arch$1" - sudo rm -r "$chrootdir/copy" + if [[ $# = 0 ]]; then + for chrootdir in "$__CHROOTS/"*(/); do + chclean "$(basename "$chrootdir")" + done + else + chrootdir="$__CHROOTS/$1" + [[ -d "$chrootdir/copy" ]] && sudo rm -r "$chrootdir/copy" + fi + return 0 } chrshell() { - chrootdir="$HOME/misc/chroots/arch$1" + chrootdir="$__CHROOTS/arch$1" linux${1[1,2]} sudo mkarchroot -r bash "$chrootdir/root" } chupdate() { - chrootdir="$HOME/misc/chroots/arch$1" - linux${1[1,2]} sudo mkarchroot -u "$chrootdir/root" - chclean "$1" + if [[ $# = 0 ]]; then + for chrootdir in "$__CHROOTS/"*(/); do + chupdate "$(basename "$chrootdir")" + done + echo ":: Cleaning up ..." + chclean + else + chrootdir="$__CHROOTS/$1" + echo ":: Updating $1" + linux${1[1,2]} sudo mkarchroot -u "$chrootdir/root" -- --noconfirm + fi } # source: http://github.com/trapd00r/configs/blob/master/.zsh/functions.zsh |