diff --git a/debian/undertime.install b/debian/undertime.install new file mode 100644 index 0000000000000000000000000000000000000000..72f2047773f0c44bf0457e8adea72e2509c2439b --- /dev/null +++ b/debian/undertime.install @@ -0,0 +1,2 @@ +extra/_undertime /usr/share/zsh/vendor-completions +extra/undertime /usr/share/bash-completion/completions \ No newline at end of file diff --git a/extra/_undertime b/extra/_undertime new file mode 100644 index 0000000000000000000000000000000000000000..981db6af8dd6f90b711f9668cfde284be454d7af --- /dev/null +++ b/extra/_undertime @@ -0,0 +1,35 @@ +#compdef undertime + +_timezones() { + python3 -c "import pytz; print(' '.join(pytz.all_timezones))" +} + +_undertime() { + _arguments \ + {-t,--timezones}"[time zones to show]:*:timezones:( $(_timezones) )" \ + '--config+[yaml config file]:filename:_files -g "*.(yaml|yml)"' \ + {-s,--start}+'[start of the working day]:hour:' \ + {-e,--end}'[end of the working day]:hour:' \ + "--no-colors[don\'t don't show colors]" \ + '--colors[show colors]' \ + '--default-zone[show current time zone first]' \ + "--no-default-zone[don't show current time zone first]" \ + '--unique[deduplicate time zone offsets]' \ + "--no-unique[don't show current time zone first]" \ + '--overlap[show zones overlap]' \ + "--no-overlap[don't show zones overlap]" \ + '--overlap-min[minimum overlap between zones]:number:' \ + '--truncate[short column headers]' \ + "--no-truncate[don't shorten column headers]" \ + '--table[show the table]' \ + "--no-table[hide the table]" \ + '--debug[enable debugging messages]' \ + {-f,--format}+'[format string for the tabulate package to format the main table]:string:(fancy_grid github grid html jira latex latex_booktabs latex_raw mediawiki moinmoin orgtbl pipe plain presto pretty psql rst simple textile tsv youtrack fancy_grid_nogap)' \ + {-v,--verbose}'[enable verbose messages]' \ + {-l,--list-zones}'[show valid time zones and exit]' \ + {-V,--version}'[print version number and exit]' \ + {-h,--help}'[show summary of options and defaults]' \ + '--selftest[run test suite]' +} + +_undertime "$@" diff --git a/extra/undertime b/extra/undertime new file mode 100644 index 0000000000000000000000000000000000000000..4ffaa830f9e67f5944c292b98538dd602295094f --- /dev/null +++ b/extra/undertime @@ -0,0 +1,63 @@ +# bash completion for undertime -*- shell-script -*- + +_timezones () { + python3 -c "import pytz; print(' '.join(pytz.all_timezones))" +} + +_undertime () { + local cur prev words + cur=$2 + prev=$3 + COMPREPLY=() + + words=( ${COMP_LINE[@]} ) + # If the last option argument is -t or --timezones and the point is at + # a position after -t or --timezones then complete timezone names + # otherwise complete regular options + for ((i=${#words[@]} - 1; i > 0; i--)); do + if [[ ${words[i]} == -* ]]; then + if [[ ${words[i]} == @(-t|--timezones) ]]; then + rest=${COMP_LINE#*${words[i]}} + if (( $COMP_POINT > ${#rest} )); then + COMPREPLY=( $(compgen -W "$(_timezones)" -- $cur) ) + return 0 + fi + fi + # give up if we have an option other than -t or --timezones + break + fi + done + + case "$prev" in + --config) + _filedir @(yml|yaml) + return 0 + ;; + --format|-f) + COMPREPLY=( $(compgen -W 'fancy_grid github grid html jira \ + latex latex_booktabs latex_raw mediawiki \ + moinmoin orgtbl pipe plain presto pretty \ + psql rst simple textile tsv youtrack \ + fancy_grid_nogap' -- $cur ) ) + return 0 + ;; + --start|-s) + ;& + --end|-e) + ;& + --overlap-min) + return 0 + ;; + esac + COMPREPLY=( $( compgen -W '-t --timezones --config \ + -s --start -e --end --no-colors --colors --default-zone \ + --no-default-zone --unique --no-unique --overlap --no-overlap \ + --overlap-min --truncate --no-truncate \ + --table --no-table --debug -f --format -v --verbose -l --list-zones \ + -V --version -h --help --selftest' -- $cur) ) + + return 0 +} && + complete -F _undertime undertime + +# ex filetype=sh