C command-line utility for snippet management and terminal command ingestion.
- Dual-Layer Execution Pipeline: Attempts direct terminal keystroke injection via low-level system
ioctlcalls. - Silent Clipboard Fallback: Automatically switches to an invisible
xclipdaemon pipeline if kernel protections block physical injection. - Dynamic File Parsing: Zero-allocation line streaming allows you to jump directly to any selected line index instantly.
- Persistent Storage: Safely creates, appends, and queries shell commands directly within a flat asset payload (
snippets.txt).
./nih -s./nih -w -- 'echo "Hello World" && sudo apt update'./nih -l./nih -p 3./nihWhen saving a command string that includes system redirections, pipe mechanics, globbing wildcards, or logical chains, you must envelop the entire string payload within single quotes ('):
./nih -w -- 'du -sh * | sort -h'The active Bash shell evaluates operators like the pipeline (|) before passing tokens down to the destination binary. Without strict quote constraints, your shell will intercept the statement prematurely, attempting to pipe the internal execution states of ./nih into subsequent operations. Single quotes completely dearm these control sequences, converting them into a harmless literal text stream.
If your snippet requires an inner single quote string literal, step out of the expression block, append an escaped quote sequence, and restart the literal tracking block immediately:
./nih -w -- 'echo '\''Hello World'\'''When writing a snippet that contains nested execution flags, place a detached double-dash prefix sequence (--) before writing your instruction data block:
./nih -w -- ls -la --color=always /var/logThe underlying POSIX standard getopt parser automatically concludes flag lookups the exact moment it meets a standalone -- operator. If this guard sequence is excluded, any subsequent token beginning with a dash parameter (such as -la or --color) will be mistakenly intercepted by getopt as configuration directives native to ./nih itself, resulting in unexpected syntax errors.
Compile the codebase using gcc, linking both the base ncurses runtime engine and the top-tier cdk abstraction toolkit libraries:
gcc nih2.c nih.c -o nih -lcdk -lncursesor just use makefile.
ncurses and cdk
for easier use (if you want the tool to automatically insert commands onto the cursor in terminal, you have to enable this by default blocked kernel parameter:
sudo sysctl -w dev.tty.legacy_tiocsti=1if you choose not to tool will work just fine,but it will copy to your clipboard instead of terminal