[pass] Proposal: fuzzy search

Kun Zhang arthur.kun at gmail.com
Wed Aug 17 17:37:39 CEST 2016


Thanks, but none of the alternative solutions work for me on Ubuntu 14.04 :(

On Tue, Aug 16, 2016 at 5:44 AM, Kjetil Torgrim Homme <
kjetil.homme at redpill-linpro.com> wrote:

> Den 16. aug. 2016 03:28, Kun Zhang skreiv:
> >     ## Regular Expression
> >     line 338: path=$(echo "$matches" | perl -pe 's/\e\[?.*?[\@-~]//g')
> >     Why not use sed or builtin?
> >     Who wants to install all of perl to run bash code?
> >
> >
> > I googled around but didn't find other code that successfully remove
> > ANSI color codes for me.
> > So I landed with the first solution that worked. I can look harder
> though.
>
>
> rewriting the regexp to not be dependent on Perl's non-greedy syntax is
> quite simple. the bash-only solution below is a bit roundabout since
> there is no substitute function for regular expressions, so we have to
> extract the actual plain strings using the =~ operator and then do text
> substitutions:
>
>     path="$matches"
>     printf -v ansi_color_re '\033\\[[^@-~]*[@-~]'
>     while [[ "$path" =~ $ansi_color_re ]]
>     do
>         path=${path/${BASH_REMATCH[0]}/}
>     done
>
> (note, I changed the [ after ESC to be mandatory, I think that is more
> correct.)
>
> alternatively, you can write it using GNU sed like this:
>
>     path=$(echo "$matches" | sed 's/\o033\[[^@-~]*[@-~]//g'
>
> or more portably:
>
>     printf -v ESC '\033'
>     path=$(echo "$matches" | sed s/${ESC}'\[[^@-~]*[@-~]//g'
>
>
> --
> Kjetil T. Homme
> Redpill Linpro - Changing the game
>
>


-- 
Best wishes
Kun Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160817/556fe1e9/attachment.html>


More information about the Password-Store mailing list