aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/hgrep.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bashrc.d/hgrep.bash')
-rw-r--r--bash/bashrc.d/hgrep.bash9
1 files changed, 9 insertions, 0 deletions
diff --git a/bash/bashrc.d/hgrep.bash b/bash/bashrc.d/hgrep.bash
new file mode 100644
index 00000000..0c31a213
--- /dev/null
+++ b/bash/bashrc.d/hgrep.bash
@@ -0,0 +1,9 @@
+# Search shell history file for a pattern. If you put your whole HISTFILE
+# contents into memory, then you probably don't need this, as you can just do:
+#
+# $ history | grep PATTERN
+#
+hgrep() {
+ grep -- "${@:?}" "${HISTFILE:?}"
+}
+