vim-appimage
vim-appimage copied to clipboard
gvim appimage: run vim if called as vim; work with extracted appimage
The GVim appimage always tries to run as gvim (even if called through a symlink named vim, and even if no X11 $DISPLAY is set). This is because AppRun.wrapped tries first
test -L "${HERE}/usr/bin/gvim" && exec "${HERE}/usr/bin/gvim" "${@+"$@"}"
Cutting through all the cruft probably generated by linuxdeploy (two bash exec's even though no bash features are needed, the "${@+"$@"}" workaround for 1990's Bash), here's a simpler AppRun that works as vim when the appimage is called as vim. As a bonus this AppRun works when symlinked from an extracted appimage (hidden option gvim.appimage --appimage-extract available with all appimages)
#!/bin/sh
set -ue
: "${ARGV0:=$0}" # run without AppImage too
this_dir=$(readlink -f "$0")
this_dir=${this_dir%/*} # empty for '/'
[ -r "$this_dir"/apprun-hooks/linuxdeploy-plugin-gtk.sh ] &&
. "$this_dir"/apprun-hooks/linuxdeploy-plugin-gtk.sh
VIMRUNTIME=${this_dir}/usr/share/vim/vim91; export VIMRUNTIME
test -x "${this_dir}/usr/bin/gvim" || ARGV0=/vim
case "${ARGV0##*/}" in
(vim*) set -- "${this_dir}/usr/bin/vim" "$@" ;;
(*) set -- "${this_dir}/usr/bin/gvim" "$@" ;;
esac
unset ARGV0
exec "$@"
(note: updated after further investigation & #68)
Would you consider making a PR for this?
yes please. I'd appreciate it.
I've pushed PR #68; it's a little complicated, comments in the commit message (identical to PR message).
Summary:
Vim.appimagedidn't have any problems to begin with.GVim.appimage(un-extracted) can now be symlinked tovim/gvimand behaves accordingly (just as the release notes say — they were incorrect as this issue explains).- remaining problem:
GVim.appimage's AppRun is generated bylinuxdeploy-plugin-gtk(i.e. not under our control) and fails when symlinked from an extracted appimage (aka AppDir); this is not a new problem — it also fails before the PR, when symlinked (due todirname/readlinkorder). - thus we'd still need a separate script (say
AppDirRun, similar to the one I quoted in my initial issue) for users who extract. Alternatively, we'd need to mess with the deployment process and patch / replace the "broken"AppRunjust before packaging theappimagearchive (I'm not keen on this).
I've tested by regenerating Vim.appimage and GVim.appimage manually with appimagetool; I have not tested the GitHub deployment workflow though.
Should I add a separate AppDirRun as proposed in #68?
closing as fixed by #68