Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Simplify alias functions in README #8

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,17 @@ valid .hvm file exists in the current directory.
```zsh
# Hugo Version Manager: override path to the hugo executable.
hugo() {
hvm_common_msg="Run 'hvm use' to fix or 'hvm disable' to disable version management."
if [ -f ".hvm" ]; then
hugo_bin=$(cat ".hvm" 2> /dev/null)
if [ -z "$hugo_bin" ]; then
>&2 printf "The .hvm file in this directory is empty.\\n"
>&2 printf "Run 'hvm use' or remove the .hvm file from this directory.\\n"
return 1
fi
if ! echo "${hugo_bin}" | grep -q "hugo$"; then
>&2 printf "The .hvm file in this directory is invalid.\\n"
>&2 printf "Run 'hvm use' or remove the .hvm file from this directory.\\n"
>&2 printf "%s\\n" "${hvm_common_msg}"
return 1
fi
if [ ! -f "${hugo_bin}" ]; then
>&2 printf "Unable to find %s.\\n" "${hugo_bin}"
>&2 printf "Run 'hvm use' or remove the .hvm file from this directory.\\n"
>&2 printf "%s\\n" "${hvm_common_msg}"
return 1
fi
else
Expand All @@ -84,21 +80,17 @@ hugo() {
```bash
# Hugo Version Manager: override path to the hugo executable.
hugo() {
hvm_common_msg="Run 'hvm use' to fix or 'hvm disable' to disable version management."
if [ -f ".hvm" ]; then
hugo_bin=$(cat ".hvm" 2> /dev/null)
if [ -z "$hugo_bin" ]; then
>&2 printf "The .hvm file in this directory is empty.\\n"
>&2 printf "Run 'hvm use' or remove the .hvm file from this directory.\\n"
return 1
fi
if ! echo "${hugo_bin}" | grep -q "hugo$"; then
>&2 printf "The .hvm file in this directory is invalid.\\n"
>&2 printf "Run 'hvm use' or remove the .hvm file from this directory.\\n"
>&2 printf "%s\\n" "${hvm_common_msg}"
return 1
fi
if [ ! -f "${hugo_bin}" ]; then
>&2 printf "Unable to find %s.\\n" "${hugo_bin}"
>&2 printf "Run 'hvm use' or remove the .hvm file from this directory.\\n"
>&2 printf "%s\\n" "${hvm_common_msg}"
return 1
fi
else
Expand Down
Loading