Opening most recently modified file in vim
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
The following commands work
$ ls -1t | head -1
git_sync_log20180924_00.txt
$ vi git_sync_log20180924_00.txt
But this does not
$ ls -1t | head -1 | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
How can I accomplish this (open most recently modified file in vi)?
shell pipe vi
add a comment |Â
up vote
1
down vote
favorite
The following commands work
$ ls -1t | head -1
git_sync_log20180924_00.txt
$ vi git_sync_log20180924_00.txt
But this does not
$ ls -1t | head -1 | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
How can I accomplish this (open most recently modified file in vi)?
shell pipe vi
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
The following commands work
$ ls -1t | head -1
git_sync_log20180924_00.txt
$ vi git_sync_log20180924_00.txt
But this does not
$ ls -1t | head -1 | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
How can I accomplish this (open most recently modified file in vi)?
shell pipe vi
The following commands work
$ ls -1t | head -1
git_sync_log20180924_00.txt
$ vi git_sync_log20180924_00.txt
But this does not
$ ls -1t | head -1 | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
How can I accomplish this (open most recently modified file in vi)?
shell pipe vi
shell pipe vi
edited 6 mins ago
asked 16 mins ago
Renu
1114
1114
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
vim -- "$(ls -t | head -n 1)"
(that assumes file names don't contain newline characters).
Or if using zsh
:
vim -- *(om[1])
Or:
vim -- *(.om[1])
To only consider regular files.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
vim -- "$(ls -t | head -n 1)"
(that assumes file names don't contain newline characters).
Or if using zsh
:
vim -- *(om[1])
Or:
vim -- *(.om[1])
To only consider regular files.
add a comment |Â
up vote
3
down vote
vim -- "$(ls -t | head -n 1)"
(that assumes file names don't contain newline characters).
Or if using zsh
:
vim -- *(om[1])
Or:
vim -- *(.om[1])
To only consider regular files.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
vim -- "$(ls -t | head -n 1)"
(that assumes file names don't contain newline characters).
Or if using zsh
:
vim -- *(om[1])
Or:
vim -- *(.om[1])
To only consider regular files.
vim -- "$(ls -t | head -n 1)"
(that assumes file names don't contain newline characters).
Or if using zsh
:
vim -- *(om[1])
Or:
vim -- *(.om[1])
To only consider regular files.
answered 12 mins ago


Stéphane Chazelas
285k53525865
285k53525865
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471080%2fopening-most-recently-modified-file-in-vim%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password