zsh-users
 help / color / mirror / code / Atom feed
* Why doesn't tab expand .
@ 2006-10-09 19:15 zzapper
  2006-10-10  2:38 ` Phil Pennock
  2006-10-11  9:13 ` zzapper
  0 siblings, 2 replies; 4+ messages in thread
From: zzapper @ 2006-10-09 19:15 UTC (permalink / raw)
  To: zsh-users


Hi Zedites

Why doesn't tab expand . ?

ie 

> cp /tmp/fred.txt .<Tab>

Be useful in a few cases?


-- 
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why doesn't tab expand .
  2006-10-09 19:15 Why doesn't tab expand zzapper
@ 2006-10-10  2:38 ` Phil Pennock
  2006-10-11  9:13 ` zzapper
  1 sibling, 0 replies; 4+ messages in thread
From: Phil Pennock @ 2006-10-10  2:38 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On 2006-10-09 at 19:15 +0000, zzapper wrote:
> Why doesn't tab expand . ?

To what?

"." is a directory, the "self" directory.  It's not an alias or special
to the shell in any way.  It's a directory entry which exists in every
directory, provided as part of the filesystem interface by the kernel;
on Unix-biased filesystems, it typically actually exists in the
filesystem.  Without anything else, it's of course interpreted relative
to the current working directory.

If you view a directory as a file containing mappings from filenames to
inodes (the actual file structure on disk), then the filesystem
hierarchies exist from some inodes pointed-to also being directories.
Every directory contains items called "." and ".."; "." points to the
directory itself, ".." to the parent (which is why you can't hardlink a
directory to be in two locations (anymore)).

/usr/./bin/./foo is valid and the same as /usr/bin/foo but with some
extra checks in there.

So "." is a valid filename, referencing a directory; since there's no
'/' anywhere, it's the '.' which exists in $PWD, and effectively the
same as $PWD for most intents and purposes.

> > cp /tmp/fred.txt .<Tab>
> 
> Be useful in a few cases?

Try $PWD<tab>

Regards,
-Phil


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why doesn't tab expand .
  2006-10-09 19:15 Why doesn't tab expand zzapper
  2006-10-10  2:38 ` Phil Pennock
@ 2006-10-11  9:13 ` zzapper
  2006-10-11 16:38   ` Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: zzapper @ 2006-10-11  9:13 UTC (permalink / raw)
  To: zsh-users; +Cc: zsh-workers

zzapper <david@tvis.co.uk> wrote in news:Xns9857CE0FC8AA4zzappergmailcom@
80.91.229.5:

> 
> Hi Zedites
> 
> Why doesn't tab expand . ?
> 
> ie 
> 
> cp /tmp/fred.txt .<Tab>
expanding to:-
> cp /tmp/fred.txt fred.txt

Which I could then arbitrarily choose to modify.

Someone has pointed out that . means current directory, so I guess it would 
be imoral


-- 
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why doesn't tab expand .
  2006-10-11  9:13 ` zzapper
@ 2006-10-11 16:38   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2006-10-11 16:38 UTC (permalink / raw)
  To: zsh-users

On Oct 11,  9:13am, zzapper wrote:
}
} zzapper <david@tvis.co.uk> wrote in news:Xns9857CE0FC8AA4zzappergmailcom@
} 80.91.229.5:
} 
} > cp /tmp/fred.txt .<Tab>
} expanding to:-
} > cp /tmp/fred.txt fred.txt
} 
} Which I could then arbitrarily choose to modify.
} 
} Someone has pointed out that . means current directory, so I guess it
} would be imoral

Well, not immoral, just ambiguous.  You have to assert via zstyles or
compdef that "." should not be considered a valid completion by itself,
and then assert by an entry in the matcher-list zstyle that it's OK to
complete both sides around a dot without having any other clues.

Although ... it looks like specifically what you want is not for "."
to complete, but for "cp" completion to insert the tail of the source
path argument as the default target argument?

  _mycp () {
    if [[ $CURRENT -ge $#words && $words[CURRENT-1] = */* ]]
    then
      compadd $words[CURRENT-1]:t
    fi
    _cp
  }
  compdef _mycp cp

This could be refined in several ways, e.g., you might prefer

  if [[ $CURRENT -ge $#words && $words[CURRENT-1] = */* &&
        $words[CURRENT] != */* ]]


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-10-11 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-09 19:15 Why doesn't tab expand zzapper
2006-10-10  2:38 ` Phil Pennock
2006-10-11  9:13 ` zzapper
2006-10-11 16:38   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).