vim / vim-appimage

AppImage for gVim
118 stars 18 forks source link

gvim appimage: run vim if called as vim; work with extracted appimage #67

Closed mralusw closed 1 day ago

mralusw commented 4 months ago

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)

jnm commented 3 months ago

Would you consider making a PR for this?

chrisbra commented 3 months ago

yes please. I'd appreciate it.

mralusw commented 3 months ago

I've pushed PR #68; it's a little complicated, comments in the commit message (identical to PR message).

Summary:

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?

chrisbra commented 1 day ago

closing as fixed by #68