News for hackers. Stuff that matters.
Re:Why “alias” is my last resort for aliases by latexr on Wednesday March 05, 2025 @08:59AM (#43266449)
> When I create, update, or delete an alias, I have to reload my `.zshrc`.

Only if you need the change to be available immediately in the tab you’re on. Which you can ensure, appropriately, with an alias:

  alias z='"${EDITOR}" ~/.zshrc && source ~/.zshrc'
Now executing `z` will open your `.zshrc` in your default editor and immediately source it afterwards.
Re:Why “alias” is my last resort for aliases by noahjk on Wednesday March 05, 2025 @01:45PM (#43270560)
Here's what I use in my .zshrc with VS Code:

    alias reload="source ~/.zshrc >/dev/null"
    alias zshconfig="code --wait --new-window ~/.zshrc && reload"
the --wait flag tells zsh that it's not done executing until the window/file is closed.
Re:Why “alias” is my last resort for aliases by latexr on Wednesday March 05, 2025 @01:55PM (#43270673)
On macOS, you can do that for any GUI editor by using the `open` command with the `-W` and `-n` flags. See `man open` for details.
Re:Why “alias” is my last resort for aliases by dcb_lu on Thursday March 06, 2025 @03:35AM (#43277853)
I do something similar to my .bash_aliases, but with a few short additions to make sure running it multiple times doesn't have any strange side effects. For instance:

  function edit_load() {
    $EDITOR $1
    source $1
    if [ $? -eq 0 ]
    then
      echo "$1 updated."
    fi
  }
  alias aliases="edit_load ~/.bash_aliases"

  # to make sure I don't add things to $PATH on each reload
  append_path () {
    case ":$PATH:" in
      *:"$1":*)
        ;;
      \*)
        PATH="${PATH:+$PATH:}$1"
    esac
  }
  append_path '/blah/blah/bin'