_myzs:internal:call(cmd, ...args) - execute _myzs:internal:[cmd] if exist, silent ignore
This method is for execute internal command but we not sure is it available or not
# e.g. with debug log
_myzs:internal:call log:debug "debug message"
_myzs:internal:call-or(cmd, fallback, ...args) - execute _myzs:internal:[cmd] if exist, or fallback command
This method is for execute internal command but we not sure is it available or not
# e.g. with debug log or echo if log not available
_myzs:internal:call log:debug echo "debug message"
_myzs:internal:db:varname(key, name) - convert key and name to database key
Usually we would use this directly, but I expose this method for client convenience
# e.g. generator variable by combine key and name
_myzs:internal:db:varname "setting" "data-setup"
_myzs:internal:db:setter:string(key, name, data) - save data to database key
We will create variable with given key and name, with data inside
# e.g. setup setting color to blue
_myzs:internal:db:setter:string "setting" "color" "blue"
_myzs:internal:db:setter:number(key, name, data) - same with `_myzs:internal:db:setter:string(key, name, data)`
We will create variable with given key and name, with data inside
# e.g. setup batch size to 15
_myzs:internal:db:setter:string "setting" "batch-size" 15
_myzs:internal:db:setter:array(key, name, ...args) - save args to database key as array type
We will create variable with given key and name, with initial array data to that variable name
# e.g. setup support ids to 5, 6, 7, and 8
_myzs:internal:db:setter:array "setting" "support-ids" 5 6 7 8
_myzs:internal:db:setter:enabled(key, name) - mark database key as true
Internally, we use _myzs:internal:db:setter:string to set value as 'true'
# e.g. enable module experiment
_myzs:internal:db:setter:enabled "module" "experiment"
_myzs:internal:db:setter:disabled(key, name) - mark database key as false
Internally, we use _myzs:internal:db:setter:string to set value as 'false'
# e.g. disabled module experiment
_myzs:internal:db:setter:disabled "module" "experiment"
_myzs:internal:db:append:array(key, name, ...args) - append array args to database key
We will append or create data to given key and name variable
# e.g. add more element in support ids
_myzs:internal:db:append:array "setting" "support-ids" 10, 11, 12
_myzs:internal:db:getter:string(key, name, [fallback]) - query data or fallback data
We query data from given database key or using fallback data if data on database key is not exist
# e.g. get plugin status or return unknown if data is missing
_myzs:internal:db:getter:string "plugin" "status" "unknown"
_myzs:internal:db:getter:array(key, name, varname) - initial queried data to given varname
Since bash cannot return array from method, so we use setting variable technique instead
# e.g. getting user id from database, and echo result
_myzs:internal:db:getter:array "user" "ids" userids
echo "${userids[@]}"
_myzs:internal:db:loader(key, ...args) - create data from data storage format
We define data storage format so we can create data as array and initial all together once.
Data storage format: $ <command_type> <...command_arguments>
.
Possible command_type
is all _myzs:internal:db:getter:<command_type>
method and _myzs:internal:<key>:getter:<command_type>
if db is not exist
# e.g. single data creator
_myzs:internal:db:loader "key" "$" "string" "data/example" "hello"
# e.g. multiple data creator
_myzs:internal:db:loader "key" \
"$" "string" "data/example" "hello" \
"$" "number" "example/count" 5
_myzs:internal:db:checker:string(key, name, ...args) - checking data from database is equals to args
We compare with OR opts, meaning only one args return true
method will return true instantly
# e.g. check is type equals to large OR small
_myzs:internal:db:checker:string "setting" "type" "large" "small"
_myzs:internal:db:checker:enabled(key, name) - check is data equal to enabled value
Checking data must be true. fail to get data will result as non-zero error
# e.g. check are we enable color
if _myzs:internal:db:checker:enabled "setting" "color"; then
echo "we enable color"
fi
_myzs:internal:db:checker:disabled(key, name) - check is data equal to disabled value
Checking data must be false. fail to get data will result as non-zero error
# e.g. check are we disable color
if _myzs:internal:db:checker:disabled "setting" "color"; then
echo "we disable color"
fi
_myzs:internal:db:checker:greater-than(key, name, number) - check is data must greater than number
# e.g. check size more than 100
_myzs:internal:db:checker:greater-than "setting" "name-size" 100
_myzs:internal:db:checker:less-than(key, name, number) - check is data must less than number
# e.g. check time less than 5 (ms)
_myzs:internal:db:checker:less-than "module" "duration" 5
_myzs:internal:db:checker:contains(key, name, ...args) - check is data contains args or not
This using grep as a searching algorithm for checking contains text
# e.g. check plugins contains myzs-plugins/core or not
_myzs:internal:db:checker:contains "plugin" "list" "myzs-plugins/core"
_myzs:internal:checker:shell:bash - check current shell is bash?
Return as non-zero code if current shell is not bash
# e.g. check current shell type
_myzs:internal:checker:shell:bash
_myzs:internal:checker:shell:zsh - check current shell is zsh?
Return as non-zero code if current shell is not zsh
# e.g. check current shell type
_myzs:internal:checker:shell:zsh
_myzs:internal:checker:string-exist(string) - check string is not empty?
Input as command string and return zero if input string is exist
# e.g. check is input == "" (empty string) or not
_myzs:internal:checker:string-exist ""
_myzs:internal:checker:command-exist(string) - check string is executable?
Input as command string, and will check whether command is executable
# e.g. check is grep command exist or not
_myzs:internal:checker:command-exist "grep"
_myzs:internal:checker:file-exist(string) - check filepath is available and correct
Input filepath and will check is input file is exist or not Will return non-zero if file is not exist or it's not file (for example it's directory)
# e.g. check is data.txt in tmp directory is exist or not
_myzs:internal:checker:file-exist "/tmp/data.txt"
_myzs:internal:checker:folder-exist(string) - check dirpath is available and correct
Input dirpath and will check is input directory is exist or not. Will return non-zero if directory is not exist or it's not directory
# e.g. check is caching is exist and it's directory
_myzs:internal:checker:folder-exist "/tmp/caching"
_myzs:internal:checker:file-contains(string, search) - file content must contains search string
read file content from input filepath string, and check if it contains input string or not
# e.g. data.txt is contains 'hello world' or not
_myzs:internal:checker:file-contains "./data.txt" "hello world"
_myzs:internal:checker:small-type - myzs type is small, or not?
reading data from myzs setting, and check type
# e.g. current terminal loading with small type
_myzs:internal:checker:small-type
_myzs:internal:checker:fully-type - myzs type is fully, or not?
reading data from myzs setting, and check type
# e.g. current terminal loading with fully type
_myzs:internal:checker:fully-type
_myzs:internal:checker:mac - check is current os is macos?
return zero code if current os is macos
# e.g. running on macos
_myzs:internal:checker:mac
_myzs:internal:log:debug(...args) - log debug message to log file
formatted debug message and write to log file ($MYZS_LOGPATH)
# e.g. print debug message to log file
_myzs:internal:log:debug "this is debug message"
_myzs:internal:log:info(...args) - log info message to log file
formatted info message and write to log file ($MYZS_LOGPATH)
# e.g. print info message to log file
_myzs:internal:log:info "this is info message"
_myzs:internal:log:warn(...args) - log warn message to log file
formatted warn message and write to log file ($MYZS_LOGPATH)
# e.g. print warn message to log file
_myzs:internal:log:warn "this is warn message"
_myzs:internal:log:error(...args) - log error message to log file
formatted error message and write to log file ($MYZS_LOGPATH)
# e.g. print error message to log file
_myzs:internal:log:error "this is error message"
myzs:module:new($0) - start new module $0 is module filepath
This will initial and notify script to know that new module is created
# e.g. initial new module
myzs:module:new "$0"
_myzs:internal:module:cleanup(key) - cleanup module with optional module key
It will cleanup module from given key if no key provided it will try to find current module from memory
# e.g. cleanup builtin/core
_myzs:internal:module:cleanup "builtin#app/core.sh"
_myzs:internal:project:cleanup - cleanup whole project
This must be called only on the end of .zshrc
file
# e.g. cleanup project
_myzs:internal:project:cleanup
_myzs:internal:shell([zsh], [bash]) - return input base on current shell
It's will check current shell name and return input string base on shell that you on
# e.g. on bash shell, this will return bash
# on zsh shell, this will return zsh
_myzs:internal:shell
# e.g. on bash shell, this will return bbb
# on zsh shell, this will return zzz
_myzs:internal:shell 'zzz' 'bbb'
_myzs:internal:load(name, path) - source input "path"
This will load input path to current shell env and write result to log file. Exit code:
- 0 - successfully
- 4 - file not found
- ANY - error code from input file
# source file from /tmp/test.sh
_myzs:internal:load "test" "/tmp/test.sh"
_myzs:internal:alias(key, value) - safe create alias
Safe create alias only if command is not existed
# alias b to boom
_myzs:internal:alias "b" "boom"
_myzs:internal:alias-force(key, value) - force create alias
Create alias or overwrite if it existed
# alias b to boom
_myzs:internal:alias "b" "boom"
_myzs:internal:fpath-push(...path)
- push all input path to the end of fpath array_myzs:internal:manpath-push(...path)
- push all input path to the end of manpath array_myzs:internal:path-push(...path)
- push all input path to the end of path variable_myzs:internal:path-append(...path)
- append all input path to a first of path variable
_myzs:internal:setting:initial
- build settings data from${MYZS_LOADING_SETTINGS}
array_myzs:internal:setting:is-enabled(name)
- checking is setting name is enabled or not (return non-zero)_myzs:internal:setting:is-disabled(name)
- checking is setting name is disabled or not (return non-zero)_myzs:internal:setting:is(name, ...value)
- check is setting name equals to values or not (return non-zero)_myzs:internal:setting:greater-than(name, ...value)
- check is setting name greater than values or not (return non-zero)_myzs:internal:setting:less-than(name, ...value)
- check is setting name less than values or not (return non-zero)_myzs:internal:setting:contains(name, ...value)
- check is setting name contains in value or not (return non-zero)myzs:setting:get(name, fallback)
- return value of setting name or fallback if data not existmyzs:setting:get-array(name, varname)
- set array value to inputvarname
_myzs:internal:module:name-deserialize(key, cmd)
- convert module key and call cmd with cmd(type, name, key)_myzs:internal:module:name-serialize(type, name)
- convert module type and name back to key_myzs:internal:module:checker:validate(name)
- check is input a valid module_myzs:internal:module:search-name(name, cmd)
- search module key and start callback_myzs:internal:module:search-module-type(type, cmd)
- search module by type and start callback_myzs:internal:module:fullpath(name)
- get module path by name_myzs:internal:module:load(name, filepath)
- load file as module_myzs:internal:module:skip(name, filepath)
- mark file as skipped module_myzs:internal:module:loaded-list(cmd)
- loop loaded modules with status_myzs:internal:module:total-list(cmd)
- loop all exist modules and myzs builtin and plugins
_myzs:internal:plugin:name-deserialize(key)
- convert plugin key (#) to plugin name and version_myzs:internal:plugin:name-serialize(name, version)
- convert plugin name and version back to plugin key_myzs:internal:plugin:install(name, version)
- install plugin repository from github and initial plugin_myzs:internal:plugin:upgrade(name, version)
- upgrade plugin repository from github and re-initital plugin_myzs:internal:plugin:initial(...args)
- run installing on each args input
_myzs:internal:changelog:loop(cmd)
- loop changelog and execute input function
_myzs:internal:metric:log-module
- saving information to metric file
myzs:zplug:checker:plugin-installed
- check is zplug plugin installed
_myzs:internal:group:initial(...args)
- parse formated args and install as group data_myzs:internal:group:load(name)
- load group name to current terminal