tmux man-page search highlighting

Based on Less Colors For Man Pages by Gen2ly, here is my man page and how to do it: Preview This is a shell, not a web page ! How to (optional) I’m using Tomorrow theme for Konsole/Yakuake ; Edit your ~/.bashrc ~/.zshrc, etc. to add : # Colored man pages: http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/ # Less Colors … Read more

How do I display ANSI color codes in emacs for any mode?

You could use code below (require ‘ansi-color) (defun display-ansi-colors () (interactive) (ansi-color-apply-on-region (point-min) (point-max))) Then you can execute display-ansi-colors via M-x, via a key-binding of your choosing, or via some programmatic condition (maybe your log files have a extension or name that matches some regexp) If you want to do this with read-only buffers (log … Read more

Python: How can I make the ANSI escape codes to work also in Windows?

For windows, calling os.system(“”) makes the ANSI escape sequence get processed correctly: import os os.system(“”) # enables ansi escape characters in terminal COLOR = { “HEADER”: “\033[95m”, “BLUE”: “\033[94m”, “GREEN”: “\033[92m”, “RED”: “\033[91m”, “ENDC”: “\033[0m”, } print(COLOR[“GREEN”], “Testing Green!!”, COLOR[“ENDC”])

Shell Prompt Line Wrapping Issue

I am now using this PS1 with good effect: green=$(tput setaf 2) blue=$(tput setaf 4) bold=$(tput bold) reset=$(tput sgr0) PS1=”\[$green$bold\]\h\[$reset\]:\[$blue$bold\]\w\[$reset\]\$ ” Scrolling through my command history appears to handle line wraps now. However in the meantime since this question was asked I have also updated my OS X to 10.6.3

How to detect if the console does support ANSI escape codes in Python?

Django users can use django.core.management.color.supports_color function. if supports_color(): … The code they use is: def supports_color(): “”” Returns True if the running system’s terminal supports color, and False otherwise. “”” plat = sys.platform supported_platform = plat != ‘Pocket PC’ and (plat != ‘win32’ or ‘ANSICON’ in os.environ) # isatty is not always implemented, #6223. is_a_tty … Read more

How to make win32 console recognize ANSI/VT100 escape sequences in `c`?

[UPDATE] For latest Windows 10 please read useful contribution by @brainslugs83, just below in the comments to this answer. While for versions before Windows 10 Anniversary Update: ANSI.SYS has a restriction that it can run only in the context of the MS-DOS sub-system under Windows 95-Vista. Microsoft KB101875 explains how to enable ANSI.SYS in a … Read more

Remove all ANSI colors/styles from strings

The regex you should be using is /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g This matches most of the ANSI escape codes, beyond just colors, including the extended VT100 codes, archaic/proprietary printer codes, etc. Note that the \u001b in the above regex may not work for your particular library (even though it should); check out my answer to a similar question … Read more