xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 25ee9ac3bf8dcb6d08bfcea501a16735cbb1499c

Expand macros in :[un]select !{command}
Thanks to Michael Corvin.
Author: xaizek
Author date (UTC): 2017-06-14 14:29
Committer name: xaizek
Committer date (UTC): 2017-06-14 14:29
Parent(s): 5e5e55b4d422d9c4662e1ecd72a859f80c26db8a
Signing key: 99DC5E4DB05F6BE2
Tree: 66030a04af6312e11842d85c3759530f3a1b5e83
File Lines added Lines deleted
ChangeLog 2 0
THANKS 1 0
src/flist_sel.c 5 1
tests/misc/commands_selection.c 14 0
File ChangeLog changed (mode: 100644) (index c96bfd5cb..11f065b11)
14 14 View current directory on ".." for quickview/view mode only if no viewer View current directory on ".." for quickview/view mode only if no viewer
15 15 matches such entry. matches such entry.
16 16
17 Expand macros in :[un]select !{command}. Thanks to Michael Corvin.
18
17 19 Fixed ruler being updated when it shouldn't even be visible. Thanks to Fixed ruler being updated when it shouldn't even be visible. Thanks to
18 20 filterfalse. filterfalse.
19 21
File THANKS changed (mode: 100644) (index eaedb335b..912a76bf8)
... ... Marius Schmidl
83 83 Martin Fischer Martin Fischer
84 84 Marton Balazs (balmar) Marton Balazs (balmar)
85 85 Merovius Merovius
86 Michael Corvin
86 87 Michael Kopp Michael Kopp
87 88 Michael Maddern (madders) Michael Maddern (madders)
88 89 Michael Vetter (jubalh) Michael Vetter (jubalh)
File src/flist_sel.c changed (mode: 100644) (index 8d5040508..68df20fc5)
... ... flist_sel_by_filter(FileView *view, const char cmd[], int erase_old, int select)
255 255 int nfiles; int nfiles;
256 256 int i; int i;
257 257
258 if(run_cmd_for_output(cmd, &files, &nfiles) != 0)
258 char *const expanded_cmd = expand_macros(cmd, NULL, NULL, 1);
259
260 if(run_cmd_for_output(expanded_cmd, &files, &nfiles) != 0)
259 261 { {
262 free(expanded_cmd);
260 263 status_bar_error("Failed to start/read output of external command"); status_bar_error("Failed to start/read output of external command");
261 264 return 1; return 1;
262 265 } }
266 free(expanded_cmd);
263 267
264 268 /* Append to previous selection unless ! is specified. */ /* Append to previous selection unless ! is specified. */
265 269 if(select && erase_old) if(select && erase_old)
File tests/misc/commands_selection.c changed (mode: 100644) (index 1cb9916b8..b742c55ba)
... ... TEST(select_and_unselect_accept_external_command)
278 278 assert_false(lwin.dir_entry[2].selected); assert_false(lwin.dir_entry[2].selected);
279 279 } }
280 280
281 TEST(select_expands_macros_in_external_command)
282 {
283 strcpy(lwin.curr_dir, cwd);
284 assert_success(chdir(cwd));
285
286 add_some_files_to_view(&lwin);
287
288 assert_success(exec_commands("select !echo %c", &lwin, CIT_COMMAND));
289 assert_int_equal(1, lwin.selected_files);
290 assert_true(lwin.dir_entry[0].selected);
291 assert_false(lwin.dir_entry[1].selected);
292 assert_false(lwin.dir_entry[2].selected);
293 }
294
281 295 TEST(select_and_unselect_consider_trailing_slash) TEST(select_and_unselect_consider_trailing_slash)
282 296 { {
283 297 strcpy(lwin.curr_dir, cwd); strcpy(lwin.curr_dir, cwd);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master