Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
79cf4b3c
Unverified
Commit
79cf4b3c
authored
Nov 10, 2019
by
Michael Peick
Committed by
Marc Cornellà
Nov 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(dirhistory): support urxvt terminal key binding (#8370)
Closes #8370
parent
7f494944
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
dirhistory.plugin.zsh
plugins/dirhistory/dirhistory.plugin.zsh
+21
-9
No files found.
plugins/dirhistory/dirhistory.plugin.zsh
View file @
79cf4b3c
##
##
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
#
#
# Navigate directory hierarchy using ALT-UP and ALT-DOWN.
# Navigate directory hierarchy using ALT-UP and ALT-DOWN.
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order
# ALT-DOWN moves into the first directory found in alphabetical order
...
@@ -14,8 +14,8 @@ export dirhistory_future
...
@@ -14,8 +14,8 @@ export dirhistory_future
export
DIRHISTORY_SIZE
=
30
export
DIRHISTORY_SIZE
=
30
# Pop the last element of dirhistory_past.
# Pop the last element of dirhistory_past.
# Pass the name of the variable to return the result in.
# Pass the name of the variable to return the result in.
# Returns the element if the array was not empty,
# Returns the element if the array was not empty,
# otherwise returns empty string.
# otherwise returns empty string.
function
pop_past
()
{
function
pop_past
()
{
...
@@ -32,7 +32,7 @@ function pop_future() {
...
@@ -32,7 +32,7 @@ function pop_future() {
fi
fi
}
}
# Push a new element onto the end of dirhistory_past. If the size of the array
# Push a new element onto the end of dirhistory_past. If the size of the array
# is >= DIRHISTORY_SIZE, the array is shifted
# is >= DIRHISTORY_SIZE, the array is shifted
function
push_past
()
{
function
push_past
()
{
if
[[
$#dirhistory_past
-ge
$DIRHISTORY_SIZE
]]
;
then
if
[[
$#dirhistory_past
-ge
$DIRHISTORY_SIZE
]]
;
then
...
@@ -76,7 +76,7 @@ function dirhistory_back() {
...
@@ -76,7 +76,7 @@ function dirhistory_back() {
local
d
=
""
local
d
=
""
# Last element in dirhistory_past is the cwd.
# Last element in dirhistory_past is the cwd.
pop_past cw
pop_past cw
if
[[
""
==
"
$cw
"
]]
;
then
if
[[
""
==
"
$cw
"
]]
;
then
# Someone overwrote our variable. Recover it.
# Someone overwrote our variable. Recover it.
dirhistory_past
=(
$PWD
)
dirhistory_past
=(
$PWD
)
...
@@ -129,6 +129,9 @@ case "$TERM_PROGRAM" in
...
@@ -129,6 +129,9 @@ case "$TERM_PROGRAM" in
iTerm.app
)
bindkey
"^[^[[D"
dirhistory_zle_dirhistory_back
;;
# iTerm2
iTerm.app
)
bindkey
"^[^[[D"
dirhistory_zle_dirhistory_back
;;
# iTerm2
Apple_Terminal
)
bindkey
"^[b"
dirhistory_zle_dirhistory_back
;;
# Terminal.app
Apple_Terminal
)
bindkey
"^[b"
dirhistory_zle_dirhistory_back
;;
# Terminal.app
esac
esac
if
((
${
+terminfo[kcub1]
}
))
;
then
bindkey
"^[
${
terminfo
[kcub1]
}
"
dirhistory_zle_dirhistory_back
# urxvt
fi
zle
-N
dirhistory_zle_dirhistory_future
zle
-N
dirhistory_zle_dirhistory_future
bindkey
"
\e
[3C"
dirhistory_zle_dirhistory_future
# xterm in normal mode
bindkey
"
\e
[3C"
dirhistory_zle_dirhistory_future
# xterm in normal mode
...
@@ -139,11 +142,14 @@ case "$TERM_PROGRAM" in
...
@@ -139,11 +142,14 @@ case "$TERM_PROGRAM" in
iTerm.app
)
bindkey
"^[^[[C"
dirhistory_zle_dirhistory_future
;;
# iTerm2
iTerm.app
)
bindkey
"^[^[[C"
dirhistory_zle_dirhistory_future
;;
# iTerm2
Apple_Terminal
)
bindkey
"^[f"
dirhistory_zle_dirhistory_future
;;
# Terminal.app
Apple_Terminal
)
bindkey
"^[f"
dirhistory_zle_dirhistory_future
;;
# Terminal.app
esac
esac
if
((
${
+terminfo[kcuf1]
}
))
;
then
bindkey
"^[
${
terminfo
[kcuf1]
}
"
dirhistory_zle_dirhistory_future
# urxvt
fi
#
#
# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings
# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings
#
#
# Move up in hierarchy
# Move up in hierarchy
function
dirhistory_up
()
{
function
dirhistory_up
()
{
...
@@ -178,6 +184,9 @@ case "$TERM_PROGRAM" in
...
@@ -178,6 +184,9 @@ case "$TERM_PROGRAM" in
iTerm.app
)
bindkey
"^[^[[A"
dirhistory_zle_dirhistory_up
;;
# iTerm2
iTerm.app
)
bindkey
"^[^[[A"
dirhistory_zle_dirhistory_up
;;
# iTerm2
Apple_Terminal
)
bindkey
"^[OA"
dirhistory_zle_dirhistory_up
;;
# Terminal.app
Apple_Terminal
)
bindkey
"^[OA"
dirhistory_zle_dirhistory_up
;;
# Terminal.app
esac
esac
if
((
${
+terminfo[kcuu1]
}
))
;
then
bindkey
"^[
${
terminfo
[kcuu1]
}
"
dirhistory_zle_dirhistory_up
# urxvt
fi
zle
-N
dirhistory_zle_dirhistory_down
zle
-N
dirhistory_zle_dirhistory_down
bindkey
"
\e
[3B"
dirhistory_zle_dirhistory_down
# xterm in normal mode
bindkey
"
\e
[3B"
dirhistory_zle_dirhistory_down
# xterm in normal mode
...
@@ -188,3 +197,6 @@ case "$TERM_PROGRAM" in
...
@@ -188,3 +197,6 @@ case "$TERM_PROGRAM" in
iTerm.app
)
bindkey
"^[^[[B"
dirhistory_zle_dirhistory_down
;;
# iTerm2
iTerm.app
)
bindkey
"^[^[[B"
dirhistory_zle_dirhistory_down
;;
# iTerm2
Apple_Terminal
)
bindkey
"^[OB"
dirhistory_zle_dirhistory_down
;;
# Terminal.app
Apple_Terminal
)
bindkey
"^[OB"
dirhistory_zle_dirhistory_down
;;
# Terminal.app
esac
esac
if
((
${
+terminfo[kcud1]
}
))
;
then
bindkey
"^[
${
terminfo
[kcud1]
}
"
dirhistory_zle_dirhistory_down
# urxvt
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment