浏览代码

Add interactive mode function to strip color codes

Alois Mahdal 9 年前
父节点
当前提交
ec388222dc
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9
    0
      dotfiles/bash/main.bashrc

+ 9
- 0
dotfiles/bash/main.bashrc 查看文件

@@ -68,6 +68,15 @@ bcdiff() {
68 68
     bcompare "$@" &
69 69
 }
70 70
 
71
+strip_colors() {
72
+    #
73
+    # Strip color codes from stdin
74
+    #
75
+    # Stolen from http://unix.stackexchange.com/a/4533/9365
76
+    #
77
+    sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
78
+}
79
+
71 80
 vims() {
72 81
     #
73 82
     # Show "abandoned" Vim .swp files in a nice table