Mini selfSelf-review
Comments are very important to future readers, they speed up the comprehension of the whole code. I think I messed up at least one comment, though(others pending review):
original:
# VS Code specific workaround to work under root alias sucode="sudo mkdir -p /root/.vscode && sudo code -w --user-data-dir=/root/.vscode"
suggested:
# run the editor with one-time SUDO_EDITOR set-up if [ "$editor_name" = code ]; then # code specific workaround sudo mkdir -p /root/.vscode && sudo code -w --user-data-dir=/root/.vscode "$@" else # main command generic SUDO_EDITOR="$editor_path $wait_option" sudoedit "$@" fi
avoid generating editors aliases for which editor is not installed
My previous solution is generating all editor aliases, no matter if such program is installed on the system, this could have been unpleasant to users.
original:
for cli_editor in $sudoedit__cli_editor_list; do alias su$cli_editor="sudoedit_enhanced_run $cli_editor ''" done for gui_editor in $sudoedit__gui_editor_list; do alias su$gui_editor="sudoedit_enhanced_run $gui_editor -w" done
suggested:
for cli_editor in $sudoedit__cli_editor_list; do if command -v "$cli_editor" > /dev/null 2>&1; then alias su$cli_editor="sudoedit_enhanced_run $cli_editor ''" fi done for gui_editor in $sudoedit__gui_editor_list; do if command -v "$gui_editor" > /dev/null 2>&1; then alias su$gui_editor="sudoedit_enhanced_run $gui_editor -w" fi done