From 38efb2d440c3f90951c8ed7a46fafdf48bd33ae4 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sun, 15 Jan 2017 13:18:09 +0100 Subject: [PATCH] fish: Fix dirprev resizing --- .config/fish/config.fish | 2 +- .config/fish/functions/cd.fish | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 1bae6ed8..4bd53e9f 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -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 diff --git a/.config/fish/functions/cd.fish b/.config/fish/functions/cd.fish index 949bc502..b2d1928d 100644 --- a/.config/fish/functions/cd.fish +++ b/.config/fish/functions/cd.fish @@ -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