Skip to content

feat(input): ✨ introducing stdin support allowing to read and search any input #235 #539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev-3.2.0
Choose a base branch
from

Conversation

dvorka
Copy link
Owner

@dvorka dvorka commented May 18, 2025

This PR adds ability of HSTR to read input from pipe - just for inspiration:

git log --pretty=format:%s | hstr
find | hstr
ps aux | hstr
cat /var/log/nginx/access.log | hstr
grep phrase . | hstr
cat data.csv | hstr
netstat -tulpn | hstr
kubectl logs mypod | hstr

@dvorka dvorka requested a review from Copilot May 18, 2025 19:14
@dvorka dvorka self-assigned this May 18, 2025
@dvorka dvorka linked an issue May 18, 2025 that may be closed by this pull request
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces stdin support for HSTR, allowing the utility to read input from a pipe and enable searching of piped data. Key changes include updating function signatures (e.g., fill_terminal_input and prioritized_history_create) to accept additional parameters such as file descriptors and history state, and modifying curses initialization to handle tty reading when input is piped.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/include/hstr_utils.h Updated fill_terminal_input signature to include file descriptor parameter.
src/include/hstr_history.h Added HISTORY_STATE parameter to prioritized_history_create.
src/include/hstr_curses.h Modified hstr_curses_start to accept a tty initialization flag and return a FILE*.
src/hstr_utils.c Adjusted fill_terminal_input implementation to use the new file descriptor parameter.
src/hstr_history.c Updated prioritized_history_create to support an external history state.
src/hstr_curses.c Updated curses initialization logic to conditionally use /dev/tty when reading from pipe.
src/hstr.c Updated main loop and interactive functions to support pipe input and pass the correct fd.
pad.xml, hstr.pro, build scripts Bumped version numbers and updated build scripts accordingly.
README.md Added package information.
Comments suppressed due to low confidence (1)

src/hstr.c:1728

  • The code closes stdin after processing piped history input, which may be problematic if further standard input operations are expected; double-check that this behavior is intended.
fclose(fp);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve HSTR to read input from pipe
1 participant