diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..718e705b --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,58 @@ +# Copilot instructions + +This document provides instructions to the copilot AI assistants and agents. + +## General instructions + +- Write beautiful code. +- Handle for errors, and exceptions and corner cases. +- Do good and don't be evil. + +## Functional architecture instructions + +- This repository is a repo of a TUI based application for the completion from the Bash or Zsh history. + +## Technology stack instructions + +- Frontend: ncurses. +- Backend: C. + +## Backend code instructions + +- Application backend is written in C. +- Always start comments you generate with lowercase letter. + +## Security instructions + +- ALWAYS follow security best practices. +- NEVER log form data that may contain sensitive information. +- ALWAYS consider overflow and memory corruption issues when writing C code. + +## Backend code quality instructions + +- NEVER use hacks or workarounds to make tests pass - always write clean, production-quality code. +- NEVER modify production code with ugly hacks just to make tests work - fix tests properly or remove them. +- ALWAYS follow clean code principles. + +## Frontend instructions + +- Application frontend is written in NCurses. + +## Test instructions + +- Test code is stored in the `tests/src` directory. +- Use `valgrind` to check for memory leaks and memory corruption issues after code changes. +- Tests can be run with `cd build && make test`. +- Write backend tests for all bugs being fixed. +- Use https://github.com/ThrowTheSwitch/Unity framework for testing. +- Each test (function) is structured into 3 sections: // GIVEN, // WHEN, and // THEN. // GIVEN section prepares the data, // WHEN section performs the actual test, and // THEN section asserts, checks and prints the results. +- Use `DONE` instead of emoji character ✓ (do not use emoji/unicode characters, use the text inside) + +## Build instructions + +- The project is built with `automake` and `make`. +- You can use `cd build && make build` to build the project. + +## Documentation instructions + +- ALWAY document new features in the man page located in the `man/` directory. diff --git a/.github/workflows/build_ubuntu.yml b/.github/workflows/build_ubuntu.yml index b468ce5b..73ff818b 100644 --- a/.github/workflows/build_ubuntu.yml +++ b/.github/workflows/build_ubuntu.yml @@ -4,14 +4,14 @@ on: [push] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: submodules: recursive - - name: Install packages - run: sudo apt-get update && sudo apt install -y build-essential qt5-default qt5-qmake ccache libncursesw5-dev libreadline-dev + - name: Install packages for Ubuntu 24.04 + run: sudo apt-get update && sudo apt install -y build-essential qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools ccache libncursesw5-dev libreadline-dev - name: Build lib and run unit tests using Unity test framework run: cd test && qmake hstr-unit-tests.pro && make clean all && ./hstr-unit-tests diff --git a/.gitignore b/.gitignore index e79c8fbc..ecf97475 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,13 @@ /autom4te.cache/ /aclocal.m4 +/confdefs.h /compile /config.guess /config.log /config.status /config.sub /configure +/configure~ /depcomp /install-sh /missing @@ -13,7 +15,10 @@ /src/hh .deps/ .vscode -Makefile +/Makefile +/man/Makefile +/src/Makefile +/test/Makefile Makefile.in *.o *.pro.user @@ -32,3 +37,4 @@ test/hstr-unit-tests /hstr.pro.user* *.stash *.save +/.vibe \ No newline at end of file diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 6c997944..22a073c7 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -1,5 +1,5 @@ # Configuration -Get most of HSTR by configuring it with: +Get the most out of HSTR by configuring it with: ```bash # bash @@ -147,7 +147,7 @@ To show the prompt at the bottom of the screen (instead at the top) use: export HSTR_CONFIG=prompt-bottom ``` -To show the basic help and history help labels on the opposite site (instead of next to the prompt) use: +To show the basic help and history help labels on the opposite side (instead of next to the prompt) use: ```bash export HSTR_CONFIG=help-on-opposite-side @@ -213,8 +213,8 @@ export HSTR_CONFIG=duplicates ``` ### Static favorites -Last selected favorite command is put the head of favorite commands list -by default. If you want to disable this behavior and make favorite +Last selected favorite command is put at the head of the favorite commands list +by default. If you want to disable this behavior and make the favorite commands list static, then use the following configuration: ```bash @@ -238,7 +238,7 @@ to `HSTR_CONFIG` environment variable: export HSTR_CONFIG=blacklist ``` -Commands to be stored in `~/.hstr_blacklist` file with trailing empty line. For instance: +Commands are to be stored in `~/.hstr_blacklist` file with a trailing empty line. For instance: ``` cd @@ -293,7 +293,7 @@ export HSTR_CONFIG=keywords-matching,hicolor,debug ``` ## Bash History Settings -Use the following `bash` settings to get most out of HSTR. +Use the following `bash` settings to get the most out of HSTR. Increase the size of history maintained by `bash` - variables defined below increase the number of history items and history file size (default value is 500): @@ -331,4 +331,4 @@ If you use `zsh`, set `HISTFILE` environment variable in `~/.zshrc`: export HISTFILE=~/.zsh_history ``` -Please check your system configuration - history might be store in `~/.zsh_history`, `~/.zhistory` or other file. +Please check your system configuration - history might be stored in `~/.zsh_history`, `~/.zhistory` or other file. diff --git a/Changelog b/Changelog index 522f984d..f0979ca7 100644 --- a/Changelog +++ b/Changelog @@ -1,157 +1,180 @@ +2026-01-28 Martin Dvorak + + * Released v3.2.0 - Minor release bringing: + - Configuration for TIOCSTI enforcement + - Added SIGQUIT handling to cleanup terminal state on quit + - Fixed buffer overflow (window resize) and missing Bash autocomplete configuration + - Fixed undesired encapsulation of patterns with quotes in case they contain spaces + - Updated changelog layout + 2023-04-18 Martin Dvorak - * Released v3.1.0 - Minor release fixing a Bash function that is used - when ioctl/TIOCSTI is not available. + * Released v3.1.0 - Minor release: + - Fixed Bash function used when ioctl/TIOCSTI is not available 2023-04-15 Martin Dvorak - * Released v3.0.0 - major release which adds ability of HSTR to work - on operating systems and Linux kernels without ioctl/TIOCSTI support. + * Released v3.0.0 - Major release: + - Added ability to work on operating systems and Linux kernels without + ioctl/TIOCSTI support 2022-12-11 Martin Dvorak - * Released v2.6.0 - fix release (several memory leak and overflow fixes, - MacPorts and Debian documentation, Snap script fix, GitHub Actions workflow). + * Released v2.6.0 - Fix release: + - Several memory leak and overflow fixes + - MacPorts and Debian documentation + - Snap script fix + - GitHub Actions workflow 2021-12-13 Martin Dvorak - * Released v2.5.0 - minor fix release to fix Arch build. + * Released v2.5.0 - Minor fix release: + - Fixed Arch build 2021-12-03 Martin Dvorak - * Released v2.4.0 - ability to insert custom command to terminal prompt, - minor fixes. + * Released v2.4.0 - Minor release: + - Ability to insert custom command to terminal prompt + - Minor fixes 2020-11-19 Martin Dvorak - * Released v2.3.0 - zsh timestamp extended history parsing and SEGFAULT fixes. + * Released v2.3.0: + - Zsh timestamp extended history parsing + - SEGFAULT fixes 2019-12-21 Martin Dvorak - * Released v2.2.0 - toggle visibility/move help lines (Fabian Saldias), - zsh support fixes, several memory leaks fixed. + * Released v2.2.0: + - Toggle visibility/move help lines (Fabian Saldias) + - Zsh support fixes + - Several memory leaks fixed 2019-12-08 Martin Dvorak - * Released v2.1.0 - significant zsh support improvements and stabilization. + * Released v2.1.0: + - Significant zsh support improvements and stabilization 2018-08-28 Martin Dvorak - * Released v2.0.0 - Major release which resolves confusing hstr/hh ambiguity by choosing - hstr to be the only name used. hh becomes just a shell alias. Therefore this release - introduces backward incompatible changes: all HH_ starting environment variables were - changed to HSTR_, similarly configuration file names starting with .hh_ were renamed - to start with .hstr_, identifiers used in HSTR_CONFIG were changed e.g. favorites to - favorites-view. - * Please check man page for details and update your 1.x.x configuration. - * Ubuntu package name was changed - use: apt install hstr. Tarball name has been changed - as well to have hstr prefix - please update your scripts. - * Additional improvements: all memory leaks fixed, long commands handling improved (...), - bash autocomplete added. + * Released v2.0.0 - Major release with backward incompatible changes: + - Resolved confusing hstr/hh ambiguity - hstr is now the only name, hh is just + a shell alias + - All HH_ environment variables changed to HSTR_ + - Configuration files .hh_* renamed to .hstr_* + - HSTR_CONFIG identifiers changed (e.g., favorites to favorites-view) + - Ubuntu package name changed to hstr (use: apt install hstr) + - Tarball name changed to hstr prefix + - All memory leaks fixed + - Long commands handling improved (...) + - Bash autocomplete added + - Please check man page for details and update your 1.x.x configuration 2018-08-13 Martin Dvorak - * Released v1.27.0 - Long lines support, QtCreator IDE migration, all build scripts - rewritten, new distros (my Debian PPA, snap, ...), CI, unit test framework and tests, - various fixes. + * Released v1.27.0: + - Long lines support + - QtCreator IDE migration + - All build scripts rewritten + - New distros (Debian PPA, snap, ...) + - CI support + - Unit test framework and tests + - Various fixes 2018-05-06 Martin Dvorak - * Released v1.25 - Community contributed fixes and improvements. Keyword search is default. + * Released v1.25: + - Community contributed fixes and improvements + - Keyword search is default 2018-01-03 Martin Dvorak - * Released v1.24 - Reproducible build and stabilization. + * Released v1.24: + - Reproducible build and stabilization 2017-09-30 Martin Dvorak - * Released v1.23 - WSL (Bash on Ubuntu on Windows 10) support + * Released v1.23: + - WSL (Bash on Ubuntu on Windows 10) support 2017-01-21 Martin Dvorak - * Released v1.22 - zsh history mgmt improvements (delete). + * Released v1.22: + - Zsh history management improvements (delete) 2016-11-22 Martin Dvorak - * Released v1.21 - Ubuntu Yakkety Yak release. + * Released v1.21: + - Ubuntu Yakkety Yak release 2016-04-27 Martin Dvorak - * Released v1.20 - Bottom prompt - * This release rewrite of screen rendering allowing to - choose prompt and help location - top or bottom. In - addition Ubuntu 16.04 LST is supported. + * Released v1.20 - Bottom prompt: + - Rewrite of screen rendering allowing to choose prompt and help location + (top or bottom) + - Ubuntu 16.04 LTS support 2015-11-25 Martin Dvorak - * Released v1.19 - Stabilization release - * This minor release brings fixes of regexp mode. + * Released v1.19 - Stabilization release: + - Fixes of regexp mode 2015-11-23 Martin Dvorak - * Released v1.18 - Blacklists, Debian and Gentoo - * This minor release bring blacklist configurable from - a file (commands that are ignored). It also improves - Debian and Gentoo distribution builders. + * Released v1.18 - Blacklists, Debian and Gentoo: + - Blacklist configurable from a file (commands that are ignored) + - Improved Debian and Gentoo distribution builders 2015-05-09 Martin Dvorak - * Released v1.17 - History Management and Color Profiles - * This release brings improvements and stabilization - of the history management along with terminal - background agnostic color profiles. + * Released v1.17 - History Management and Color Profiles: + - Improvements and stabilization of history management + - Terminal background agnostic color profiles 2015-01-08 Martin Dvorak - * Released v1.15 - First Item Autoselect and Vim Binding - * Minor release that brings first history item - autoselect on empty prompt selection, Vim style - history navigation binding and several bug fixes. + * Released v1.15 - First Item Autoselect and Vim Binding: + - First history item autoselect on empty prompt selection + - Vim style history navigation binding + - Several bug fixes 2014-10-29 Martin Dvorak - * Released v1.14 - Keyboard Search and Improved Highlighting - * New release brings keyboard based search i.e. matching - of history entries by occurrence of words in arbitrary - order. - * In addition highlighting of matching segments in history - entries has been improved. + * Released v1.14 - Keyboard Search and Improved Highlighting: + - Keyboard based search (matching of history entries by occurrence of words + in arbitrary order) + - Improved highlighting of matching segments in history entries 2014-09-11 Martin Dvorak - * Released v1.13 - Transparent terminal and Internationalization - * New release brings support for transparent terminals. - * Internationalization problems were finally solved - use - of Czech, German, Chinese, ... special characters w/ - and w/o diacritics should be smooth. + * Released v1.13 - Transparent terminal and Internationalization: + - Support for transparent terminals + - Internationalization problems solved (Czech, German, Chinese, ... special + characters with and without diacritics) 2014-05-05 Martin Dvorak - * Released v1.12 - Regexp - * New release brings regexp based filtering of command - history. In addition it is possible to use HSTR in - non-interactive mode i.e. filtered output is written - to standard output. openSUSE became newly supported - distribution. + * Released v1.12 - Regexp: + - Regexp based filtering of command history + - Non-interactive mode support (filtered output written to standard output) + - openSUSE became newly supported distribution 2014-04-14 Martin Dvorak - * Released v1.10 - Favorites. - * Major release that brings favorites - favorite - commands can be bookmarked for later use and managed - in a brand new view. + * Released v1.10 - Favorites: + - Favorite commands can be bookmarked for later use + - Managed in a brand new view 2014-03-16 Martin Dvorak - * Released v1.3 - Radix Sort Stabilization - * A stabilization release that enables loading of huge - history files and makes internal radix sort - implementation more efficient. + * Released v1.3 - Radix Sort Stabilization: + - Enabled loading of huge history files + - More efficient internal radix sort implementation 2014-01-25 Martin Dvorak - * Released v1.0 - The First Stable Release. + * Released v1.0 - The First Stable Release 2013-12-03 Martin Dvorak - * Released v0.2 - Initial Release. + * Released v0.2 - Initial Release diff --git a/INSTALLATION.md b/INSTALLATION.md index 4aaf07bf..9dba3ba8 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -562,10 +562,12 @@ as if it had been typed by the user. * Cygwin * WSL -HSTR uses `TIOCSTI` to insert a command chosen by the user in HSTR +HSTR uses `TIOCSTI` to **insert a command chosen by the user** in HSTR to shell prompt - if `TIOCSTI` is available. Otherwise shell specific line editors features are used. -**Therefore it is important to configure HSTR after the installation:** +Therefore it is **very important** to configure HSTR after the installation: * [HSTR configuration](README.md#configuration) + +Without proper configuration HSTR will [not be able to insert commands to terminal](https://github.com/dvorka/hstr/issues/531). diff --git a/PKGBUILD b/PKGBUILD index 71cd6a2d..ef73e429 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -4,7 +4,7 @@ # Contributor: Busindre pkgname=hstr -pkgver=3.1 +pkgver=3.2 pkgrel=1 pkgdesc="A command line utility that brings improved BASH command completion from the history. It aims to make completion easier and more efficient than Ctrl-r." arch=('x86_64' diff --git a/README.md b/README.md index b04d8e3e..d2fd2b2a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![All releases downloads](https://img.shields.io/github/downloads/dvorka/hstr/total.svg)](https://github.com/dvorka/hstr/releases) [![License](https://img.shields.io/github/license/dvorka/hstr?color=%23fe0000)](https://github.com/dvorka/hstr/blob/master/LICENSE) -Easily view, navigate and search your **command history** with shell history suggest box for +Easily view, navigate and search your **command history** with shell history TUI suggest box for [bash](https://www.gnu.org/software/bash/) and [zsh](CONFIGURATION.md#zsh-history-settings). [![Shell History Suggest Box](doc/hstr-v2.gif "Shell History Suggest Box @ YouTube")](http://www.youtube.com/watch?v=sPF29NyXe2U) @@ -27,6 +27,14 @@ or **bookmark** your favorite commands. +## Packages + +
+ + Packaging status + +
+ ## Installation Install: @@ -84,9 +92,29 @@ hstr --show-zsh-configuration >> ~/.zshrc For detailed HSTR configuration documentation please refer to [Configuration](CONFIGURATION.md). +## Tips +Troubleshooting: + +* [Commands chosen in HSTR are not inserted to terminal](INSTALLATION.md#hstr-2x-to-3x-ioctl--tiocsti) + +Tips and tricks: + +* [How to hide commands from your history](./TIPS.md) +* [How to use command tags for fast lookup](./TIPS.md) +* [How to curate your favorite commands](./TIPS.md) + + ## In the News -Read about HSTR in [LinuxMagazine](http://www.linux-magazine.com/Issues/2014/164/Bash-History-on-Steroids), [UbuntuGeek](http://www.ubuntugeek.com/tag/hstr-bash-history), [DebianAdmin](http://www.debianadmin.com/hstr-easily-view-navigate-search-and-use-your-command-history-with-shell-history.html), [Tuxdiary](http://tuxdiary.com/2015/02/17/hstr/), [Softpedia](http://linux.softpedia.com/get/Terminals/BASH-Command-History-Completion-103155.shtml) and [OSTechNix](https://www.ostechnix.com/hstr-easily-view-navigate-search-manage-commandline-history/). +Read about HSTR in: + +* [LinuxMagazine](http://www.linux-magazine.com/Issues/2014/164/Bash-History-on-Steroids) +* [UbuntuGeek](http://www.ubuntugeek.com/tag/hstr-bash-history) +* [DebianAdmin](http://www.debianadmin.com/hstr-easily-view-navigate-search-and-use-your-command-history-with-shell-history.html) +* [Tuxdiary](http://tuxdiary.com/2015/02/17/hstr/) +* [Softpedia](http://linux.softpedia.com/get/Terminals/BASH-Command-History-Completion-103155.shtml) +* [OSTechNix](https://www.ostechnix.com/hstr-easily-view-navigate-search-manage-commandline-history/) + ## Documentation @@ -96,7 +124,7 @@ Check man page: man hstr ``` -User videos: [Zack](https://www.youtube.com/watch?v=Qd75pIeQkH8), [Dvorka](https://www.youtube.com/watch?v=sPF29NyXe2U) and [Yu-Jie Lin](https://www.youtube.com/watch?v=Qx5n_5B5xUw). +User videos: [Zack](https://www.youtube.com/watch?v=Qd75pIeQkH8), [Dvorka](https://www.youtube.com/watch?v=sPF29NyXe2U), [Yayuuu](https://www.reddit.com/r/commandline/comments/1lo5up5/hstr_tiny_bash_script_that_helps_you_browse_and/), and [Yu-Jie Lin](https://www.youtube.com/watch?v=Qx5n_5B5xUw). ## Bugs diff --git a/SECURITY.md b/SECURITY.md index db3fdfc5..4ad212cd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,6 +6,7 @@ The following HSTR versions are currently being supported with security updates. | Version | Supported | | -------- | ------------------ | +| 3.2.0 | :white_check_mark: | | 3.1.0 | :white_check_mark: | | 3.0.0 | :white_check_mark: | | 2.6.0 | :white_check_mark: | diff --git a/TIPS.md b/TIPS.md new file mode 100644 index 00000000..354a025d --- /dev/null +++ b/TIPS.md @@ -0,0 +1,78 @@ +# HSTR Tips and Tricks +Tips: + +* [Hiding Commands from History](#hiding-commands-from-history) +* [Commands Tagging](#commands-tagging) +* [Favorite Commands](#favorite-commands) + + +## Hiding Commands from History + +You can exclude commands from being saved to your history by adding a leading space before the command. This requires the `HISTCONTROL` variable to be set appropriately. + +```bash +# Bash +export HISTCONTROL=ignorespace + +# Zsh +setopt HIST_IGNORE_SPACE +``` + +Now any command starting with a space will not be recorded in your history: + +```bash + secret-command --password=123 +``` + +You can also prevent specific commands from being saved by setting `HISTIGNORE`: + +```bash +# Bash +export HISTIGNORE="ls:cd:pwd:exit:date" + +# Zsh +export HISTORY_IGNORE="(ls|cd|pwd|exit|date)" +``` + +## Commands Tagging + +You can add comments at the end of your commands to make them easier to find in HSTR. This is especially useful for complex commands with long paths or many options - just tag them with a short, memorable keyword. + +For example, instead of typing the full path segments to find this command: + +```bash +cd /home/user/projects/github/hstr # HHH +``` + +You can simply type `HHH` in HSTR to find it instantly. + +Here are more examples of commonly used complex commands with tags: + +```bash +# Find Docker container by typing "DDD" +docker run -it --rm -v $(pwd):/app -w /app node:18 npm install # DDD + +# Find SSH tunnel by typing "SSS" +ssh -L 8080:localhost:3000 user@remote-server.example.com # SSS + +# Find database backup by typing "BBB" +pg_dump -h localhost -U postgres -d mydb > backup_$(date +%Y%m%d).sql # BBB + +# Find complex Git command by typing "GGG" +git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit # GGG +``` + +Tags work because HSTR searches the entire command line, including comments. Choose short, memorable tags that are easy to type. + + +## Favorite Commands + +Mark your most frequently used commands as favorites for instant access: + +1. **Add to favorites**: Navigate to a command in HSTR and press Ctrl-f +2. **View favorites**: Press Ctrl-/ to toggle between history and favorites view +3. **Remove from favorites**: Navigate to a favorited command and press DEL again + +Favorites are persistent across sessions and stored in `~/.hstr_favorites` file. + + diff --git a/build/Makefile b/build/Makefile new file mode 100644 index 00000000..8caee390 --- /dev/null +++ b/build/Makefile @@ -0,0 +1,128 @@ +# hstr.c HSTR shell history completion utility + +# Copyright (C) 2014-2026 Martin Dvorak + +# 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 + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.DEFAULT_GOAL := help + +# +# VARIABLES +# + +# HSTR version - extracted from src/hstr.c +HSTR_VERSION := $(shell grep 'hstr version' ../src/hstr.c | sed 's/.*hstr version \\"\([^\\]*\)\\".*/\1/') + +# +# CMD +# + +DIFF := colordiff -u + + +# +# HELP +# + +.PHONY: help +help: ## make targets help + @echo " _ _ ____ _____ ____ " + @echo "| | | / ___|_ _| _ \\ " + @echo "| |_| \\___ \\ | | | |_) |" + @echo "| _ |___) || | | _ < " + @echo "|_| |_|____/ |_| |_| \\_\\ $(HSTR_VERSION)" + @echo "" + @echo "HSTR: history suggest box - Swiss knife:" + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | sort \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +# +# CODING +# + +.PHONY: vibe +vibe: + @ls -l ../.github/copilot*.md + @cd .. && copilot --allow-all-tools --banner + +# +# CLEAN +# + +.PHONY: clean +clean: ## clean build artifacts + @rm -vf ../hstr ../src/hstr + @cd .. && make clean ; cd build + +# +# BUILD +# + +../src/hstr: + cd ./tarball && ./tarball-automake.sh && cd ../.. && ./configure && make all + +build-dev: clean ../src/hstr ## clean, configure, and build HSTR + @echo "HSTR $(HSTR_VERSION) built for development" + +build: ../src/hstr ## clean, configure, and build HSTR + strip ../src/hstr + +# +# RUN +# + +.PHONY: run-dev +run-dev: build-dev ## run HSTR for development + ../src/hstr + +run: ../src/hstr ## run HSTR + ../src/hstr + +run-web: ## run HSTR web preview + cd ../web && python3 -m http.server 8000 + +# +# TEST +# + +.PHONY: test +test: ## run HSTR unit tests + cd ../test && qmake hstr-unit-tests.pro && make clean all && ./hstr-unit-tests + +.PHONY: test-memleaks +test-memleaks: ## run HSTR memory leak tests with Valgrind + ./test-memleaks.sh + +# +# INSTALL +# + +.PHONY: install-personal +install-personal: build ## install HSTR for personal user + @echo "Installing HSTR $(HSTR_VERSION) for personal user..." + @rm -vf $(HOME)/bin/hstr + @cp -vf ../src/hstr $(HOME)/bin + @echo "HSTR $(HSTR_VERSION) installed to $(HOME)/bin" + hstr --version + +# +# package +# + +.PHONY: . +releng-ubuntu: ## release launchpad package for Ubuntu + @echo "= Diff ============================" + $(DIFF) ./ubuntu/launchpad-make-all-releases.sh ~/p/hstr/launchpad/launchpad-make-all-releases.sh || true + @echo "= Script ============================" + cd ~/p/hstr/launchpad && ./launchpad-make-all-releases.sh diff --git a/build/arch/update-pkgconfig-sha256-on-repo-change.sh b/build/arch/update-pkgconfig-sha256-on-repo-change.sh index a23ed8d0..eccfdffd 100755 --- a/build/arch/update-pkgconfig-sha256-on-repo-change.sh +++ b/build/arch/update-pkgconfig-sha256-on-repo-change.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/debian/aptly-add-deb.sh b/build/debian/aptly-add-deb.sh index 25008a62..1ab7ec7f 100755 --- a/build/debian/aptly-add-deb.sh +++ b/build/debian/aptly-add-deb.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/build/debian/debian/copyright b/build/debian/debian/copyright index 07102089..1f52e500 100644 --- a/build/debian/debian/copyright +++ b/build/debian/debian/copyright @@ -3,7 +3,7 @@ Upstream-Name: hstr Source: https://github.com/dvorka/hstr Files: debian/* -Copyright: 2015 Martin Dvorak +Copyright: 2026 Martin Dvorak License: Apache Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/build/debian/make-deb.sh b/build/debian/make-deb.sh index 29bd9375..f30b4ddb 100755 --- a/build/debian/make-deb.sh +++ b/build/debian/make-deb.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -147,8 +147,8 @@ then exit 1 fi -export ARG_BAZAAR_MSG="HSTR 3.1.0" -export ARG_VERSION="3.1.0" +export ARG_BAZAAR_MSG="HSTR 3.2.0" +export ARG_VERSION="3.2.0" # Debian releases: https://www.debian.org/releases/ # 6/7/8/9/10: squeeze wheezy jessie stretch buster diff --git a/build/debian/upload-to-mentors.sh b/build/debian/upload-to-mentors.sh index b2656a7d..f4b3af13 100755 --- a/build/debian/upload-to-mentors.sh +++ b/build/debian/upload-to-mentors.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/fedora/rpm-from-deb.sh b/build/fedora/rpm-from-deb.sh index 4efc5f2c..4feb4b4b 100755 --- a/build/fedora/rpm-from-deb.sh +++ b/build/fedora/rpm-from-deb.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -20,7 +20,7 @@ # This script is available from http://www.mindforger.com/fedora/fedora-rpm-from-deb.sh # to be easily available in VMs -export MFVERSION="3.1.0" +export MFVERSION="3.2.0" export MFPRJNAME="hstr-${MFVERSION}" export AMD64NAME="hstr_${MFVERSION}-1_amd64" export I386NAME="hstr_${MFVERSION}-1_i386" diff --git a/build/anigif-build.sh b/build/stop-motion-build.sh similarity index 91% rename from build/anigif-build.sh rename to build/stop-motion-build.sh index 4de18296..caac6bb9 100755 --- a/build/anigif-build.sh +++ b/build/stop-motion-build.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/anigif-create.sh b/build/stop-motion-create.sh similarity index 83% rename from build/anigif-create.sh rename to build/stop-motion-create.sh index 6187080e..36c53c76 100755 --- a/build/anigif-create.sh +++ b/build/stop-motion-create.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ do done` # delay: 100 > 75 -export CCC="convert -loop 0 -delay 75 ${FFF} hstr-v2.gif" +export CCC="convert -loop 0 -delay 75 ${FFF} hstr-stop-motion.gif" #echo ${CCC}; ${CCC} diff --git a/build/anigif-rename.sh b/build/stop-motion-rename.sh similarity index 92% rename from build/anigif-rename.sh rename to build/stop-motion-rename.sh index f06bb9f0..c4bce25c 100755 --- a/build/anigif-rename.sh +++ b/build/stop-motion-rename.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/tarball/tarball-automake.sh b/build/tarball/tarball-automake.sh index f326cba7..a6d1316c 100755 --- a/build/tarball/tarball-automake.sh +++ b/build/tarball/tarball-automake.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/tarball/tarball-build.sh b/build/tarball/tarball-build.sh index 04f4f8d0..e238d1d2 100755 --- a/build/tarball/tarball-build.sh +++ b/build/tarball/tarball-build.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ export SCRIPT_HOME=`pwd` -export HSTR_VERSION="3.1.0" +export HSTR_VERSION="3.2.0" export NOW=`date +%Y-%m-%d--%H-%M-%S` export GH_RELEASE_DIR=~/p/hstr/release @@ -30,7 +30,12 @@ export GH_DISTRO_DIR=${GH_RELEASE_DIR}/release-${NOW} function makeTarballRelease() { cp -vrf ${GH_SRC_DIR} . mv `basename ${GH_SRC_DIR}` hstr - cd hstr && rm -vrf debian doc test hstr && cd build/tarball && ./tarball-automake.sh --purge + + cd hstr && \ + rm -vrf debian doc test hstr .git .vscode .github .*~ web && \ + cd build/tarball && \ + ./tarball-automake.sh --purge + if [ ${?} -ne 0 ] then echo "ERROR: automake prepare phase failed" @@ -39,6 +44,7 @@ function makeTarballRelease() { cd ../../.. tar zcfv hstr-${HSTR_VERSION}-tarball.tgz hstr cd hstr && ./configure && make && cd src + strip hstr tar zcfv ../../hstr-${HSTR_VERSION}-bin-64b.tgz hstr } diff --git a/build/tarball/tarball-uninstall.sh b/build/tarball/tarball-uninstall.sh index d5f19120..c3eb43ce 100755 --- a/build/tarball/tarball-uninstall.sh +++ b/build/tarball/tarball-uninstall.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/test-clean.sh b/build/test-clean.sh index 25a24ebe..8cb5dd33 100755 --- a/build/test-clean.sh +++ b/build/test-clean.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/test-gdb.sh b/build/test-gdb.sh index 8010c238..f7afa528 100755 --- a/build/test-gdb.sh +++ b/build/test-gdb.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/test-generate-unity-test-runner.sh b/build/test-generate-unity-test-runner.sh index 3b0f5b1b..884f6e2a 100755 --- a/build/test-generate-unity-test-runner.sh +++ b/build/test-generate-unity-test-runner.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/test-memleaks.sh b/build/test-memleaks.sh index 99d2cd2c..25c4f90d 100755 --- a/build/test-memleaks.sh +++ b/build/test-memleaks.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,12 +16,13 @@ # Run HSTR w/ 1 history entry to hunt memleaks w/ valgrind -#export OPT_ALL_SCENARIOS=true +export OPT_ALL_SCENARIOS=true # both valid and INVALID history file to be tested #export HISTFILE= -export HISTFILE="/tmp/invalid-history-file-01" +#export HISTFILE="/tmp/invalid-history-file-01" #export HISTFILE="~/.bash_history" +export HISTFILE="~/.zsh_history" #export HISTFILE="~/.zhistory" #export HISTFILE="~/.zshrc" @@ -67,8 +68,9 @@ fi # run tests w/ Valgrind cat ${FILE_SCENARIOS} | while read SCENARIO do - # Valgrind - valgrind --track-origins=yes --tool=memcheck --leak-check=full --show-leak-kinds=all ${SCENARIO} + # Valgrind with ncurses suppressions + # valgrind --suppressions=build/valgrind-ncurses.supp --track-origins=yes --tool=memcheck --leak-check=full --show-leak-kinds=definite,possible ${SCENARIO} + valgrind --track-origins=yes --tool=memcheck --leak-check=full --show-leak-kinds=definite,possible ${SCENARIO} # Valgrind's GDB #valgrind --vgdb=yes --vgdb-error=0 --track-origins=yes --tool=memcheck --leak-check=full --show-leak-kinds=all ${SCENARIO} diff --git a/build/test-set-env-monster-history.sh b/build/test-set-env-monster-history.sh index 5a39ae4a..5c1897f3 100755 --- a/build/test-set-env-monster-history.sh +++ b/build/test-set-env-monster-history.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/test-set-env-utf8-history.sh b/build/test-set-env-utf8-history.sh index c36df868..ba0b1a34 100755 --- a/build/test-set-env-utf8-history.sh +++ b/build/test-set-env-utf8-history.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/test-units.sh b/build/test-units.sh index 981a02fd..8510cf81 100755 --- a/build/test-units.sh +++ b/build/test-units.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/travis-ci/.travis.yml b/build/travis-ci/.travis.yml index b1f68ac6..be24251d 100644 --- a/build/travis-ci/.travis.yml +++ b/build/travis-ci/.travis.yml @@ -1,6 +1,6 @@ # .travis.yml Travis CI configuration file for HSTR # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/ubuntu/debian/copyright b/build/ubuntu/debian/copyright index 07102089..1f52e500 100644 --- a/build/ubuntu/debian/copyright +++ b/build/ubuntu/debian/copyright @@ -3,7 +3,7 @@ Upstream-Name: hstr Source: https://github.com/dvorka/hstr Files: debian/* -Copyright: 2015 Martin Dvorak +Copyright: 2026 Martin Dvorak License: Apache Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/build/ubuntu/launchpad-add-hstr-ppa.sh b/build/ubuntu/launchpad-add-hstr-ppa.sh index 62f08281..f32d5e3d 100755 --- a/build/ubuntu/launchpad-add-hstr-ppa.sh +++ b/build/ubuntu/launchpad-add-hstr-ppa.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/ubuntu/launchpad-make-all-releases.sh b/build/ubuntu/launchpad-make-all-releases.sh index bbe699c8..715c794c 100755 --- a/build/ubuntu/launchpad-make-all-releases.sh +++ b/build/ubuntu/launchpad-make-all-releases.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,6 +33,107 @@ export HSTRSRC=/home/dvorka/p/hstr/github/hstr export HSTRRELEASEDIR=/home/dvorka/p/hstr/launchpad export SCRIPTHOME=`pwd` +# ############################################################################ +# # Check dependencies # +# ############################################################################ + +function checkDependencies() { + local missing_deps=() + local missing_config=() + + # check for required commands + if ! command -v bzr &> /dev/null; then + missing_deps+=("bzr/brz") + fi + + if ! command -v dput &> /dev/null; then + missing_deps+=("dput") + fi + + if ! command -v pbuilder-dist &> /dev/null; then + missing_deps+=("ubuntu-dev-tools") + fi + + if ! command -v debuild &> /dev/null; then + missing_deps+=("devscripts") + fi + + if ! dpkg -l debhelper &> /dev/null; then + missing_deps+=("debhelper") + fi + + # check for bzr-builddeb plugin (provided by brz-debian package as "debian" plugin) + if command -v bzr &> /dev/null; then + if ! bzr plugins 2>/dev/null | grep -q "debian"; then + missing_deps+=("brz-debian") + fi + + # check if bzr whoami is configured + if ! bzr whoami &> /dev/null; then + missing_config+=("bzr-whoami") + fi + fi + + # report missing dependencies + if [ ${#missing_deps[@]} -gt 0 ]; then + echo "ERROR: Missing required dependencies:" + for dep in "${missing_deps[@]}"; do + echo " - $dep" + done + echo "" + echo "To install all required packages, run:" + echo " sudo apt-get install brz bzr brz-debian dput ubuntu-dev-tools devscripts debhelper pbuilder" + exit 1 + fi + + # report missing configuration + if [ ${#missing_config[@]} -gt 0 ]; then + echo "ERROR: Missing required configuration:" + for cfg in "${missing_config[@]}"; do + case $cfg in + bzr-whoami) + echo " - Bazaar identity not set" + echo " Run: bzr whoami \"Your Name \"" + ;; + esac + done + exit 1 + fi + + # check for GPG key matching the debian maintainer email + local bzr_email=$(bzr whoami 2>/dev/null | grep -oP '<\K[^>]+') + if [ -n "$bzr_email" ]; then + if ! gpg --list-secret-keys "$bzr_email" &> /dev/null; then + missing_config+=("gpg-key") + fi + fi + + # report missing configuration (second check after GPG) + if [ ${#missing_config[@]} -gt 0 ]; then + echo "ERROR: Missing required configuration:" + for cfg in "${missing_config[@]}"; do + case $cfg in + gpg-key) + echo " - No GPG key found for: $bzr_email" + echo "" + echo " OPTION 1: Generate new GPG key:" + echo " gpg --full-generate-key" + echo " (Use: Martin Dvorak <$bzr_email>)" + echo "" + echo " OPTION 2: Import key from old machine:" + echo " On old machine: gpg --export-secret-keys $bzr_email > ~/gpg-key.asc" + echo " Transfer file securely, then: gpg --import ~/gpg-key.asc" + echo "" + echo " After creating/importing key:" + echo " - Upload to keyserver: gpg --keyserver keyserver.ubuntu.com --send-keys YOUR_KEY_ID" + echo " - Add to Launchpad: https://launchpad.net/~ultradvorka/+editpgpkeys" + ;; + esac + done + exit 1 + fi +} + # ############################################################################ # # Checkout HSTR from bazaar and make it # # ############################################################################ @@ -41,6 +142,21 @@ function checkoutHstr() { echo "Checking out HSTR from Bazaar to `pwd`" # Create new branch hstr-package: bzr init && bzr push lp:~ultradvorka/+junk/hstr-package bzr checkout lp:~ultradvorka/+junk/hstr-package + + if [ ! -d "hstr-package" ]; then + echo "" + echo "ERROR: Bazaar checkout failed! This is usually due to:" + echo " 1. SSH key not configured on Launchpad" + echo " 2. Launchpad login not configured (run: bzr launchpad-login ultradvorka)" + echo "" + echo "To fix SSH authentication:" + echo " 1. Generate SSH key: ssh-keygen -t rsa -b 4096" + echo " 2. Add to Launchpad: https://launchpad.net/~ultradvorka/+editsshkeys" + echo " 3. Configure bzr: bzr launchpad-login ultradvorka" + echo "" + exit 1 + fi + cd hstr-package && mv -v .bzr .. && rm -rvf *.* && mv -v ../.bzr . cp -rvf ${HSTRSRC}/* ${HSTRSRC}/*.* . cd .. @@ -131,7 +247,17 @@ function releaseForParticularUbuntuVersion() { export PBUILDFOLDER=/tmp/hstr-tmp rm -rvf ${PBUILDFOLDER} mkdir -p ${PBUILDFOLDER} - cp -rvf ~/pbuilder/*.tgz ${PBUILDFOLDER} + # copy pbuilder base tarball if it exists in ~/pbuilder/ + if [ -f ~/pbuilder/${UBUNTUVERSION}-base.tgz ]; then + cp -v ~/pbuilder/${UBUNTUVERSION}-base.tgz ${PBUILDFOLDER}/ + else + echo "ERROR: pbuilder base tarball not found: ~/pbuilder/${UBUNTUVERSION}-base.tgz" + echo "Please create it first by running:" + echo " pbuilder-dist ${UBUNTUVERSION} create" + echo " mkdir -p ~/pbuilder" + echo " sudo cp /var/cache/pbuilder/${UBUNTUVERSION}-base.tgz ~/pbuilder/" + # NON critital error: exit 1 + fi # END pbuilder-dist ${UBUNTUVERSION} build ${HSTRRELEASE}.dsc @@ -150,7 +276,9 @@ function releaseForParticularUbuntuVersion() { # # Main # # ############################################################################ -echo "This script is expected to be copied to and run from: ~/p/hstr/launchpad" +echo "IMPORTANT: make sure to login to Launchpad using 'bzr launchpad-login YOUR_LAUNCHPAD_ID' before running this script!" +echo "IMPORTANT: make sure your SSH key is configured on Launchpad: https://launchpad.net/~ultradvorka/+editsshkeys" +echo -e "This script is expected to be copied to and run from: ~/p/hstr/launchpad\n\n" if [ -e "../../.git" ] then @@ -163,18 +291,26 @@ then exit 1 fi -export ARG_BAZAAR_MSG="Release 3.1" -export ARG_MAJOR_VERSION=3.1. -export ARG_MINOR_VERSION=8 # minor version is incremented for every Ubuntu version +# check all required dependencies +checkDependencies + +export ARG_BAZAAR_MSG="Release 3.2" +export ARG_MAJOR_VERSION=3.2. +export ARG_MINOR_VERSION=10 # minor version is incremented for every Ubuntu version +# https://en.wikipedia.org/wiki/Ubuntu_version_history # https://wiki.ubuntu.com/Releases # obsolete: -# precise quantal saucy precise utopic vivid wily yakkety xenial artful cosmic disco eoan groovy hirsute impish +# precise quantal saucy precise utopic vivid wily yakkety xenial artful cosmic disco eoan groovy hirsute impish oracular plucky +# missed: +# oracular # current : -# trusty xenial bionic focal jammy noble +# trusty xenial bionic focal jammy noble . questing +# future: +# resolute # command : -# trusty xenial bionic focal jammy noble -for UBUNTU_VERSION in noble +# trusty xenial bionic focal jammy noble questing +for UBUNTU_VERSION in trusty xenial bionic focal jammy plucky questing do echo "Releasing HSTR for Ubuntu version: ${UBUNTU_VERSION}" releaseForParticularUbuntuVersion ${UBUNTU_VERSION} ${ARG_MAJOR_VERSION}${ARG_MINOR_VERSION} "${ARG_BAZAAR_MSG}" diff --git a/build/ubuntu/pbuilder-add-new-distro.sh b/build/ubuntu/pbuilder-add-new-distro.sh index 6f7f0e60..21334aeb 100755 --- a/build/ubuntu/pbuilder-add-new-distro.sh +++ b/build/ubuntu/pbuilder-add-new-distro.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,9 +17,9 @@ # https://wiki.ubuntu.com/Releases # boostrap new OR refresh distribution base for pbuilder -export DISTRO=impish +export DISTRO=bionic -sudo pbuilder --create $DISTRO +sudo pbuilder --create --distribution ${DISTRO} rm -vf ~/pbuilder/${DISTRO}-base.tgz cp /var/cache/pbuilder/base.tgz ~/pbuilder/${DISTRO}-base.tgz diff --git a/build/ubuntu/pbuilder-refresh-all-distros.sh b/build/ubuntu/pbuilder-refresh-all-distros.sh index 723d9d66..31353bc1 100755 --- a/build/ubuntu/pbuilder-refresh-all-distros.sh +++ b/build/ubuntu/pbuilder-refresh-all-distros.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,10 +17,12 @@ # https://wiki.ubuntu.com/Releases # obsolete: precise quantal saucy precise utopic vivid wily yakkety artful cosmic # current : (trusty) xenial bionic (cosmic disco eoan) focal (groovy) hirsute impish -for DISTRO in xenial bionic focal hirsute impish +for DISTRO in trusty xenial bionic focal jammy noble questing do -sudo pbuilder --create ${DISTRO} +sudo pbuilder --create --distribution ${DISTRO} +rm -vf ~/pbuilder/${DISTRO}-base.tgz +cp /var/cache/pbuilder/base.tgz ~/pbuilder/${DISTRO}-base.tgz done diff --git a/check-bash-lab-experiments b/check-bash-lab-experiments deleted file mode 100644 index e69de29b..00000000 diff --git a/configure.ac b/configure.ac index 9241d980..996720d2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # configure.ac Autoconf configuration file # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/doc/USER-DOCUMENTATION.md b/doc/USER-DOCUMENTATION.md index d1d861d0..c8564805 100644 --- a/doc/USER-DOCUMENTATION.md +++ b/doc/USER-DOCUMENTATION.md @@ -16,7 +16,7 @@ Table of contents: * Blacklist * Delete last command * Examples - + # Features HSTR is typically started by pressing Ctrl-r after you configure it for this shorcut in your shell. However, @@ -33,18 +33,18 @@ hh ``` It opens a page with a history view (ranking view is default). -Alternatively you can run HSTR in non-interactive mode - +Alternatively you can run HSTR in non-interactive mode - commands are just listed on standard output based on history view: ```bash -hh --non-interactive +hstr --non-interactive ``` Filtering pattern can be optionally specified as well: ```bash -hh -i git +hstr -i git ``` Prints history items containing `git` to standard output and @@ -67,13 +67,13 @@ items is highlighted. Once you are done with your choice: ## Favorite Commands -HSTR allows you to store and manage your favorite -commands. +HSTR allows you to store and manage your favorite +commands. A new favorite command can be added from ranking or raw history view by pressing Ctrl-f. -You can check your favorite commands by choosing +You can check your favorite commands by choosing favorite view - rotate views using Ctrl-/ or start HSTR by adding `favorites-view` to `HSTR_CONFIG` environment property. A favorite command can be choosen just @@ -104,8 +104,8 @@ printf "\e[?2004l" # fix broken copy/paste in terminal #TERM ## Blacklist HSTR allows you to specify a set of commands to be skipped from all the views. Blacklist typically contains -frequently used commands whose completion from history -has a little or no value. The default blacklist looks +frequently used commands whose completion from history +has a little or no value. The default blacklist looks like this: ```bash @@ -125,7 +125,7 @@ Tips: * You can skip any command from history just by prefixing it with `SPACE`. For example: ` echo "Skip this from history"` It's a `bash` - option that is configured using + option that is configured using `HISTCONTROL=ignorespace` environment variable. @@ -148,24 +148,23 @@ Get more colors when running HSTR: export HSTR_CONFIG=hicolor ``` -Start HSTR in configured view and filter out history items -containing 'git' (make sure `hh` is defined using -[alias](../CONFIGURATION.md#alias)): +Start HSTR in configured view and filter out history items +containing 'git': ```bash -hh git +hstr git ``` Print history items containing 'git' to standard output and exit: ```bash -hh --non-interactive git +hstr --non-interactive git ``` -Append default `hh` configuration to your `bash` profile: +Append default `hstr` configuration to your `bash` profile: ```bash -hh --show-configuration >> ~/.bashrc +hstr --show-configuration >> ~/.bashrc ``` Check HSTR man page: diff --git a/etc/bash-completion.d/hstr b/etc/bash-completion.d/hstr index e9351536..c7412543 100755 --- a/etc/bash-completion.d/hstr +++ b/etc/bash-completion.d/hstr @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ _hstr() esac case $cur in -*) - OPTS="--favorites --kill-last-command --non-interactive --show-configuration --show-zsd-configuration --show-blacklist --version --help" + OPTS="--favorites --kill-last-command --non-interactive --show-configuration --show-bash-configuration --show-zsh-configuration --show-blacklist --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; diff --git a/hstr.pro b/hstr.pro index 00024e05..32852a6a 100644 --- a/hstr.pro +++ b/hstr.pro @@ -1,6 +1,6 @@ # hstr.pro Qt project file for HSTR shell history completion utility # -# Copyright (C) 2014-2025 Martin Dvorak +# Copyright (C) 2014-2026 Martin Dvorak # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/man/hstr.1 b/man/hstr.1 index aed57b84..caa1bdb2 100644 --- a/man/hstr.1 +++ b/man/hstr.1 @@ -1,35 +1,35 @@ .TH HSTR 1 .SH NAME -\fBhstr\fR \- easily view, navigate, sort and use your command history with shell history suggest box. +\fBhstr\fR \- easily view, navigate, sort and use your command history with a shell history suggest box. .SH SYNOPSIS .B hstr [option] [arg1] [arg2]... .SH DESCRIPTION .B hstr 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 +for commands used in the past. By default it parses the .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 occurrences, length and timestamp. +that considers the number of occurrences, length and timestamp. Favorite and frequently used commands can be bookmarked. In addition -\fBhstr\fR allows removal of commands from history - for instance with a typo -or with a sensitive content. +\fBhstr\fR allows removal of commands from history - for instance with a typo +or with sensitive content. .SH OPTIONS -.TP +.TP \fB-h --help\fR Show help -.TP +.TP \fB-n --non-interactive\fR Print filtered history on standard output and exit -.TP +.TP \fB-k --kill-last-command\fR Delete the last command from history and exit -.TP +.TP \fB-i --insert-in-terminal=[command]\fR -Insert custom command to terminal prompt and exit +Insert custom command in terminal prompt and exit .TP \fB-f --favorites\fR Show favorites view immediately -.TP +.TP \fB-s --show-configuration\fR Show configuration to be added to the config file of the shell (~/.bashrc or ~/.zshrc) .TP @@ -65,17 +65,17 @@ Add currently selected command to favorites. Toggle search pattern case. .TP \fBCtrl\-r\fR, \fBUP\fR arrow, \fBDOWN\fR arrow, \fBCtrl\-n\fR, \fBCtrl\-p\fR, \fBCtrl\-j\fR, \fBCtrl\-k\fR -Navigate in the history list. +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. +Choose currently selected item for completion and let user 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). +Choose currently selected item for completion and let user edit it in editor (fix command). .TP \fBENTER\fR Choose currently selected item for completion and execute it. -.TP +.TP \fBDEL\fR Remove currently selected item from the shell history. .TP @@ -96,17 +96,17 @@ Exit with empty prompt. \fBHSTR_CONFIG\fR Configuration options: -\fIhicolor\fR +\fIhicolor\fR Get more colors with this option (default is monochromatic). -\fImonochromatic\fR +\fImonochromatic\fR Ensure black and white view. \fIprompt-bottom\fR Show prompt at the bottom of the screen (default is prompt at the top). \fIhelp-on-opposite-side\fR - Show help label on the opposite site (default is next to the prompt). + Show help label on the opposite side (default is next to the prompt). \fIhide-basic-help\fR Hide the basic help label. @@ -118,7 +118,7 @@ Configuration options: Do not ask for confirmation on a history entry delete (default is with confirmation). \fIregexp-matching\fR - Filter command history using regular expressions. + Filter command history using regular expressions. \fIsubstring-matching\fR Filter command history using substring. @@ -127,10 +127,10 @@ Configuration options: Filter command history using keywords - item matches if contains all keywords in pattern in any order (keywords match is default). \fIcase-sensitive\fR - Make history filtering case sensitive (it's case insensitive by default). + Make history filtering case sensitive (it's case insensitive by default). \fIraw-history-view\fR - Show normal history as a default view (metric-based view is shown otherwise). + Show normal history as a default view (metric-based view is shown otherwise). \fIfavorites-view\fR Show favorites as a default view (metric-based view is shown otherwise). @@ -142,10 +142,10 @@ Configuration options: Skip comments (lines beginning with #) when loading ~/.hstr_favorites (all lines are loaded by default). \fIduplicates\fR - Show duplicates in rawhistory (duplicates are discarded by default). + Show duplicates in raw history (duplicates are discarded by default). \fIverbose-kill\fR - Print the last command command deleted from history (nothing is printed by default). + Print the last command deleted from history (nothing is printed by default). \fIblacklist\fR Load list of commands to skip when processing history from ~/.hstr_blacklist (built-in blacklist used otherwise). @@ -180,10 +180,10 @@ Example: .SH FILES .TP -\fB~/.hstr_favorites\fR +\fB~/.hstr_favorites\fR Bookmarked favorite commands. .TP -\fB~/.hstr_blacklist\fR +\fB~/.hstr_blacklist\fR Commands to be hidden. .SH BASH CONFIGURATION @@ -199,8 +199,7 @@ export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500) # ensure synchronization between bash memory and history file export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" function hstrnotiocsti { - { HSTR_OUT="$( { &1 1>&3 3>&- )"; } 3>&1; - READLINE_LINE="$(hstr ${READLINE_LINE})" + { READLINE_LINE=\"$( { &1 1>&3 3>&- )\"; } 3>&1; READLINE_POINT=${#READLINE_LINE} } # if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc) @@ -232,7 +231,7 @@ setopt histignorespace # skip cmds w/ leading space from history export HSTR_CONFIG=hicolor # get more colors hstr_no_tiocsti() { zle -I - { HSTR_OUT="$( { &1 1>&3 3>&- )"; } 3>&1; + { HSTR_OUT="$( { &1 1>&3 3>&- )"; } 3>&1; BUFFER="${HSTR_OUT}" CURSOR=${#BUFFER} zle redisplay diff --git a/pad.xml b/pad.xml index 9e7d99ad..b1cb5621 100644 --- a/pad.xml +++ b/pad.xml @@ -2,7 +2,7 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/web/hstr-stop-motion.gif b/web/hstr-stop-motion.gif new file mode 100644 index 00000000..35948e2b Binary files /dev/null and b/web/hstr-stop-motion.gif differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 00000000..207d19cf --- /dev/null +++ b/web/index.html @@ -0,0 +1,837 @@ + + + + + + HSTR - Bash and Zsh Shell History Suggest Box + + + + + + + +
+
+
+

HSTR

+

+ Bash and Zsh shell history suggest box - easily view, navigate and search your command history + with shell history completion that's faster and more efficient than Ctrl-r. +

+ +
+
+
+
+
+
+
+ HSTR Demo +
+
+
+
+ +
+
+ +

Why HSTR?

+
+
+
*
+

Intelligent History Search

+

+ Search your command history with keywords, regular expressions, or substring matching. + HSTR provides multiple search modes to find exactly what you need, when you need it. +

+
+
+
*
+

Metrics-Based Ranking

+

+ HSTR automatically ranks commands based on usage frequency and recency. + Your most important commands are always at your fingertips. +

+
+
+
*
+

Favorite Commands

+

+ Bookmark your favorite commands for instant access. Perfect for complex commands + you use regularly but can't quite remember. +

+
+
+
*
+

History Management

+

+ Delete obsolete commands or remove sensitive information from your history. + Full control over your command history database. +

+
+
+
*
+

Multiple Views

+

+ Switch between ranked history, raw chronological view, and favorites. + Each view is optimized for different workflows. +

+
+
+
*
+

Bash & Zsh Support

+

+ Works seamlessly with both bash and zsh. Easy configuration with + automatic shell detection and setup scripts. +

+
+
+
*
+

Case-Insensitive Search

+

+ Search without worrying about capitalization. HSTR's intelligent + case-insensitive search finds what you need regardless of how you type it. +

+
+
+
*
+

Customizable Interface

+

+ Configure colors, prompt position, help visibility, and more. + Make HSTR look and behave exactly how you want it. +

+
+
+
*
+

Cross-Platform

+

+ Available on Linux, macOS, BSD, and more. Install via package managers + or build from source on virtually any Unix-like system. +

+
+
+
+
+ +
+
+ +

Installation

+
+
+

Ubuntu/Debian

+ sudo apt install hstr +
+
+

Fedora/RHEL/CentOS

+ sudo dnf install hstr +
+
+

macOS (Homebrew)

+ brew install hstr +
+
+

Arch Linux

+ yaourt -S hstr-git +
+
+

Build from Source

+ git clone https://github.com/dvorka/hstr.git
+cd hstr/build/tarball
+./tarball-automake.sh
+cd ../..
+./configure && make
+sudo make install
+
+
+

Configure

+ # Bash
+hstr --show-bash-configuration >> ~/.bashrc
+source ~/.bashrc
+
+# Zsh
+hstr --show-zsh-configuration >> ~/.zshrc
+source ~/.zshrc
+
+
+
+
+ +
+
+ +

Get the Most Out of HSTR

+
+
+

Command Tagging

+

Add comments to commands for easy searching:

+
docker run -it ubuntu bash # DDD
+ssh -L 8080:localhost:3000 user@server # SSS
+git log --graph --oneline # GGG
+

Just type "DDD" in HSTR to find your Docker commands instantly!

+
+
+

Hide Sensitive Commands

+

Prevent commands from being saved to history:

+
# Bash
+export HISTCONTROL=ignorespace
+
+# Zsh
+setopt HIST_IGNORE_SPACE
+
+# Now use a leading space:
+ secret-command --password=123
+
+
+

Keyboard Shortcuts

+

Master HSTR with these shortcuts:

+
Ctrl-r     - Invoke HSTR
+Ctrl-/     - Toggle views
+Ctrl-f     - Add to favorites
+Ctrl-t     - Toggle case sensitivity
+Ctrl-e     - Edit command
+DEL        - Delete from history
+
+
+

Customize Appearance

+

Configure HSTR to match your style:

+
export HSTR_CONFIG=hicolor,prompt-bottom
+
+# Options include:
+# - hicolor / monochromatic
+# - prompt-bottom
+# - hide-help
+# - raw-history-view
+# - favorites-view
+
+
+

Increase History Size

+

Store more commands in your history:

+
export HISTFILESIZE=10000
+export HISTSIZE=${HISTFILESIZE}
+shopt -s histappend
+
+
+

Blacklist Commands

+

Exclude commands from ranking view:

+
export HSTR_CONFIG=blacklist
+
+# Create ~/.hstr_blacklist:
+cd
+ls
+pwd
+exit
+
+
+
+
+ +
+
+ +

HSTR: History on Steroids

+
+

+ HSTR (HiSToRy) is a command line utility that brings improved bash/zsh command completion + from the history. It aims to make completion easier and more efficient than the built-in Ctrl-r. +

+

+ Are you looking for a command that you used recently? Do you want to avoid the need to write + long commands over and over again? Are you looking for a tool that is able to manage your + favorite commands? HSTR is the answer. +

+

+ HSTR can also manage your command history - for instance you can remove commands that are + obsolete or contain a piece of sensitive information, or bookmark your favorite commands. +

+
+
+
10+
+
Years Active
+
+
+
4k+
+
GitHub Stars
+
+
+
15+
+
Platforms
+
+
+
+
+
+ + + +