Tuesday, December 31, 2013

Re: Where is my system-wide init file?

On 31.12.13 10:18, Tony Mechelynck wrote:
> On 31/12/13 09:34, Erik Christiansen wrote:
> >$ grep which .bashrc
> >alias which='type -a' # Checks aliases & functions also.
>
> The problem with this alias, IIUC, is when one tries to use
>
> vim `which somecommand`
>
> to edit an executable script, since the output of "type" is in a different
> format.

Sort of. Making "which" a helpful tool and convenient mnemonic for the
vast majority of general use cases, makes it unsuited to that one, but
not merely due to format. On this host, without looking further than
"which" itself, it finds several (prioritised) alternatives:

$ which which
which is aliased to `type -a'
which is /usr/bin/which
which is /bin/which

I'm not too sure how a command should mind-read which of several
alternatives we'd prefer to examine, now that we know what's there. OK,
sometimes picking the one which has path priority will be the right one.
So I'd have to go with your second strategy:

> I suppose you would have to do
>
> vim `/usr/bin/which somecommand`
>
> instead (at least on my system, which is in /usr/bin, not in plain /bin) to
> bypass the alias, or else do it manually:
>
> which somecommand # aliased to type -a
> vim ~/bin/somecommand

If we want to tweak the command with path priority, then we'd need to
vim .bashrc, to get at the alias. But if we wanted to examine the
underlying shell script which constitutes "which", then it'd be
vim /bin/which, since /usr/bin/which is just a link to that anyway.

Finding stuff in the filesystem is, at least here, a greater challenge
than invoking vim on a specific file, so maximising transparency has the
greater payoff, I find. Making an informed choice on which alternative
to edit seems to beat a tiny bit of automation, I figure. But needs
differ, I'll accept.

Here's wishing a happy new year to all Vimmers. (Under an hour and a half
away here.)

Erik

--
GNU's not Unix, but Unix is a beast; its plural form is Unixen.
- GNU grep 2.5.1-cvs manpage

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: