feat: clipboard import + bash/fish shell support#6
Conversation
Clipboard import: `mem import` with no file reads from the system clipboard, auto-detects JSON/markdown format and group name, and confirms before importing. The -g flag overrides the detected name. Shell hooks: `mem init bash` and `mem init fish` now emit working hooks instead of the "coming in v1.5" error. Bash uses trap DEBUG + PROMPT_COMMAND; fish uses the native fish_postexec event. Refactors import_from_json/markdown into string-based _str variants that return (detected_name, commands), with the file-based functions as thin wrappers.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 023ed9ca49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _mem_debug_trap() { | ||
| if [[ -z "$_mem_capturing" && -n "$BASH_COMMAND" ]]; then | ||
| _mem_capturing=1 | ||
| _mem_cmd="$(HISTTIMEFORMAT= history 1 | sed 's/^[ ]*[0-9]*[ ]*//')" |
There was a problem hiding this comment.
Capture actual command instead of relying on history entry
Using history 1 here records the last persisted history item rather than the command that just triggered DEBUG, so in common Bash setups like HISTCONTROL=ignorespace/HISTIGNORE (or when history is disabled) the hook stores a stale previous command. I reproduced this in an interactive Bash session: running a leading-space command resulted in the prior command being captured again, which corrupts mem history and downstream pattern extraction.
Useful? React with 👍 / 👎.
history 1 returns the last persisted history entry, not the command that triggered DEBUG. With HISTCONTROL=ignorespace or HISTIGNORE, it silently captures a stale previous command. $BASH_COMMAND is always the actual command being executed. Trade-off: pipelines (a | b | c) capture only the first simple command.
13 importable runbooks across 6 categories: - security: recon, headers-audit, ssl-audit - devops: docker-cleanup, k8s-debug, incident-response - git: forensics, cleanup - networking: network-debug, dns-debug - performance: system-profile - databases: postgres-debug, redis-ops All use $VARIABLES for mem run integration and are in mem export format for clipboard import.
Clipboard import:
mem importwith no file reads from the system clipboard, auto-detects JSON/markdown format and group name, and confirms before importing. The -g flag overrides the detected name.Shell hooks:
mem init bashandmem init fishnow emit working hooks instead of the "coming in v1.5" error. Bash uses trap DEBUG + PROMPT_COMMAND; fish uses the native fish_postexec event.Refactors import_from_json/markdown into string-based _str variants that return (detected_name, commands), with the file-based functions as thin wrappers.