From: Thomas Lauer <thomas.lauer@virgin.net>
To: Zsh Users <zsh-users@zsh.org>
Subject: zsh function breaks after error
Date: Tue, 08 Feb 2022 17:16:14 +0000 [thread overview]
Message-ID: <l3850ht4v4mopd3asrkeuvpad65k2gi0j3@tlc.com> (raw)
I have googled for what seems to be an simple and obvious thing but
somehow I seem to be unable to find what I'm looking for. So here goes.
I have this function, called via keyboard shortcut while editing a line:
expandDir2() {
zle backward-kill-word
local _dir=$CUTBUFFER
_dir=${_dir:gs/*/.+/}
_dir=${_dir:gs/?/./}
_dir=${_dir:gs/:/(?i)/}
_dir=$(command grep -hP "$_dir" ~/other/dirlist_*.txt | rofi -dmenu -p
\"Directory\")
echo Never reached on Esc.
[[ "$_dir" == "" ]] && BUFFER=$BUFFER$CUTBUFFER || BUFFER=$BUFFER$_dir
CURSOR=$#BUFFER
}
This basically reads a search string (say "u*sh*z"), greps a set of
files with directory lists (created by a custom script) and runs rofi in
dmenu mode to select one directory which then replaces the search
string. This works very well. The trouble starts when rofi is terminated
not via selecting one of the shown directories (exit value 0) but with
Esc/Ctrl-G (exit value 1).
In this case the function just breaks and I have found no way to
actually check for either the returned string of rofi or its exit value.
Bash has set +-e and I am sure there is sth similar for zsh but I can't
for the life of me find it (I have for now "solved" the problem by
writing a two-liner that calls rofi and always returns exit 0 but that's
a kludge at best).
THX Tom
next reply other threads:[~2022-02-08 17:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 17:16 Thomas Lauer [this message]
2022-02-09 15:18 ` Bart Schaefer
2022-02-09 18:45 ` Thomas Lauer
2022-02-09 20:16 ` Bart Schaefer
2022-02-10 13:55 ` Thomas Lauer
2022-02-10 13:59 ` Roman Perepelitsa
2022-02-10 16:20 ` Thomas Lauer
2022-02-10 16:48 ` Roman Perepelitsa
2022-02-10 17:20 ` Thomas Lauer
2022-02-10 21:26 ` Ray Andrews
2022-02-10 21:45 ` Thomas Paulsen
2022-02-10 23:37 ` Daniel Shahaf
2022-02-11 15:07 ` Thomas Lauer
2022-02-11 14:58 ` Thomas Lauer
2022-02-11 15:59 ` Ray Andrews
2022-02-11 23:31 ` Bart Schaefer
2022-02-12 3:39 ` Ray Andrews
2022-02-22 3:58 ` Matthew Martin
2022-02-12 16:45 ` Thomas Lauer
2022-02-12 17:48 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=l3850ht4v4mopd3asrkeuvpad65k2gi0j3@tlc.com \
--to=thomas.lauer@virgin.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).