summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-09-08 09:46:55 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-09-08 09:46:55 +0200
commitef3143c38ef615481b50da7e71924b54f5fade30 (patch)
tree25ff79522dfd55df831b032cb9cfd5d4ec9b40ac
parent5bb1e8834b5f953b21e882eb4610642499a441c4 (diff)
downloaddotfiles-ef3143c38ef615481b50da7e71924b54f5fade30.tar.gz
dotfiles-ef3143c38ef615481b50da7e71924b54f5fade30.tar.xz
zshrc: make ch* functions more useful
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--.zshrc35
1 files changed, 26 insertions, 9 deletions
diff --git a/.zshrc b/.zshrc
index 6b4d6f6..0c2bfb7 100644
--- a/.zshrc
+++ b/.zshrc
@@ -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