Skip to content

Commit 11362b0

Browse files
committed
Bugfixes + consistency
1 parent 2554196 commit 11362b0

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

templates/murex.txt

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{%- let section = "# =============================================================================\n#" -%}
22
{%- let not_configured = "# -- not configured --" -%}
33

4-
# Code generated by zoxide. DO NOT EDIT.
4+
{{ section }}
5+
# Utility functions for zoxide.
6+
#
7+
8+
# cd + custom logic based on the value of _ZO_ECHO.
9+
fexec builtin function __zoxide_cd {
10+
fexec builtin cd $PARAMS[0]
11+
{%- if echo %}
12+
fexec builtin out $PWD
13+
{%- endif %}
14+
}
515

616
{{ section }}
717
# Hook configuration for zoxide.
@@ -12,14 +22,14 @@
1222
{{ not_configured }}
1323

1424
{%- when InitHook::Prompt -%}
15-
# Update database after each command completes.
16-
event onPrompt zoxide=command-completion {
17-
zoxide add -- $PWD
25+
# Initialize hook to add new entries to the database.
26+
fexec builtin event onPrompt __zoxide_hook=command-completion {
27+
exec zoxide add -- $PWD
1828
}
1929

2030
{%- when InitHook::Pwd -%}
21-
out "zoxide: PWD hooks are not supported on Murex."
22-
out " Use 'zoxide init murex --hook prompt' instead."
31+
fexec builtin out "zoxide: PWD hooks are not supported on Murex.
32+
fexec builtin out " Use 'zoxide init murex --hook prompt' instead."
2333

2434
{%- endmatch %}
2535

@@ -28,36 +38,21 @@ out " Use 'zoxide init murex --hook prompt' instead."
2838
#
2939

3040
# Jump to a directory using only keywords.
31-
function __zoxide_z {
32-
# No args: go home
33-
if { !$ARGS } {
34-
cd ~
35-
{%- if echo %} out $PWD {%- endif %}
36-
return
41+
fexec builtin function __zoxide_z {
42+
if { !$PARAMS } then {
43+
fexec function __zoxide_cd ~
44+
fexec builtin return
3745
}
38-
39-
# Previous dir
40-
if { $ARGS[0] == "-" } {
41-
cd -
42-
{%- if echo %} out $PWD {%- endif %}
43-
return
46+
if { $PARAMS[0] == "-" } then {
47+
fexec function __zoxide_cd -
48+
fexec builtin return
4449
}
45-
46-
# Query and jump
47-
zoxide query --exclude $PWD -- @PARAMS -> set: str __z
48-
cd $__z
49-
{%- if echo %}
50-
out $PWD
51-
{%- endif %}
50+
exec zoxide query --exclude $PWD -- @PARAMS -> set: str __zoxide_result && fexec function __zoxide_cd $__zoxide_result
5251
}
5352

5453
# Jump to a directory using interactive search.
55-
function __zoxide_zi {
56-
zoxide query --interactive -- @PARAMS -> set: str __z
57-
cd $__z
58-
{%- if echo %}
59-
out $PWD
60-
{%- endif %}
54+
fexec builtin function __zoxide_zi {
55+
exec zoxide query --interactive -- @PARAMS -> set: str __zoxide_result && fexec function __zoxide_cd $__zoxide_result
6156
}
6257

6358
{{ section }}
@@ -77,7 +72,6 @@ function {{cmd}}i { __zoxide_zi @PARAMS }
7772
{%- endmatch %}
7873

7974
{{ section }}
80-
# To initialize zoxide, add this to your Murex profile (~/.murex_profile):
75+
# To initialize zoxide, add this to your shell configuration file (usually ~/.murex_profile):
8176
#
82-
# zoxide init murex --hook prompt -> source
83-
77+
# zoxide init murex --hook prompt -> source

0 commit comments

Comments
 (0)