Introducing My-Alternatives
My-Alternatives takes an honest run at making a useful tool to allow you to configure alternatives (see: update-alternatives) that only affect your local account / shell sessions.
No root/sudo
My-Alternatives does not require root / sudo privileges to use, as it creates and maintains user-owned alt root directories that store your alternative links.
Quick Example
Here's a quick example of using my-alterantives to configure a local override for the pager
alternative:
confirm current system value for pager
$ which pager
/usr/bin/pager
take a closer look
$ ls -l /usr/bin/pager
lrwxrwxrwx root root /usr/bin/pager -> /etc/alternatives/pager
$ ls -l /etc/alternatives/pager
lrwxrwxrwx root root /etc/alternatives/pager -> /usr/bin/less
init my-alternatives
$ eval "$( my-alternatives init )"
configure pager
$ my-alternatives config pager
There are 2 choices for the alternative pager (providing ${MY_ALTS_ROOT}/bin/pager).
Selection Path Priority Status
------------------------------------------------------------
1 /bin/more 50
2 /usr/bin/less 77 system value
Type selection number:
select non-system value '/bin/more'
... Type selection number: 1
configured local alternative for pager: /bin/more
confirm updated value
$ which pager
/tmp/my-alts.abcd/bin/pager
take a closer look
$ ls -l "${MY_ALTS_ROOT}"/bin/pager "${MY_ALTS_ROOT}"/man/man1/pager.1.gz
lrwxrwxrwx user group bin/pager -> /bin/more
lrwxrwxrwx user group man/man1/pager.1.gz -> /usr/share/man/man1/more.1.gz
Per-Shell Alternatives
The example above shows how to create per-shell alternatives.
That is, using my-alternatives init
without specifying a target directory results in the creation and use of a temporary directory that only the current shell session knows about.
User-Level Alternatives
You can configure user-level alternatives by providing a specific init directory i.e:
$ eval "$( my-alternatives init ~/.my-alts )"
More Information
Please see the Project Homepage for more inrmation.
Thanks for looking and please let me know if you have any questions!
-TekWizely
Top comments (0)