diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c2a97b06..5b00f8987 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1337,6 +1337,12 @@ install( RENAME "${CMAKE_PROJECT_NAME}" ) +install( + FILES "${CMAKE_SOURCE_DIR}/completions/${CMAKE_PROJECT_NAME}.zsh" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions" + RENAME "_${CMAKE_PROJECT_NAME}" +) + install( FILES "${CMAKE_SOURCE_DIR}/completions/${CMAKE_PROJECT_NAME}.fish" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d" diff --git a/completions/fastfetch.zsh b/completions/fastfetch.zsh new file mode 100644 index 000000000..924e4a338 --- /dev/null +++ b/completions/fastfetch.zsh @@ -0,0 +1,97 @@ +#compdef fastfetch + +function _fastfetch() { + local state + + local -a opts + opts=(${(f)"$( + python <modules") + elif type == "config": + print(f"{command_prefix}:presets:->presets") + elif type == "enum": + temp: str = " ".join(flag["arg"]["enum"]) + print(f'{command_prefix}:type:( {temp} )') + elif type == "logo": + print(f"{command_prefix}:logo:->logo") + elif type == "structure": + print(f"{command_prefix}:structure:->structure") + elif type == "path": + print(f"{command_prefix}:path:_files -/") + else: + print(f"{command_prefix}:") + else: + print(f"{command_prefix}") + + +if __name__ == "__main__": + try: + main() + except Exception: + sys.exit(1) +EOF + )"}) + + _arguments -C "$opts[@]" + + case $state in + modules) + local -a modules=( ${(f)"$(fastfetch --list-modules autocompletion)"} ) + modules=( ${(L)^modules%%:*}-format format color ) + _describe 'module' modules + ;; + presets) + local -a presets=( + ${$(fastfetch --list-presets autocompletion):#.*} + "none:Disable loading config file" + ) + _describe 'preset' presets + ;; + structure) + local -a structures=( ${(f)"$(fastfetch --list-modules autocompletion)"} ) + _describe 'structure' structures + ;; + logo) + local -a logos=( + $(fastfetch --list-logos autocompletion) + "none:Don't print logo" + "small:Print small ascii logo if available" + ) + _describe 'logo' logos + ;; + esac +} + +_fastfetch "$@"