[英]Passing zsh function parameter to grep -E
Trying to find which commit(s) last touched a specific file. 尝试查找哪个提交最后触及了特定文件。
I can do this on the CLI piping from git-log
to grep
but I'm trying to wrap this in a zsh function, more for ease of memory. 我可以在从git-log
到grep
的CLI管道中执行此操作,但是我试图将其包装在zsh函数中,以简化存储。
Here's my function, and then here is the output I'd like to generate with it. 这是我的函数,然后是我想用它生成的输出。
# match lines from git log that start with commit or include the
# filename I'm interested in and then pipe back through grep to color the output
glpg() {
\git log --name-only | \grep -E ‘“$"|^commit\s\S' | \grep -B1 --color -E ‘$'
}
dwight:assets (add-analytics*) $ glpg clickouts
commit 6662418b8e68e478b95e7254faa6406abdada30f
web/assets/app/viewmodels/clickouts.js
web/assets/app/views/clickouts.html
web/client/app/viewmodels/clickouts.js
web/client/app/views/clickouts.html
--
commit cee37549f613985210c9caf90a48e2cca28d4412
web/client/app/viewmodels/clickouts.js
web/client/app/views/clickouts.html
--
commit df9ea8cd90ff80b89a0c7e2b0657141b105d5e7e
web/client/app/viewmodels/clickouts.js
web/client/app/views/clickouts.html
Three problems. 三个问题。
' '
and [^ ]
instead to be portable. 使用' '
和[^ ]
代替可移植。 "$@"
including the double quotes. 所有参数列表以"$@"
引用,包括双引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.