diff --git a/share/functions/__fish_paginate.fish b/share/functions/__fish_paginate.fish new file mode 100644 index 000000000..992993b6c --- /dev/null +++ b/share/functions/__fish_paginate.fish @@ -0,0 +1,13 @@ +function __fish_paginate -d "Paginate the current command using the users default pager" + + set -l cmd less + if set -q PAGER + set cmd $PAGER + end + + if commandline -j|grep -v "$cmd *\$" >/dev/null + + commandline -aj "|$cmd;" + end + +end diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index 6340810bc..60fefc3b8 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -85,7 +85,7 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis bind \cd delete-or-exit # This will make sure the output of the current command is paged using the less pager when you press Meta-p - bind \ep 'if commandline -j|grep -v "less *\$" >/dev/null; commandline -aj "|less;"; end' - + bind \ep '__fish_paginate' + end