From e90c03a51b7eae12cc54949ea3f818ab23701e6c Mon Sep 17 00:00:00 2001 From: A Farzat Date: Thu, 17 Nov 2022 18:13:19 +0900 Subject: Initial commit as generated by `zi create` --- example-script | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 example-script (limited to 'example-script') diff --git a/example-script b/example-script new file mode 100755 index 0000000..3f8ea0a --- /dev/null +++ b/example-script @@ -0,0 +1,70 @@ +#!/usr/bin/env zsh +# -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# +# Copyright (c) 2022 A Farzat +# +# An example of type-agnostic script/function, i.e.: the file can be run as a +x +# script or as an autoload function. Set the base and typically useful options +builtin emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace} +builtin setopt extended_glob warn_create_global typeset_silent no_short_loops rc_quotes no_auto_pushd + +if [[ $0 != example-script || -n $ZSH_SCRIPT ]]; then +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟘 - https://wiki.zshell.dev/community/zsh_plugin_standard +# Standardized $0 Handling - [ zero-handling ] +0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}" +0="${${(M)0:#/*}:-$PWD/$0}" +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟙 - # https://wiki.zshell.dev/community/zsh_plugin_standard#funtions-directory +# The below snippet added to the plugin.zsh file will add the directory +# to the $fpath with the compatibility with any new plugin managers preserved. +if [[ $PMSPEC != *f* ]] { + fpath+=( "${0:h}/functions" ) +} +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟚 - # https://wiki.zshell.dev/community/zsh_plugin_standard#unload-function +# If a plugin is named kalc* and is available via any-user/kalc_plugin_ID, +# then it can provide a function, kalc_plugin_unload, that can be called by a +# plugin manager to undo the effects of loading that plugin. +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟛 - https://wiki.zshell.dev/community/zsh_plugin_standard#run-on-unload-call +# RUN ON UNLOAD CALL +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟜 - https://wiki.zshell.dev/community/zsh_plugin_standard#run-on-update-call +# RUN ON UPDATE CALL +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟝 - https://wiki.zshell.dev/community/zsh_plugin_standard#activity-indicator +# ZI will set the $zsh_loaded_plugins array to contain all previously loaded plugins +# and the plugin currently being loaded, as the last element. +if [[ ${zsh_loaded_plugins[-1]} != */kalc && -z ${fpath[(r)${0:h}]} ]] { + fpath+=( "${0:h}" ) +} +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟞 - https://wiki.zshell.dev/community/zsh_plugin_standard#global-parameter-with-prefix +# Global Parameter With PREFIX For Make, Configure, Etc +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟟 - https://wiki.zshell.dev/community/zsh_plugin_standard#global-parameter-with-capabilities +# PMSPEC +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# 𝟠 - https://wiki.zshell.dev/community/zsh_plugin_standard#zsh-plugin-programming-best-practices +# Zsh Plugin-Programming Best practices +# #̶ =̶=̶=̶ =̶=̶=̶ =̶=̶=̶ #̶ +# Such global variable is expected to be typeset'd -g in the plugin.zsh +# file. Here it's restored in case of the function being run as a script. +typeset -gA Plugins +Plugins[MY_ZSH_COMPLETIONS_DIR]=${0:h} +# In case of the script using other scripts from the plugin, either set up +# $fpath and autoload, or add the directory to $PATH. +fpath+=( $Plugins[MY_ZSH_COMPLETIONS_DIR] ) +autoload … +# OR +path+=( $Plugins[MY_ZSH_COMPLETIONS_DIR] ) +fi +# The script/function contents possibly using $Plugins[MY_ZSH_COMPLETIONS_DIR] … +# … +# Use alternate marks [[[ and ]]] as the original ones can confuse nested +# substitutions, e.g.: ${${${VAR}}} +# +# Made with love by Z-Shell Community +# +# vim:ft=zsh:tw=120:sw=2:sts=2:et:foldmarker=[[[,]]] -- cgit v1.2.3-70-g09d2