oh-my-zsh/plugins/org-mode-manager/_org

43 lines
1.0 KiB
Plaintext
Raw Normal View History

2017-08-27 01:57:08 +00:00
#compdef org
_org(){
local state
local f_dirname=~/.config/org_notes.conf
2017-08-27 01:57:08 +00:00
touch $f_dirname
local f_dir=$(grep "^location" $f_dirname | sed -r 's|^location\s*=\s*(.*)\s*|\1|' )
if [ "$f_dir" = "" ] || ! [ -d $f_dir ]; then
echo -e "-> No valid location set in $f_dirname"
2017-08-27 01:57:08 +00:00
return -1
fi
local f_dir=$(readlink -f $f_dir)
_arguments \
'1: :->org_files'\
'*: :->args'
### Attempt to make org print out everything at a subdirectory by tabbing a suggestion, one subdir (depth 1) at a time
#local dirs_at_loc=$(find ${f_dir} -maxdepth 1 -type d);
#local files_at_loc=$(find ${f_dir} -type f -name '*.org' | sed "s|^${f_dir}/||" | sed "s|.org$||")
#case $state in
# (org_files)
# _arguments "1:files:($files_at_loc $dirs_at_loc)";
# org --subdir=${org_files}
# return 0
# ;;
#esac
local all=$(find ${f_dir} -type f -name '*.org' | sed "s|^${f_dir}/||" | sed "s|.org$||")
2017-08-27 01:57:08 +00:00
case $state in
(org_files) _arguments "1:files:($all)" ;;
esac
2017-08-27 01:57:08 +00:00
}
_org "$@"