Autocompleting Student Usernames in zsh
November 22, 2013 by Chris Johnson. Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
code, public.
I use a lot of scripts to help me grade students’ work, enter their scores in the gradebook, and send them email reports. For example, I might grade the entire class’s work with:
./autograde "Homework 2" /path/to/submissions
Or maybe I just want to grade Quintin Buster’s submission. I just supply his username as a parameter:
./autograde "Homework 2" /path/to/submissions BUSTERQ
I’ve had an itch for a very long time to enable autocompletion of my students’ usernames, which I can almost never remember when I’m grading. I’ve now scratched that itch with zsh using compctl:
_ids() {
reply=(BUSTERQ USERNAME2 USERNAME3 USERNAME4)
}
compctl -f -K _ids autograde
This compctl command adds completion for the autograde script. The -f says to complete file names as parameters to autograde. The -K _ids says to also add the results of calling the _ids functions to the list of things that can be completed.
I threw these commands into a script in my gradebook directory, which I source when I’m ready to grade. Instead of assigning to reply a list of literal usernames, I read the usernames from a file I store for each class I teach.