From faf0d935c4b01c180c0a389cb62adaa6c2737d8a Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Thu, 10 Sep 2015 10:13:58 +0200 Subject: [PATCH] Debian: polishing various config files + DEB build script (blank license, changelog format, change line format issues remains). --- debian/changelog | 2 +- debian/control | 6 +- debian/copyright | 4 +- dist/2-debian-build-deb.sh | 8 +- dist/3-debian-push-mentors.sh | 2 +- dist/debian-env.sh | 8 +- dist/debian-make-distro.sh | 6 +- dist/debian/{hh.dirs => hstr.dirs} | 0 dist/debian/rules | 2 +- man/Makefile.am | 2 +- man/hstr.1 | 192 +++++++++++++++++++++++++++++ src/Makefile.am | 14 ++- 12 files changed, 221 insertions(+), 25 deletions(-) rename dist/debian/{hh.dirs => hstr.dirs} (100%) create mode 100644 man/hstr.1 diff --git a/debian/changelog b/debian/changelog index f57888e..ca94b1b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,4 +2,4 @@ hh (0.80-0ubuntu1) raring; urgency=low * Fixed keyboard loop; Ctrl-r consistent shortcuts; propagation of the text from the prompt to HH. - -- Martin Dvorak (Dvorka) Wed, 25 Dec 2013 17:21:31 +0100 +-- Martin Dvorak Wed, 25 Dec 2013 17:21:31 +0100 diff --git a/debian/control b/debian/control index caf806b..ed9021f 100644 --- a/debian/control +++ b/debian/control @@ -1,14 +1,14 @@ -Source: hh +Source: hstr Section: utils Priority: optional -Maintainer: Martin Dvorak (Dvorka) +Maintainer: Martin Dvorak Build-Depends: debhelper (>= 8.0.0), autotools-dev, libreadline-dev, libncursesw5-dev Standards-Version: 3.9.5 Homepage: https://github.com/dvorka/hstr Vcs-Git: https://github.com/dvorka/hstr.git Vcs-Browser: https://github.com/dvorka/hstr -Package: hh +Package: hstr Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Suggest box like shell history completion diff --git a/debian/copyright b/debian/copyright index 733bc50..0710208 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,10 +1,10 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: hh +Upstream-Name: hstr Source: https://github.com/dvorka/hstr Files: debian/* Copyright: 2015 Martin Dvorak -License: Apache-2.0 +License: Apache Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/dist/2-debian-build-deb.sh b/dist/2-debian-build-deb.sh index b3fa31a..f2867df 100755 --- a/dist/2-debian-build-deb.sh +++ b/dist/2-debian-build-deb.sh @@ -7,7 +7,7 @@ export SCRIPTHOME=`pwd` function createChangelog() { export MYTS=`date "+%a, %d %b %Y %H:%M:%S"` echo "Changelog timestamp: ${MYTS}" - echo -e "hh (${HHFULLVERSION}) ${UBUNTUVERSION}; urgency=low" > $1 + echo -e "hstr (${HHFULLVERSION}) ${UBUNTUVERSION}; urgency=low" > $1 echo -e "\n" >> $1 echo -e " * ${HHBZRMSG}" >> $1 echo -e "\n" >> $1 @@ -26,18 +26,18 @@ function createTarball() { cd ../${HH} } -echo -e "\n_ hh deb build _______________________________________________\n" +echo -e "\n_ HSTR deb build _______________________________________________\n" rm -rvf ../debian cp -rvf ${HHSRC}/debian .. createChangelog ../debian/changelog cp -vf debian/rules ../debian/rules -cp -vf debian/hh.dirs ../debian/hh.dirs +cp -vf debian/hstr.dirs ../debian/hstr.dirs cp -vf debian/watch ../debian/watch cd ../.. -mv hh ${HH} +mv hstr ${HH} cd ${HH} createTarball diff --git a/dist/3-debian-push-mentors.sh b/dist/3-debian-push-mentors.sh index 7dab250..95774c3 100755 --- a/dist/3-debian-push-mentors.sh +++ b/dist/3-debian-push-mentors.sh @@ -3,6 +3,6 @@ . ./debian-env.sh cd ../.. -dput mentors hh*source.changes +dput mentors hstr*source.changes # eof diff --git a/dist/debian-env.sh b/dist/debian-env.sh index 4317cd3..4589c6e 100755 --- a/dist/debian-env.sh +++ b/dist/debian-env.sh @@ -2,10 +2,10 @@ # Debian release: https://wiki.debian.org/IntroDebianPackaging -export HHVERSION="1.0.8" +export HHVERSION="1.17.0" #export HHFULLVERSION=${HHVERSION}-1.0 # NMU upload -export HHFULLVERSION=${HHVERSION}-1 # mantainer upload -export HH=hh_${HHVERSION} +export HHFULLVERSION=${HHVERSION}-1 # mantainer upload +export HH=hstr_${HHVERSION} export HHRELEASE=hh-${HHFULLVERSION} export HHSRC=/home/dvorka/p/hstr/github/hstr export NOW=`date +%Y-%m-%d--%H-%M-%S` @@ -13,6 +13,6 @@ export HHBUILD=hstr-${NOW} export UBUNTUVERSION=unstable -export HHBZRMSG="Radix sort fixes." +export HHBZRMSG="Debian distribution." # eof diff --git a/dist/debian-make-distro.sh b/dist/debian-make-distro.sh index 53b0ee3..139208b 100755 --- a/dist/debian-make-distro.sh +++ b/dist/debian-make-distro.sh @@ -2,7 +2,7 @@ . ~/p/hstr/github/hstr/dist/debian-env.sh -rm -rvf *.*~ ./debian +rm -rvf *.*~ ./debian ./bin mkdir ${HHBUILD} cd ${HHBUILD} @@ -15,14 +15,14 @@ tar zcf ${HH}.tgz ${HH} rm -rvf ${HH} #bzr dh-make -v packagename version tarball -bzr dh_make -v hh ${HHVERSION} ${HH}.tgz +bzr dh_make -v hstr ${HHVERSION} ${HH}.tgz # rewrite to native dh_make: #dh_make --single --createorig rm -vf *.orig.tar.gz -cd hh/dist +cd hstr/dist ./2-debian-build-deb.sh pwd diff --git a/dist/debian/hh.dirs b/dist/debian/hstr.dirs similarity index 100% rename from dist/debian/hh.dirs rename to dist/debian/hstr.dirs diff --git a/dist/debian/rules b/dist/debian/rules index 5c264dd..f14cfec 100755 --- a/dist/debian/rules +++ b/dist/debian/rules @@ -3,4 +3,4 @@ dh $@ override_dh_auto_install: - $(MAKE) DESTDIR=$$(pwd)/debian/hh prefix=/usr install + $(MAKE) DESTDIR=$$(pwd)/debian/hstr prefix=/usr install diff --git a/man/Makefile.am b/man/Makefile.am index e8316cc..b4e5c45 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1 +1 @@ -man_MANS = hh.1 \ No newline at end of file +man_MANS = hh.1 hstr.1 diff --git a/man/hstr.1 b/man/hstr.1 new file mode 100644 index 0000000..5b6f51d --- /dev/null +++ b/man/hstr.1 @@ -0,0 +1,192 @@ +.TH HH 1 +.SH NAME +\fBhh\fR \- easily view, navigate, sort and use your command history with shell history suggest box. +.SH SYNOPSIS +.B hh [option] [arg1] [arg2]... +.SH DESCRIPTION +.B hh +uses shell history to provide suggest box like functionality +for commands used in the past. By default it parses .bash-history +file that is filtered as you type a command substring. Commands +are not just filtered, but also ordered by a ranking algorithm +that considers number of occurences, length and timestamp. +Favorite and frequently used commands can be bookmarked. In addition +\fBhh\fR allows removal of commands from history - for instance with a typo +or with a sensitive content. +.SH OPTIONS +.TP +\fB-h --help\fR +Show help +.TP +\fB-n --non-interactive\fR +Print filtered history on standard output and exit +.TP +\fB-f --favorites\fR +Show favorites view immediately +.TP +\fB-s --show-configuration\fR +Show configuration that can be added to ~/.bashrc +.TP +\fB-b --show-blacklist\fR +Show blacklist of commands to be filtered out before history processing +.TP +\fB-V --version\fR +Show version information +.SH KEYS +.TP +\fBpattern\fR +Type to filter shell history. +.TP +\fBCtrl\-e\fR +Toggle regular expression and substring search. +.TP +\fBCtrl\-t\fR +Toggle case sensitive search. +.TP +\fBCtrl\-/\fR, \fBCtrl\-7\fR +Rotate view of history as provided by Bash, ranked history ordered by the number of occurences/length/timestamp and favorites. +.TP +\fBCtrl\-f\fR +Add currently selected command to favorites. +.TP +\fBCtrl\-l\fR +Make search pattern lowercase or uppercase. +.TP +\fBCtrl\-r\fR, \fBUP\fR arrow, \fBDOWN\fR arrow, \fBCtrl\-n\fR, \fBCtrl\-p\fR +Navigate in the history list. +.TP +\fBTAB\fR, \fBRIGHT\fR arrow +Choose currently selected item for completion and let user to edit it on the command prompt. +.TP +\fBLEFT\fR arrow +Choose currently selected item for completion and let user to edit it in editor (fix command). +.TP +\fBENTER\fR +Choose currently selected item for completion and execute it. +.TP +\fBDEL\fR +Remove currently selected item from the shell history. +.TP +\fBBACSKSPACE\fR, \fBCtrl\-h\fR +Delete last pattern character. +.TP +\fBCtrl\-u\fR, \fBCtrl\-w\fR +Delete pattern and search again. +.TP +\fBCtrl\-x\fR +Write changes to shell history and exit. +.TP +\fBCtrl\-g\fR +Exit with empty prompt. +.SH ENVIRONMENT VARIABLES +\fBhh\fR defines the following environment variables: +.TP +\fBHH_CONFIG\fR +Configuration options: + +\fIhicolor\fR + Get more colors with this option (default is monochromatic). + +\fImonochromatic\fR + Ensure black and white view. + +\fIregexp\fR + Filter command history using regular expressions (substring match is default) + +\fIsubstring\fR + Filter command history using substring. + +\fIkeywords\fR + Filter command history using keywords - item matches if contains all keywords in pattern in any order. + +\fIcasesensitive\fR + Make history filtering case sensitive (it's case insensitive by default). + +\fIrawhistory\fR + Show normal history as a default view (metric-based view is shown otherwise). + +\fIfavorites\fR + Show favorites as a default view (metric-based view is shown otherwise). + +\fIblacklist\fR + Load list of commands to skip when processing history from ~/.hh_blacklist (built-in blacklist used otherwise). + +\fIbigkeysskip\fR + Skip big history entries i.e. very long lines (default). + +\fIbigkeysfloor\fR + Use different sorting slot for big keys when building metrics-based view (big keys are skipped by default). + +\fIbigkeysexit\fR + Exit (fail) on presence of a big key in history (big keys are skipped by default). + +\fIwarning\fR + Show warning. + +\fIdebug\fR + Show debug information. + +Example: + \fBexport HH_CONFIG=hicolor,regexp,rawhistory\fR + +.TP +\fBHH_PROMPT\fR +Change prompt string which is \fBuser@host$\fR by default. + +Example: + \fBexport HH_PROMPT="$ "\fR + +.SH FILES +.TP +\fB~/.hh_favorites\fR + Bookmarked favorite commands. +.TP +\fB~/.hh_blacklist\fR + Command blacklist. + +.SH BASH CONFIGURATION +Optionally add the following lines to ~/.bashrc: +.nf +.sp +export HH_CONFIG=hicolor # get more colors +shopt -s histappend # append new history items to .bash_history +export HISTCONTROL=ignorespace # leading space hides commands from history +export HISTFILESIZE=10000 # increase history file size (default is 500) +export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500) +export PROMPT_COMMAND="history \-a; history \-n; ${PROMPT_COMMAND}" +# if this is interactive shell, then bind hh to Ctrl-r (for Vi mode check doc) +if [[ $\- =~ .*i.* ]]; then bind '"\eC\-r": "\eC\-a hh \eC-j"'; fi +.sp +.fi +The prompt command ensures synchronization of the history between BASH memory +and history file. +.SH ZSH CONFIGURATION +Optionally add the following lines to ~/.zshrc: +.nf +.sp +export HISTFILE=~/.zsh_history # ensure history file visibility +export HH_CONFIG=hicolor # get more colors +bindkey -s "\eC\-r" "\eeqhh\en" # bind hh to Ctrl-r (for Vi mode check doc) +.sp +.fi +.SH EXAMPLES +.TP +\fBhh git\fR + Start `hh` and show only history items containing 'git'. +.TP +\fBhh --non-interactive git\fR + Print history items containing 'git' to standard output and exit. +.TP +\fBhh --show-configuration >> ~/.bashrc\fR + Append default \fBhh\fR configuration to your Bash profile. +.TP +\fBhh --show-blacklist\fR + Show blacklist configured for history processing. +.SH AUTHOR +Written by Martin Dvorak +.SH BUGS +Report bugs to https://github.com/dvorka/hstr/issues +.SH "SEE ALSO" +.BR history (1), +.BR bash (1), +.BR zsh (1) \ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index 121cf64..989e533 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,13 +21,17 @@ AM_LDFLAGS = # bin_ installs to bin; hh_ is the binary name bin_PROGRAMS = hh -hh_SOURCES = \ - hashset.c include/hashset.h \ +hh_SOURCES = \ + hashset.c include/hashset.h \ hstr_curses.c include/hstr_curses.h \ hstr_history.c include/hstr_history.h \ - hstr_utils.c include/hstr_utils.h \ + hstr_utils.c include/hstr_utils.h \ hstr_favorites.c include/hstr_favorites.h \ hstr_blacklist.c include/hstr_blacklist.h \ - hstr_regexp.c include/hstr_regexp.h \ - radixsort.c include/radixsort.h \ + hstr_regexp.c include/hstr_regexp.h \ + radixsort.c include/radixsort.h \ hstr.c + +# create hh > hstr hard link on installation +install-exec-hook: + ln $(DESTDIR)$(bindir)/hh$(EXEEXT) $(DESTDIR)$(bindir)/hstr$(EXEEXT)