Permalink
Browse files

[package] add.

  • Loading branch information...
1 parent 0a8e6b0 commit 1532235b825916bf49b7ea9dd146df51c0cd3913 @kou kou committed Sep 4, 2011
Showing with 48 additions and 0 deletions.
  1. +48 −0 package.zsh
View
@@ -0,0 +1,48 @@
+# -*- sh -*-
+
+: ${PACKAGE_BASE_DIR:="$HOME/.zsh.d/packages"}
+
+package-directory()
+{
+ local name=$1
+ echo -n "${PACKAGE_BASE_DIR}/${name:t}"
+}
+
+package-run-command()
+{
+ "$@"
+ if test $? -eq 0; then
+ return 0
+ else
+ echo "Failed: $@"
+ return 1
+ fi
+}
+
+package-install-github()
+{
+ local name=$1
+ local package_dir="$2"
+
+ package-run-command git clone https://github.com/${name}.git "${package_dir}"
+}
+
+package-install()
+{
+ local type=$1; shift
+ local spec=$1; shift
+
+ local package_dir="$(package-directory $spec)"
+
+ if [ ! -d "${package_dir}" ]; then
+ mkdir -p "${package_dir}"
+ case "${type}" in
+ github)
+ package-install-github "${spec}" "${package_dir}"
+ ;;
+ *)
+ return
+ ;;
+ esac
+ fi
+}

0 comments on commit 1532235

Please sign in to comment.