mirror of
https://github.com/dvorka/hstr.git
synced 2025-02-20 21:04:12 +08:00
Add comments about zsh history item format.
This commit is contained in:
parent
3e118156ce
commit
255ada9cac
3 changed files with 24 additions and 14 deletions
|
@ -6,7 +6,7 @@ hh --show-configuration >> ~/.bashrc
|
|||
```
|
||||
Run `hh --show-configuration` to determine what will be appended to your BASH profile.
|
||||
|
||||
This document describes `hh` related configuration in detail -
|
||||
This document describes `hh` related configuration in detail -
|
||||
[binding hh to a keyboard shortcut](#binding-hh-to-keyboard-shortcut),
|
||||
[colors](#colors),
|
||||
[default history view](#history-view),
|
||||
|
@ -35,7 +35,7 @@ Bind `hh` to `Ctrl-r` only if it is interactive shell:
|
|||
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh \C-j"'; fi
|
||||
```
|
||||
|
||||
To determine the character sequence emitted by a pressed key in terminal,
|
||||
To determine the character sequence emitted by a pressed key in terminal,
|
||||
type `Ctrl-v` and then press the key. Check your current bindings using:
|
||||
```bash
|
||||
bind -S
|
||||
|
@ -101,20 +101,20 @@ BASH HISTORY SETTINGS
|
|||
---------------------
|
||||
Use the following BASH settings to get most out of `hh`.
|
||||
|
||||
Increase the size of history maintained by BASH - variables defined below increase the
|
||||
Increase the size of history maintained by BASH - variables defined below increase the
|
||||
number of history items and history file size (default value is 500):
|
||||
```bash
|
||||
export HISTFILESIZE=10000
|
||||
export HISTSIZE=${HISTFILESIZE}
|
||||
```
|
||||
Ensure syncing (flushing and reloading) of `.bash_history` with in-memory
|
||||
Ensure syncing (flushing and reloading) of `.bash_history` with in-memory
|
||||
history:
|
||||
```bash
|
||||
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
|
||||
```
|
||||
|
||||
Force appending of in-memory history to `.bash_history`
|
||||
(instead of overwriting):
|
||||
Force appending of in-memory history to `.bash_history`
|
||||
(instead of overwriting):
|
||||
```bash
|
||||
shopt -s histappend
|
||||
```
|
||||
|
@ -124,3 +124,11 @@ Use leading space to hide commands from history:
|
|||
export HISTCONTROL=ignorespace
|
||||
```
|
||||
Suitable for a sensitive information like passwords.
|
||||
|
||||
ZSH HISTORY SETTINGS
|
||||
--------------------
|
||||
If you use zsh, set HISTFILE environment variable in ~/.zshrc:
|
||||
|
||||
```
|
||||
export HISTFILE=~/.zsh_history
|
||||
```
|
||||
|
|
|
@ -108,12 +108,4 @@ Finish the installation
|
|||
make && make install
|
||||
```
|
||||
|
||||
ZSH
|
||||
___
|
||||
Set HISTFILE environment variable in ~/.zshrc:
|
||||
|
||||
```
|
||||
export HISTFILE=~/.zsh_history
|
||||
```
|
||||
|
||||
Optionally [configure](CONFIGURATION.md) `hh` and check its [man page](README.md#documentation).
|
||||
|
|
|
@ -79,6 +79,8 @@ HistoryItems *get_prioritized_history()
|
|||
HISTORY_STATE *historyState=history_get_history_state();
|
||||
|
||||
int itemOffset = 0;
|
||||
|
||||
// If user use zsh, the name of history file is .zsh_history
|
||||
char* zshFileName = ".zsh_history";
|
||||
int historyFileLen = strlen(historyFile);
|
||||
int zshFileNameLen = strlen(zshFileName);
|
||||
|
@ -90,6 +92,14 @@ HistoryItems *get_prioritized_history()
|
|||
}
|
||||
}
|
||||
if (i == historyFileLen) {
|
||||
// In zsh history file, the format of item is
|
||||
// [:][blank][unix_timestamp][:][0][;][cmd]
|
||||
// Such as:
|
||||
// : 1420549651:0;ls /tmp/b
|
||||
// : 1420549680:0;touch /tmp/c
|
||||
// : 1420549686:0;ln -s /tmp/c /tmp/b
|
||||
// And the limit of unix timestamp 9999999999 is 2289/11/21,
|
||||
// so we could skip first 15 chars in every zsh history item to get the cmd.
|
||||
itemOffset = ZSH_HISTORY_ITEM_OFFSET;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue