If you are wanting to change your colours in the console, that is outside X, then you can specify colours in your .bashrc
, like so:
if [ "$TERM" = "linux" ]; then
echo -en "\e]P0222222" #black
echo -en "\e]P8222222" #darkgrey
echo -en "\e]P1803232" #darkred
....
fi
Where you are defining black as #222222
See this post for the details: http://phraktured.net/linux-console-colors.html
If you are working in X, then you can customize your setup by defining your colours in your .Xresources
like so:
!black
*color0: #3D3D3D
*color8: #5E5E5E
!red
*color1: #8C4665
*color9: #BF4D80
...
and then sourcing this file when you start X, typically from your .xinitrc
:
xrdb -merge ~/.Xresources
The Arch Wiki has a page on .Xresources that explains all of the options:
https://wiki.archlinux.org/index.php/Xresources
Another enhancement you can make either in X or not is to specify all of the different filetypes that you would like to colour—and their respective colours in a .dir_colors
file, like so:
.xinitrc 01;31
.Xauthority 01;31
.Xmodmap 00;31
.Xresources 01;33
...
To get started, copy /etc/dir_colors
to your user's /home
directory and make your changes. Then source this from your .bashrc
with eval $(dircolors -b ~/.dir_colors)
This will allow you fine-grained control over the colours of files and filetypes when you use ls
.
You can find (an incredibly detailed and thorough) .dir_colors
example file here:
https://github.com/trapd00r/LS_COLORS/blob/master/LS_COLORS
With a combination of all three approaches, you can create a reasonably uniform setup, whether you are working in the console or in X.
I think the piece you're missing is the interactive
form. It's how Emacs distinguishes between a function designed to be called by other functions, and a function designed to be called directly by the user. See the Emacs Lisp Intro node
Now if you read the definition of ansi-color-apply-on-region
, you'll see that it's not designed for interactive use. "ansi-color" is designed to filter comint output. However it's easy to make an interactive wrapper for it.
(defun ansi-color-apply-on-region-int (beg end)
"interactive version of func"
(interactive "r")
(ansi-color-apply-on-region beg end))
The next bit is you want to turn on ansi colors for the .col extension. You can add a hook function to whatever major-mode you want use to edit those files. The function would be run whenever you turn on the major-mode, so you will have to add a check for the proper file suffix.
Alternatively you can hack a quick derived mode based on "fundamental" mode.
(define-derived-mode fundamental-ansi-mode fundamental-mode "fundamental ansi"
"Fundamental mode that understands ansi colors."
(require 'ansi-color)
(ansi-color-apply-on-region (point-min) (point-max)))
and associate it with that extension.
(setq auto-mode-alist
(cons '("\\.col\\'" . fundamental-ansi-mode) auto-mode-alist))
Best Answer
You would want to check the exit code of spfquery, then have an if/else to see if it was a pass or not. Something like this: