Commits

Ross Light committed 26cd290

Improve zsh support

* Update autocompletion for verify, web, and search commands
* Fix error handling in Gcd
* Allow project path to be a file for Gcd and use parent directory

  • Participants
  • Parent commits 376c3ce

Comments (0)

Files changed (2)

misc/completion.zsh

         'import[import project(s) from JSON]'
         'checkout[check out project from version control]'
         'co[check out project from version control]'
+        'search[full text search for projects]'
+        'web[run web server]'
+        'verify[check a catalog for consistency]'
     )
     globalflags+=(
         '-catalog=[path to catalog directory]:file:_path_files -/'
         return
     }
     case ${words[2]} in
-    init|list|ls|search)
+    init|list|ls|verify|search)
         _arguments : ${globalflags[@]}
         ;;
     show|info)
         _arguments : ${globalflags[@]} \
             '-created=[project creation date, formatted as RFC3339]' \
             '-description=[human-readable project description]' \
-            '-path=[path of working copy]:file:_path_files -/' \
+            '-path=[path of working copy]:file:_files' \
             '-shortname=[identifier for project]' \
             '-tags=[comma-separated tags to assign to the new project]' \
             '-url=[project homepage]' \
             '-deltags=[delete tags from the project, separated by commas]' \
             '-description=[human-readable project description]' \
             '-name=[human-readable name of project]' \
-            '-path=[path of working copy]:file:_path_files -/' \
+            '-path=[path of working copy]:file:_files' \
             "-tags=[set the project's tags, separated by commas]" \
             '-url=[project homepage]' \
             '-vcs=[type of VCS for project]:vcs:__glados_vcs' \
             ':project:__glados_list' \
             ':file:_path_files -/'
         ;;
+    web)
+        _arguments : ${globalflags[@]} \
+            '-listen=[address to listen for HTTP]' \
+            '-refresh=[interval between catalog cache refreshes]' \
+            '-staticdir=[static directory]:file:_path_files -/' \
+            '-templatedir=[template directory]:file:_path_files -/'
+        ;;
     esac
 }
 

misc/ross-aliases.zsh

 alias G=glados
 
 Gcd() {
-    local projpath="$(glados path "$1")"
+    local projpath
+    projpath="$(glados path "$1")"
     if [ $? -ne 0 ]; then
+        echo "Gcd: no path" 1>&2
         return 1
     fi
-    cd "$projpath"
+    if [[ -d "$projpath" ]]; then
+        cd "$projpath"
+        return $?
+    elif [[ -e "$projpath" ]]; then
+        cd "${projpath:h}"
+        return $?
+    else
+        echo "Gcd: \"$projpath\" does not exist" 1>&2
+        return 1
+    fi
 }
 compdef '_values "glados projects" $(glados list 2>/dev/null)' Gcd
 
     glados show "$@" | sed -n 's/^'"$word"':\s*//p'
 }
 
-alias GPUSH='hg push -R "$GLADOS_PATH"'
-alias GPULL='hg pull -R "$GLADOS_PATH" -u'
+GPUSH() {
+    hg push -R "$GLADOS_PATH" "$@"
+}
+
+GPULL() {
+    hg pull -R "$GLADOS_PATH" -u "$@"
+}