Comments (2)
That's already possible in Zsh natively. You have three options for this, all of which can be combined:
- Add
setopt HIST_IGNORE_SPACE
to your.zshrc
file. Then, if you insert at least one space at the very beginning of a command line, it will not be saved to history, although it is still saved to local history in memory. - Add
HISTORY_IGNORE=<glob pattern
to your.zshrc
file. Then, any command line that matches that pattern will not be saved to history. - Add a history hook function to your
.zshrc
file:Then, whenever you submit a command line, before it is executed, it will be passed to this function. If the function returnsautoload -Uz <function>() { <logic> } add-zsh-hook zshaddhistory <function>
1
, it will not be saved. If it returns2
, it will be saved to local history in memory, but will not be saved to the$HISTFILE
. Returning0
will save the command line to history, unless prevented by one of the other two options.
from zsh-hist.
@marlonrichert Thank you for the detailed explanation, it makes sense to do it this way. Very useful.
from zsh-hist.
Related Issues (18)
- Commands drawn from history cannot be executed. HOT 3
- Problems with unicode characters HOT 3
- Select multiple history entries HOT 3
- How to do a big-time auto format in place?
- TODO: Add installation instructions
- Regex `\b` replaced with `^H` in multi-line command HOT 2
- Plugin no longer working as expected after recent changes HOT 5
- Make plugin work with per-directory-history too, not just global history HOT 2
- ^Q unavailable in vi command mode
- hist: warning: $HISTSIZE should be at least 20% larger than $SAVEHIST HOT 1
- The term "undo" is used twice HOT 4
- Widgets are not found anymore HOT 4
- Aliases are automatically expanded before the command is executed HOT 16
- Code formatting ignores HIST_IGNORE_SPACE HOT 3
- Command line prepended with tab character. HOT 13
- History line autocompletion not working. HOT 1
- History line tab-completion not working. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zsh-hist.