fish: Fix dirprev resizing

master
Pierre Neidhardt 2017-01-15 13:18:09 +01:00
parent d29ec42312
commit 38efb2d440
2 changed files with 3 additions and 2 deletions

View File

@ -11,7 +11,7 @@ set -g fish_cdhist_max 128
## Go back to last cdhist folder. Run this before the SHELL_FILEBROWSER hook.
if grep -q . $fish_cdhist_path ^ /dev/null
set dirprev (cat $fish_cdhist_path)
set -q dirprev[$fish_cdhist_max]; and set dirprev $dirprev[-$fish_cdhist_max..-1]
set -q dirprev[$fish_cdhist_max]; and set dirprev $dirprev[(math - $fish_cdhist_max)..-1]
cd $dirprev[(count $dirprev)] ^ /dev/null
end

View File

@ -22,7 +22,8 @@ function cd --description "Change directory"
if set -q dirprev
## Remove duplicates.
set -g dirprev (string match -v $PWD $dirprev) $PWD
set -q dirprev[$fish_cdhist_max]; and set dirprev $dirprev[-$fish_cdhist_max..-1]
## Keep last '$fish_cdhist_max' elements only.
set -q dirprev[$fish_cdhist_max]; and set dirprev $dirprev[(math - $fish_cdhist_max)..-1]
## Save history.
string join \n $dirprev > $fish_cdhist_path
else