From d3202537f3bcd18f3b0b712d9c670b914d5a230c Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Thu, 15 Nov 2012 17:20:05 +0100 Subject: [PATCH] lesskey, setup.sh: Don't store less' history in ~/. --- .gitignore | 3 ++- lesskey | 4 ++++ setup.sh | 13 +++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index caf6922..5b546a1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /tmux.conf /tmux-window1.conf /tmux-window2.conf -# Ignore temporary zsh files. +# Ignore temporary files. +/lesshistory /zsh/cache /zsh/history* diff --git a/lesskey b/lesskey index a5aac7a..da9ace4 100644 --- a/lesskey +++ b/lesskey @@ -46,3 +46,7 @@ l right-scroll # ignore-case: Ignore case if the search string doesn't contain any uppercase # letters. LESS = --no-init --search-skip-screen --quit-if-one-screen --RAW-CONTROL-CHARS --ignore-case + +# Store less' history file in this directory. HISTORY_PATH is replaced by +# setup.sh because lesskey doesn't expand ~/. +LESSHISTFILE = HISTORY_PATH diff --git a/setup.sh b/setup.sh index a5af86b..041629f 100755 --- a/setup.sh +++ b/setup.sh @@ -39,8 +39,17 @@ fi mkdir -p ~/.tmp chmod 0700 ~/.tmp -# Generate ~/.less with lesskey. -lesskey lesskey +# Generate ~/.less with lesskey. Prevent cluttering ~/ by storing the history +# file in this directory; this requires replacing the constant HISTORY_PATH in +# lesskey. +echo lesskey: generating .lesskey +perl < lesskey \ + -e 'while () { + s/\bHISTORY_PATH\b/$ARGV[0]/; + print; + }' \ + "`pwd`/lesshistory" \ + | lesskey - chmod 0600 ~/.less # Find the required options to get colored ls output. GNU ls is preferred. See -- 2.44.1