Skip to content

Commit 939078e

Browse files
committed
Merge branch 'history' into v6 [#146, pr #152]...
- #146 - #152
2 parents 7255242 + cfb75ad commit 939078e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/abbr-history.ztr.zsh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env zsh
2+
3+
main() {
4+
emulate -LR zsh
5+
6+
ztr skip '@TODO' 'When ABBR_PUSH_HISTORY == 1, abbreviations are included in history'
7+
}
8+
9+
main

zsh-abbr.zsh

+11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ typeset -gi ABBR_LOG_AVAILABLE_ABBREVIATION_AFTER=${ABBR_LOG_AVAILABLE_ABBREVIAT
4747
# deprecated
4848
typeset -gi ABBR_PRECMD_LOGS=${ABBR_PRECMD_LOGS:-1}
4949

50+
# Should abbr-expand-and-accept push the unexpanded line to the shell history? (default false)
51+
# If true, if abbr-expand-and-accept expands an abbreviation there will be two history entries:
52+
# the first is what was typed (with the abbreviation), the second is what was run (with the expansion).
53+
typeset -gi ABBR_PUSH_HISTORY=${ABBR_PUSH_HISTORY:-0}
54+
5055
# Behave as if `--quiet` was passed? (default false)
5156
typeset -gi ABBR_QUIET=${ABBR_QUIET:-0}
5257

@@ -1638,11 +1643,17 @@ abbr-expand-and-accept() {
16381643

16391644
# do not support debug message
16401645

1646+
local buffer
1647+
16411648
local trailing_space
16421649
trailing_space=${LBUFFER##*[^[:IFSSPACE:]]}
16431650

16441651
if [[ -z $trailing_space ]]; then
1652+
buffer=$BUFFER
1653+
16451654
zle abbr-expand
1655+
1656+
(( ABBR_PUSH_HISTORY )) && [[ $buffer != $BUFFER ]] && print -s $buffer
16461657
fi
16471658

16481659
_abbr_accept-line

0 commit comments

Comments
 (0)