Discussion:
update-alternatives: install with permanent arguments
(too old to reply)
Dmitrii Odintcov
2024-08-22 10:10:01 UTC
Permalink
Let's say I want to install VS Code / Codium as an alternative for
`/usr/bin/editor`, but I want it to always run with `--wait
--reuse-window` so that other software can rely on the editor
returning after the file is saved (like `crontab -e` does, for
example)

I cannot do `update-alternatives --install /usr/bin/editor editor
"$(which codium) --wait --reuse-window" 0` because the "alternative
path doesn't exist".

Suggestions?
Greg Wooledge
2024-08-22 11:10:01 UTC
Permalink
Post by Dmitrii Odintcov
Let's say I want to install VS Code / Codium as an alternative for
`/usr/bin/editor`, but I want it to always run with `--wait
--reuse-window` so that other software can rely on the editor
returning after the file is saved (like `crontab -e` does, for
example)
I cannot do `update-alternatives --install /usr/bin/editor editor
"$(which codium) --wait --reuse-window" 0` because the "alternative
path doesn't exist".
Suggestions?
Write a wrapper script like


#!/bin/sh
exec codium --wait --reuse-window "$@"


and use this script as the symlink target of /usr/bin/editor (do it
manually, not with update-alternatives). Don't forget to chmod 755.
Dmitrii Odintcov
2024-08-22 11:40:02 UTC
Permalink
Hi Greg,


This has occurred to me, but seemed like a bit of a hack and less
convenient to transfer to other machines...
do it manually, not with update-alternatives
Why so? Could I not feed the script path to update-alternatives install?


Thanks
Post by Dmitrii Odintcov
Let's say I want to install VS Code / Codium as an alternative for
`/usr/bin/editor`, but I want it to always run with `--wait
--reuse-window` so that other software can rely on the editor
returning after the file is saved (like `crontab -e` does, for
example)
I cannot do `update-alternatives --install /usr/bin/editor editor
"$(which codium) --wait --reuse-window" 0` because the "alternative
path doesn't exist".
Suggestions?
Write a wrapper script like
#!/bin/sh
and use this script as the symlink target of /usr/bin/editor (do it
manually, not with update-alternatives). Don't forget to chmod 755.
Greg Wooledge
2024-08-22 12:20:02 UTC
Permalink
Post by Dmitrii Odintcov
Hi Greg,
This has occurred to me, but seemed like a bit of a hack and less
convenient to transfer to other machines...
do it manually, not with update-alternatives
Why so? Could I not feed the script path to update-alternatives install?
Well, if it works, then I guess it's OK.
Henning Follmann
2024-08-22 13:20:01 UTC
Permalink
Post by Greg Wooledge
Post by Dmitrii Odintcov
Hi Greg,
This has occurred to me, but seemed like a bit of a hack and less
convenient to transfer to other machines...
do it manually, not with update-alternatives
Why so? Could I not feed the script path to update-alternatives install?
Well, if it works, then I guess it's OK.
Exactly. And if you want it less "hackish", build a deb where the postinstall
creates the links.

-H
--
Henning Follmann | ***@itcfollmann.com
Loading...