dotwryn/zsh/school

31 lines
466 B
Plaintext
Raw Normal View History

2019-12-02 17:16:05 +00:00
#!/bin/zsh
2020-03-09 20:23:38 +00:00
#
# school() = School Navigation Utility
#
2019-12-02 17:16:05 +00:00
2020-03-09 20:23:38 +00:00
function school() {
cd "$SCHOOL_DIR";
2019-12-02 17:16:05 +00:00
2020-03-09 20:23:38 +00:00
[ -d "$1" ] && cd "$1";
[ -d "$2" ] && cd "$2";
2019-12-02 17:16:05 +00:00
2020-03-09 20:23:38 +00:00
return 0;
}
_school () { # autocompletion
local state
2019-12-02 17:16:05 +00:00
2020-03-09 20:23:38 +00:00
_arguments \
'1: :->class_title'\
':: :->class_child'\
;
case "$state" in
class_title)
compadd $(ls "$SCHOOL_DIR" | grep -v GITIGNORE);
;;
class_child)
compadd $(ls -F "$SCHOOL_DIR/$words[2]" | grep \/);
;;
esac
2019-12-02 17:16:05 +00:00
}
2020-03-09 20:23:38 +00:00
compdef _school school;