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

hardcoded references to edit will break #177

Closed
LucasLarson opened this issue Dec 6, 2020 · 0 comments
Closed

hardcoded references to edit will break #177

LucasLarson opened this issue Dec 6, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@LucasLarson
Copy link
Owner

LucasLarson commented Dec 6, 2020

edit is not at all portable here:

alias aliases='edit ${ZSH:-${HOME}/.oh-my-${SHELL##*/}}/custom/aliases.${SHELL##*/}; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login'
alias ohmyzsh='cd ${ZSH:-${HOME}/.oh-my-${SHELL##*/}}'
alias zshconfig='edit ${HOME}/.${SHELL##*/}rc; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login'
alias zshenv='edit ${HOME}/.${SHELL##*/}env; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login'

A solution like ${EDITOR:-vi}¹ instead of edit² is portable and should replace it.


  1. this may not be the correct if-not-𝑥-then-𝑦 syntax when calling a binary like /usr/bin/vi, but it’s close
  2. edit is defined as:

    dotfiles/.zshenv

    Lines 8 to 20 in 9c37ff8

    if command -v nvim > /dev/null 2>&1; then
    EDITOR="nvim"
    elif command -v vim > /dev/null 2>&1; then
    EDITOR="vim"
    elif command -v vi > /dev/null 2>&1; then
    EDITOR="vi"
    else
    EDITOR="nano"
    fi
    export EDITOR
    # https://github.com/koalaman/shellcheck/wiki/SC2139/db553bf16fcb86b2cdc77b835e75b9121eacc429#this-expands-when-defined-not-when-used-consider-escaping
    alias editor='$EDITOR'
    alias edit="editor"
@LucasLarson LucasLarson added the bug Something isn't working label Dec 6, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant