mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
chore(zsh/funcs): tidy up comments
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
#
|
#
|
||||||
# zshrc helper functions
|
# zshrc helper functions
|
||||||
#
|
#
|
||||||
# Helpers designed for use during setup of interactive shell environments
|
# Helpers designed for use during setup of interactive shell environments in
|
||||||
# (~/.zshrc ).
|
# `~/.zshrc`.
|
||||||
#
|
#
|
||||||
|
|
||||||
# setup-completions is a helper function to set up shell completions for a given
|
# Helper function to set up shell completions for a given command. It generates
|
||||||
# command. It generates Zsh completion scripts and places them in the specified
|
# Zsh completion scripts and places them in the specified completions directory.
|
||||||
# completions directory. If the completion file already exists, it checks if the
|
# If the completion file already exists, it checks if the source file has been
|
||||||
# source file has been updated and regenerates the completions if necessary.
|
# updated and regenerates the completions if necessary.
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
#
|
#
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
#
|
#
|
||||||
# The completions are placed in the directory specified by the ZSH_COMPLETIONS
|
# The completions are placed in the directory specified by the ZSH_COMPLETIONS
|
||||||
# environment variable. If ZSH_COMPLETIONS is not set, the completions are
|
# environment variable. If ZSH_COMPLETIONS is not set, the completions are
|
||||||
# placed in $HOME/.zsh/completions by default.
|
# placed in `$HOME/.zsh/completions` by default.
|
||||||
setup-completions() {
|
setup-completions() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
local source="$2"
|
local source="$2"
|
||||||
@@ -71,22 +71,26 @@ setup-completions() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Convert a bash/zsh alias to a function. It prints the unalias command and the
|
# Convert a bash/zsh alias to a function. It prints the `unalias` command and the
|
||||||
# function definition, meaning the output needs to be evaluated to take effect.
|
# function definition, meaning the output needs to be evaluated to take effect.
|
||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
|
|
||||||
# $1: The alias to convert. Should be a single line like "alias ll='ls -alF'"
|
# $1: The alias to convert. Should be a single line like "alias ll='ls -alF'"
|
||||||
# or "ll='ls -alF'".
|
# or "ll='ls -alF'".
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# alias brew="op plugin run -- brew"
|
#
|
||||||
# convert_alias_to_function "$(alias brew)"
|
# alias brew="op plugin run -- brew"
|
||||||
|
# convert_alias_to_function "$(alias brew)"
|
||||||
#
|
#
|
||||||
# This will print:
|
# This will print:
|
||||||
# unalias brew
|
#
|
||||||
# brew() {
|
# unalias brew
|
||||||
# op plugin run -- brew "$@"
|
# brew() {
|
||||||
# }
|
# op plugin run -- brew "$@"
|
||||||
|
# }
|
||||||
|
#
|
||||||
convert-alias-source-to-function-source() {
|
convert-alias-source-to-function-source() {
|
||||||
local line="$1"
|
local line="$1"
|
||||||
|
|
||||||
@@ -108,7 +112,7 @@ convert-alias-source-to-function-source() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print the unalias command and the function definition.
|
# Print the `unalias` command and the function definition.
|
||||||
echo -e "unalias ${alias_name}"
|
echo -e "unalias ${alias_name}"
|
||||||
echo -e "${alias_name}() {\n ${command} \"\$@\"\n}"
|
echo -e "${alias_name}() {\n ${command} \"\$@\"\n}"
|
||||||
}
|
}
|
||||||
@@ -120,8 +124,9 @@ convert-alias-source-to-function-source() {
|
|||||||
# $1: The alias to convert. Should be the name of the alias.
|
# $1: The alias to convert. Should be the name of the alias.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# alias brew="op plugin run -- brew"
|
#
|
||||||
# convert-alias-to-function brew
|
# alias brew="op plugin run -- brew"
|
||||||
|
# convert-alias-to-function brew
|
||||||
#
|
#
|
||||||
# This will replace the alias "brew" with a function that has the same behavior.
|
# This will replace the alias "brew" with a function that has the same behavior.
|
||||||
convert-alias-to-function() {
|
convert-alias-to-function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user