2016-12-15 23 views
0

在ZSH,一个ZLE命令可以有多个键绑定,例如:等效于使用unix的group_concat()聚合函数?

▶ bindkey | grep accept-and-hold 
"^[A" accept-and-hold 
"^[a" accept-and-hold 

如何产生从bindkey一个聚合给定命令所有关键序列成一条线一个列表?使用q

一个解决方案:

▶ bindkey | q "select c2, group_concat(c1) from - group by c2" | grep accept-and-hold 
accept-and-hold ^[A,^[a 

但我不知道是否有办法做到这一点,而无需使用工具票友使用诸如perlawksedq

回答

0

一些awk来营救:

% bindkey | awk -v zle=accept-and-hold '$2==zle{s=s" "$1};END{print zle s}' 
accept-and-hold "^[A" "^[a" 

还有如果你真的想删除引号:

% bindkey | awk -v zle=accept-and-hold '$2==zle{s=s" "gensub(/\"/,"","g",$1)};END{print zle s}' 
accept-and-hold ^[A ^[a 
+0

我想知道是否有没有'awk'的方式。 –