* tab completion sort by modification time
@ 2015-01-10 19:33 kamaraju kusumanchi
2015-01-10 19:52 ` Eric Cook
2015-01-10 20:11 ` Peter Stephenson
0 siblings, 2 replies; 7+ messages in thread
From: kamaraju kusumanchi @ 2015-01-10 19:33 UTC (permalink / raw)
To: zsh-users
Hi all,
Long time bash user here. Looking to see if zsh can solve my
particular problem. If it does, I'd like to switch to it.
Say a directory contains a lot of files and say I am only interested
in the files that were recently edited/created. When doing a tab
completion inside this directory, I would like the files to be listed
in the order of modification time (similar to ls -rt). This way the
latest files show up at the end and I can easily copy/paste their
names using mouse onto the command line.
Is zsh tab completion system comprehensive enough to do something like this?
FWIW, this feature is not present in bash at the moment -
http://lists.gnu.org/archive/html/bug-bash/2014-12/msg00161.html . So
I am looking for alternatives.
thanks
raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: tab completion sort by modification time
2015-01-10 19:33 tab completion sort by modification time kamaraju kusumanchi
@ 2015-01-10 19:52 ` Eric Cook
2015-01-11 4:40 ` kamaraju kusumanchi
2015-01-10 20:11 ` Peter Stephenson
1 sibling, 1 reply; 7+ messages in thread
From: Eric Cook @ 2015-01-10 19:52 UTC (permalink / raw)
To: zsh-users
On 01/10/2015 02:33 PM, kamaraju kusumanchi wrote:
> Hi all,
>
> Long time bash user here. Looking to see if zsh can solve my
> particular problem. If it does, I'd like to switch to it.
>
> Say a directory contains a lot of files and say I am only interested
> in the files that were recently edited/created. When doing a tab
> completion inside this directory, I would like the files to be listed
> in the order of modification time (similar to ls -rt). This way the
> latest files show up at the end and I can easily copy/paste their
> names using mouse onto the command line.
>
> Is zsh tab completion system comprehensive enough to do something like this?
>
> FWIW, this feature is not present in bash at the moment -
> http://lists.gnu.org/archive/html/bug-bash/2014-12/msg00161.html . So
> I am looking for alternatives.
>
> thanks
> raju
zstyle ':completion:*' file-sort modification
Will accomplish that for any completer that uses the normal means of
completing filenames.
You can be more specific with the context if you don't want to affect
everything.
zstyle ":completion:*:${EDITOR}:*" file-sort modification
You can also reverse the order:
zstyle ':completion:*' file-sort 'reverse modification'
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: tab completion sort by modification time
2015-01-10 19:33 tab completion sort by modification time kamaraju kusumanchi
2015-01-10 19:52 ` Eric Cook
@ 2015-01-10 20:11 ` Peter Stephenson
2015-01-10 20:30 ` Mikael Magnusson
1 sibling, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2015-01-10 20:11 UTC (permalink / raw)
To: kamaraju kusumanchi, zsh-users
On Sat, 10 Jan 2015 14:33:49 -0500
kamaraju kusumanchi <raju.mailinglists@gmail.com> wrote:
> Long time bash user here. Looking to see if zsh can solve my
> particular problem. If it does, I'd like to switch to it.
>
> Say a directory contains a lot of files and say I am only interested
> in the files that were recently edited/created. When doing a tab
> completion inside this directory, I would like the files to be listed
> in the order of modification time (similar to ls -rt). This way the
> latest files show up at the end and I can easily copy/paste their
> names using mouse onto the command line.
>
> Is zsh tab completion system comprehensive enough to do something like this?
I'm assuming as a bash user you're not subscribed to zsh-users...
If you want this behaviour globally, I think it's as simple as the
following piece of configuration:
zstyle ':completion:*' file-sort modification
If you want more control, reading the zshcompsys manual page should give
you ideas of how to modify that first argument --- which is a pattern
matching the context in which a completion occurs --- should give you
some ideas how to do so.
It's also relatively straightforward (i.e someone here can work out
how to do it in a few minutes after you've scratched your head for
half an hour:-)) to add a new key binding that has this file completion
behaviour.
pws
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: tab completion sort by modification time
2015-01-10 20:11 ` Peter Stephenson
@ 2015-01-10 20:30 ` Mikael Magnusson
2015-01-10 22:08 ` kamaraju kusumanchi
0 siblings, 1 reply; 7+ messages in thread
From: Mikael Magnusson @ 2015-01-10 20:30 UTC (permalink / raw)
To: Peter Stephenson; +Cc: kamaraju kusumanchi, Zsh Users
On Sat, Jan 10, 2015 at 9:11 PM, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> On Sat, 10 Jan 2015 14:33:49 -0500
> kamaraju kusumanchi <raju.mailinglists@gmail.com> wrote:
>> Long time bash user here. Looking to see if zsh can solve my
>> particular problem. If it does, I'd like to switch to it.
>>
>> Say a directory contains a lot of files and say I am only interested
>> in the files that were recently edited/created. When doing a tab
>> completion inside this directory, I would like the files to be listed
>> in the order of modification time (similar to ls -rt). This way the
>> latest files show up at the end and I can easily copy/paste their
>> names using mouse onto the command line.
>>
>> Is zsh tab completion system comprehensive enough to do something like this?
>
> I'm assuming as a bash user you're not subscribed to zsh-users...
>
> If you want this behaviour globally, I think it's as simple as the
> following piece of configuration:
>
> zstyle ':completion:*' file-sort modification
>
> If you want more control, reading the zshcompsys manual page should give
> you ideas of how to modify that first argument --- which is a pattern
> matching the context in which a completion occurs --- should give you
> some ideas how to do so.
>
> It's also relatively straightforward (i.e someone here can work out
> how to do it in a few minutes after you've scratched your head for
> half an hour:-)) to add a new key binding that has this file completion
> behaviour.
As it happens, I have one of these lying around already (I'm 83% sure
you wrote this for me too),
zstyle ':completion:most-recent-file:*' match-original both
zstyle ':completion:most-recent-file:*' file-sort modification
zstyle ':completion:most-recent-file:*' file-patterns '*:all\ files'
zstyle ':completion:most-recent-file:*' hidden all
zstyle ':completion:most-recent-file:*' completer _files
zle -C most-recent-file menu-complete _generic
bindkey "^N" most-recent-file
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: tab completion sort by modification time
2015-01-10 20:30 ` Mikael Magnusson
@ 2015-01-10 22:08 ` kamaraju kusumanchi
0 siblings, 0 replies; 7+ messages in thread
From: kamaraju kusumanchi @ 2015-01-10 22:08 UTC (permalink / raw)
To: Zsh Users
On Sat, Jan 10, 2015 at 3:30 PM, Mikael Magnusson <mikachu@gmail.com> wrote:
> As it happens, I have one of these lying around already (I'm 83% sure
> you wrote this for me too),
> zstyle ':completion:most-recent-file:*' match-original both
> zstyle ':completion:most-recent-file:*' file-sort modification
> zstyle ':completion:most-recent-file:*' file-patterns '*:all\ files'
> zstyle ':completion:most-recent-file:*' hidden all
> zstyle ':completion:most-recent-file:*' completer _files
> zle -C most-recent-file menu-complete _generic
> bindkey "^N" most-recent-file
>
> --
> Mikael Magnusson
Thanks for all the replies guys. I will give this a try.
raju
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: tab completion sort by modification time
2015-01-10 19:52 ` Eric Cook
@ 2015-01-11 4:40 ` kamaraju kusumanchi
2015-01-12 5:58 ` kamaraju kusumanchi
0 siblings, 1 reply; 7+ messages in thread
From: kamaraju kusumanchi @ 2015-01-11 4:40 UTC (permalink / raw)
To: Zsh Users
On Sat, Jan 10, 2015 at 2:52 PM, Eric Cook <llua@gmx.com> wrote:
> You can also reverse the order:
> zstyle ':completion:*' file-sort 'reverse modification'
I confirm that this line is all I needed to get what I am after. But
thanks to all other tidbits. They will all be useful as I get more
experience with Z shell.
raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: tab completion sort by modification time
2015-01-11 4:40 ` kamaraju kusumanchi
@ 2015-01-12 5:58 ` kamaraju kusumanchi
0 siblings, 0 replies; 7+ messages in thread
From: kamaraju kusumanchi @ 2015-01-12 5:58 UTC (permalink / raw)
To: Zsh Users
On Sat, Jan 10, 2015 at 11:40 PM, kamaraju kusumanchi
<raju.mailinglists@gmail.com> wrote:
> On Sat, Jan 10, 2015 at 2:52 PM, Eric Cook <llua@gmx.com> wrote:
>> You can also reverse the order:
>> zstyle ':completion:*' file-sort 'reverse modification'
>
> I confirm that this line is all I needed to get what I am after. But
> thanks to all other tidbits. They will all be useful as I get more
> experience with Z shell.
>
> raju
So I have been experimenting with zsh and I found one feature that I
really like. The shell cleans up the tab completions once it is
completed.
For example, say I have
rajulocal@hogwarts ~/x % ls file*
file10.txt file11.txt file12.txt file13.txt file1.txt file2.txt
file3.csv file4.csv file5.tsv file6.tsv file7.txt file9.txt
Now, I can bring up a list of possible completions by <tab>
rajulocal@hogwarts ~/x % ls file<tab>
Completing files
file2.txt file4.csv file6.tsv file7.txt file10.txt
file12.txt
file3.csv file5.tsv file1.txt file9.txt file11.txt
file13.txt*
and when I enter 12.txt, the list completely disappears.
rajulocal@hogwarts ~/x % ls file12.txt
file12.txt
That is pretty impressive and something I always wanted to do in bash.
raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-01-12 5:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-10 19:33 tab completion sort by modification time kamaraju kusumanchi
2015-01-10 19:52 ` Eric Cook
2015-01-11 4:40 ` kamaraju kusumanchi
2015-01-12 5:58 ` kamaraju kusumanchi
2015-01-10 20:11 ` Peter Stephenson
2015-01-10 20:30 ` Mikael Magnusson
2015-01-10 22:08 ` kamaraju kusumanchi
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).