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

43 lines
1.0 KiB
Plaintext
Executable File

#compdef org
_org(){
local state
local f_dirname=~/.config/org_notes.conf
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"
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$||")
case $state in
(org_files) _arguments "1:files:($all)" ;;
esac
}
_org "$@"