On Mon, Apr 17, 2017 at 4:57 PM, Pete Smith <psmith...@gmail.com> wrote: [...] > So what's the possibility of adding -v option to popd and pushd???
Feel free to send patches. Under the hood, the pushd/popd builtins call the dirs builtin with no arguments after their execution, so it's just a matter of adding to pushd/popd the ability to interpret the -v flag, and then pass this flag back to the dirs_builtin execution. In the below patch I just pass the flag unconditionally, but it should give you an idea of what you need to do. # patched bash-4.4$ pwd /home/dualbus/foo/bar/baz bash-4.4$ pushd aaaaaaaaa/ 0 ~/foo/bar/baz/aaaaaaaaa 1 ~/foo/bar/baz bash-4.4$ pushd bbbbbbbbbb/ 0 ~/foo/bar/baz/aaaaaaaaa/bbbbbbbbbb 1 ~/foo/bar/baz/aaaaaaaaa 2 ~/foo/bar/baz bash-4.4$ popd 0 ~/foo/bar/baz/aaaaaaaaa 1 ~/foo/bar/baz Or now that I think about it, you can get away with these functions: # masked builtins dualbus@debian:~/foo/bar/baz$ pushd() { builtin pushd "$@" >/dev/null; dirs -v; }; popd(){ builtin popd "$@" >/dev/null; dirs -v; } dualbus@debian:~/foo/bar/baz$ pushd aaaaaaaaa/ 0 ~/foo/bar/baz/aaaaaaaaa 1 ~/foo/bar/baz dualbus@debian:~/foo/bar/baz/aaaaaaaaa$ pushd bbbbbbbbbb/ 0 ~/foo/bar/baz/aaaaaaaaa/bbbbbbbbbb 1 ~/foo/bar/baz/aaaaaaaaa 2 ~/foo/bar/baz # patch dualbus@debian:~/src/gnu/bash$ PAGER= git diff -- builtins diff --git a/builtins/pushd.def b/builtins/pushd.def index 6579e4c8..bd41fcca 100644 --- a/builtins/pushd.def +++ b/builtins/pushd.def @@ -178,6 +178,8 @@ pushd_builtin (list) int j, flags, skipopt; intmax_t num; char direction; + WORD_DESC *wd; + WORD_LIST *wl; orig_list = list; @@ -300,7 +302,11 @@ pushd_builtin (list) if (j == EXECUTION_SUCCESS) { add_dirstack_element ((flags & NOCD) ? savestring (list->word->word) : current_directory); - dirs_builtin ((WORD_LIST *)NULL); + + wd = make_word ("-v"); + wl = make_word_list (wd, NULL); + + dirs_builtin (wl); if (flags & NOCD) free (current_directory); return (EXECUTION_SUCCESS); @@ -324,6 +330,8 @@ popd_builtin (list) int flags; char direction; char *which_word; + WORD_DESC *wd; + WORD_LIST *wl; CHECK_HELPOPT (list); @@ -400,7 +408,10 @@ popd_builtin (list) pushd_directory_list[i] = pushd_directory_list[i + 1]; } - dirs_builtin ((WORD_LIST *)NULL); + wd = make_word ("-v"); + wl = make_word_list (wd, NULL); + + dirs_builtin (wl); return (EXECUTION_SUCCESS); }