I agree with the idea that you shouldn't get used to behaviour that isn't common on different boxes, but my change doesn't affect the semantic content of the command at all. The following commands achieve the same thing (where /home/roydsd is my home directory):

   ls ~/Documents
   ls /home/roydsd/Documents

My proposed change just alters what happens to Tab completion. On another machine, I'll get a wee surprise when Bash changes the ~ to /home/whoever, but the command will still work.

The tilde still works on my machine.

Derek Smithies wrote:
Douglas,
 I "like" the idea that one can customize their computer to do whatever.

However, you have the problem:
what happens when you have to use someone else's computer. Most likely they will have bash as the default shell, and ~ will work in the way you dislike

When someone else uses your computer - they will complain that the ~ symbol don't work.

I would have thought that using \~ will get most circumstances.


Derek.

==========================================================================
 On Fri, 7 Dec 2007, Douglas Royds wrote:

It has irritated me for some time that Bash was expanding ~ (my home directory
path). For instance, if I type:

   $ ls ~/Doc <Tab>

Bash would expand the path to:

   $ ls /home/roydsd/Documents

This is a matter of personal taste, but I'd prefer the tilde to remain,
thanks.

I've found the culprit in /etc/bash_completion. Find the function _expand(),
and edit it as follows:

   # This function expands tildes in pathnames
   #
   _expand()
   {
       [ "$cur" != "${cur%\\}" ] && cur="$cur\\"

       # expand ~username type directory specifications
       if [[ "$cur" == \~*/* ]]; then
           #eval cur=$cur <-------- Commented out
           return # <-------- Added
elif [[ "$cur" == \~* ]]; then
           #cur=${cur#\~}  <-------- Commented out
           #COMPREPLY=( $( compgen -P '~' -u $cur ) )  <--------
   Commented out
           #return [EMAIL PROTECTED]  <-------- Commented out
           return # <-------- Added
       fi
   }

Douglas.




=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================

Reply via email to