根据 svn 状态对文件名着色
当调用ls
时,我希望文件名根据其颠覆状态具有不同的颜色。例如,添加的文件将显示为青色,修改的文件将显示为红色等。仅靠 bash 的力量就可以实现吗?这方面有准备吗?
When invoking ls
, I would like to have file names with a different color depending on their subversion status. For example, an added file will be cyan, a modified file red and so on. Is it possible with the bare power of bash? Is there something ready on this regard ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,用纯bash(除了脚本)不可能实现这一点。
您可以使用脚本(bash、python、perl,无论您是什么毒药)轻松获得彩色文件列表。这是用 python 编写的相当粗略的概念验证实现: https://gist.github.com/776093
As far as I know, it is not possible to achieve that with pure bash (scripting aside).
You can quite easily get colorised file listing using scripts (bash, python, perl, whatever your poison). Here's a rather crude proof-of-concept implementation written in python : https://gist.github.com/776093
这是一个要点,其中包含第三代小脚本,用于对 SVN 输出进行着色。它非常适合 svn status 命令。我刚刚将
alias svns="/path/to/svn-color.py status"
添加到我的.bash_profile
中,现在我可以输入svns
并查看颜色编码的输出。作者建议将svn
默认为他的脚本。Here's a Gist with the 3rd generation of a small script to colorize SVN output. It works perfectly for
svn status
commands. I just addedalias svns="/path/to/svn-color.py status"
to my.bash_profile
and now I can typesvns
and see the color-coded output. The author recommends makingsvn
default to his script.