From 530db47524a31649f6f46b2698e53720d87e657e Mon Sep 17 00:00:00 2001 From: edslocomb Date: Sun, 17 Jun 2012 00:17:31 -0700 Subject: [PATCH] many color/term fixes to accomodate Ubuntu, updated emacs-solarized, better-paths debugged and reintroduced --- bash/FreeBSD | 98 ------------------ bash/better-paths | 98 ++++++++++++++++++ bash/colorfixes | 24 +++++ bash/{Linux => gnu-screen-fix} | 0 bash_profile | 6 +- bashrc | 2 +- .../solarized-definitions.el | 99 ++++++++++--------- emacs.d/term/gnome.el | 9 ++ screenrc | 8 +- 9 files changed, 189 insertions(+), 155 deletions(-) delete mode 100644 bash/FreeBSD create mode 100644 bash/better-paths create mode 100644 bash/colorfixes rename bash/{Linux => gnu-screen-fix} (100%) create mode 100644 emacs.d/term/gnome.el diff --git a/bash/FreeBSD b/bash/FreeBSD deleted file mode 100644 index 0113314a78..0000000000 --- a/bash/FreeBSD +++ /dev/null @@ -1,98 +0,0 @@ -# -*- sh -*- - - -# # Add some user and/or local paths to $PATH and $MANPATH - -# ### -# ### Add your dirs to [pre|post]PATH and [pre|post]MANPATH below. -# ### Dirs already in your PATH/MANPATH won't be added. -# ### Dirs that don't exist on your system won't be added. -# ### Dirs will be *prepended* to your PATH/MANPATH, order preserved. -# ### - -# prePATH="/usr/local/mysql/bin:/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin" - -# postPATH="$HOME/bin:$HOME/.scripts:$HOME/.rvm/bin" - -# preMANPATH="/usr/local/mysql/man:/usr/local/git/man:/usr/local/man:/opt/local/man" - -# postMANPATH="$HOME/man:$HOME/.rvm/man" - -# # Note on $MANPATH, $extraMANPATH -# # we don't want to set $MANPATH if the system/user is using another -# # mechanism to find man pages (e.g. manpath(1) on ubuntu or freebsd), -# # because setting MANPATH could clobber that mechanism. -# # manpath(1) will use $PATH to find man pages; for the most -# # part, if you add something to [pre|post]PATH, then manpath(1) will -# # pick up your corresponding man pages. - - -# ## -# ## Function definitions -# ## - -# list_contains () { -# eval p=\$$1 -# for dir in $p -# do -# if [ "$dir" == "$2" ]; then -# return 0 -# fi -# done -# return 1 -# } - -# prepend_to_listvar () { -# if [ -d $2 ] && ! ( list_contains "$1" "$2" ) ; then -# eval "$1=$2${IFS:0:1}\$$1" -# fi -# } - -# append_to_listvar () { -# if [ -d $2 ] && ! ( list_contains "$1" "$2" ) ; then -# eval "$1=\$$1${IFS:0:1}$2" -# fi -# } - -# reverse_list () { -# rev=$1 -# shift -# while [ $1 ] -# do -# rev=$1${IFS:0:1}$rev -# shift -# done -# echo -n "$rev" -# } - -# ## -# ## End function definitions -# ## - -# # we're going to work with paths separated by ":" instead of whitespace -# IFS=: - -# for dir in $( reverse_list $prePATH ) -# do -# prepend_to_listvar PATH "$dir" -# done - -# for dir in $postPATH -# do -# append_to_listvar PATH "$dir" -# done - -# if [ -n "$MANPATH" ]; then -# for dir in $( reverse_list $preMANPATH ) -# do -# prepend_to_listvar MANPATH "$dir" -# done -# for dir in $postMANPATH -# do -# append_to_listvar MANPATH "$dir" -# done -# fi - -# # put IFS back -# unset IFS - diff --git a/bash/better-paths b/bash/better-paths new file mode 100644 index 0000000000..495ab60450 --- /dev/null +++ b/bash/better-paths @@ -0,0 +1,98 @@ +# -*- sh -*- + +# # Add some user and/or local paths to $PATH and $MANPATH + +# ### +# ### Add your dirs to [pre|post]PATH and [pre|post]MANPATH below. +# ### Dirs already in your PATH/MANPATH won't be added. +# ### Dirs that don't exist on your system won't be added. +# ### Dirs will be *prepended* to your PATH/MANPATH, order preserved. +# ### + +prePATH="$HOME/bin:$HOME/.scripts:$HOME/.rvm/bin" + +postPATH="/usr/local/mysql/bin:/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin" + +preMANPATH="/usr/local/mysql/man:/usr/local/git/man:/usr/local/man:/opt/local/man" + +postMANPATH="$HOME/man:$HOME/.rvm/man" + +# # Note on $MANPATH, $extraMANPATH +# # we don't want to set $MANPATH if the system/user is using another +# # mechanism to find man pages (e.g. manpath(1) on ubuntu or freebsd), +# # because setting MANPATH could clobber that mechanism. +# # manpath(1) will use $PATH to find man pages; for the most +# # part, if you add something to [pre|post]PATH, then manpath(1) will +# # pick up your corresponding man pages. + + +# ## +# ## Function definitions +# ## + +list_contains () { + eval p=\$$1 + for dir in $p + do + if [ "$dir" == "$2" ]; then + return 0 + fi + done + return 1 +} + +prepend_to_listvar () { + if [ -d $2 ] && ! ( list_contains "$1" "$2" ) ; then + eval "$1=$2${IFS:0:1}\$$1" + fi +} + +append_to_listvar () { + if [ -d $2 ] && ! ( list_contains "$1" "$2" ) ; then + eval "$1=\$$1${IFS:0:1}$2" + fi +} + +reverse_list () { + rev=$1 + shift + while [ $1 ] + do + rev=$1${IFS:0:1}$rev + shift + done + echo -n "$rev" +} + +# ## +# ## End function definitions +# ## + +# # we're going to work with paths separated by ":" instead of whitespace +IFS=: + +for dir in $( reverse_list $prePATH ) +do + prepend_to_listvar PATH "$dir" +done + +for dir in $postPATH +do + append_to_listvar PATH "$dir" +done + +if [ -n "$MANPATH" ]; then + for dir in $( reverse_list $preMANPATH ) + do + prepend_to_listvar MANPATH "$dir" + done + for dir in $postMANPATH + do + append_to_listvar MANPATH "$dir" + done + export MANPATH +fi + +# # put IFS back +unset IFS + diff --git a/bash/colorfixes b/bash/colorfixes new file mode 100644 index 0000000000..23ccaac811 --- /dev/null +++ b/bash/colorfixes @@ -0,0 +1,24 @@ +# -*- sh -*- + +# set TERM correctly if we're in Ubuntu's default graphical terminal app, +# (gnome-terminal, in Ubuntu 12.04) +if [[ ($TERM == "xterm") && ($COLORTERM == "gnome-terminal") ]]; then + TERM=gnome-256color +fi + +# Fix GNU screen's 256-color terminal setttings +# the presence of $STY is the most reliable way to detect when we're +# running inside screen. note TERMCAP is not the same as TERM +if [ $STY ]; then + # we're running inside GNU screen... + if [ -n "$TERMCAP" ]; then + # ...where the $TERMCAP screen sets is wrong for 256-color terminals... + if (( `expr "$TERM" : '.*256col'` )); then + # ...so we blow it away, assuming either the system-wide + # termcap will have something better, or we have + # taken advantage of $TERMPATH and/or .termcap, or + # we'll be setting $TERMCAP ourselves after this + unset TERMCAP + fi + fi +fi \ No newline at end of file diff --git a/bash/Linux b/bash/gnu-screen-fix similarity index 100% rename from bash/Linux rename to bash/gnu-screen-fix diff --git a/bash_profile b/bash_profile index 6d0b86769f..070953bcb3 100644 --- a/bash_profile +++ b/bash_profile @@ -3,13 +3,9 @@ # Read by login shells only (the first time you log in). # NOT read by subshells (like what screen creates). -source ~/.bash/paths - +source $HOME/.bash/better-paths # .bashrc is read by subshells. This will make login shells read it too. if [ -f $HOME/.bashrc ]; then source $HOME/.bashrc fi - - - diff --git a/bashrc b/bashrc index c6354cf539..e5e729f20f 100644 --- a/bashrc +++ b/bashrc @@ -14,7 +14,7 @@ source ~/.bash/aliases source ~/.bash/completions source ~/.bash/config -source ~/.bash/`uname` +source ~/.bash/colorfixes # Use .localrc for settings specific to one system. if [ -f ~/.localrc ]; then diff --git a/emacs.d/emacs-color-theme-solarized/solarized-definitions.el b/emacs.d/emacs-color-theme-solarized/solarized-definitions.el index 95c030fe1f..5e5219ff16 100644 --- a/emacs.d/emacs-color-theme-solarized/solarized-definitions.el +++ b/emacs.d/emacs-color-theme-solarized/solarized-definitions.el @@ -32,16 +32,6 @@ degraded color mode to test the approximate color values for accuracy." :type 'boolean :group 'solarized) -(defcustom solarized-termcolors 16 - "This setting applies to emacs in terminal (non-GUI) mode. -If set to 16, emacs will use the terminal emulator's colorscheme (best option -as long as you've set your emulator's colors to the Solarized palette). If -set to 256 and your terminal is capable of displaying 256 colors, emacs will -use the 256 degraded color mode." - :type 'integer - :options '(16 256) - :group 'solarized) - (defcustom solarized-contrast 'normal "Stick with normal! It's been carefully tested. Setting this option to high or low does use the same Solarized palette but simply shifts some values up or @@ -52,7 +42,7 @@ down in order to expand or compress the tonal range displayed." (defcustom solarized-broken-srgb (if (eq system-type 'darwin) t nil) "Emacs bug #8402 results in incorrect color handling on Macs. If this is t -(the default on Macs), Solarized works around it with alternative colors. +\(the default on Macs), Solarized works around it with alternative colors. However, these colors are not totally portable, so you may be able to edit the \"Gen RGB\" column in solarized-definitions.el to improve them further." :type 'boolean @@ -61,37 +51,38 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." ;; FIXME: The Generic RGB colors will actually vary from device to device, but ;; hopefully these are closer to the intended colors than the sRGB values ;; that Emacs seems to dislike -(defvar solarized-colors - ;; name sRGB Gen RGB degraded ANSI(Solarized terminal) - '((base03 "#002b36" "#042028" "#1c1c1c" "#7f7f7f") - (base02 "#073642" "#0a2832" "#262626" "#000000") - (base01 "#586e75" "#465a61" "#585858" "#00ff00") - (base00 "#657b83" "#52676f" "#626262" "#ffff00") - (base0 "#839496" "#708183" "#808080" "#5c5cff") - (base1 "#93a1a1" "#81908f" "#8a8a8a" "#00ffff") - (base2 "#eee8d5" "#e9e2cb" "#e4e4e4" "#e5e5e5") - (base3 "#fdf6e3" "#fcf4dc" "#ffffd7" "#ffffff") - (yellow "#b58900" "#a57705" "#af8700" "#cdcd00") - (orange "#cb4b16" "#bd3612" "#d75f00" "#ff0000") - (red "#dc322f" "#c60007" "#d70000" "#cd0000") - (magenta "#d33682" "#c61b6e" "#af005f" "#cd00cd") - (violet "#6c71c4" "#5859b7" "#5f5faf" "#ff00ff") - (blue "#268bd2" "#2075c7" "#0087ff" "#0000ee") - (cyan "#2aa198" "#259185" "#00afaf" "#00cdcd") - (green "#859900" "#728a05" "#5f8700" "#00cd00")) +(defvar solarized-colors ; ANSI(Solarized terminal) + ;; name sRGB Gen RGB 256 16 8 + '((base03 "#002b36" "#042028" "#1c1c1c" "brightblack" "black") + (base02 "#073642" "#0a2832" "#262626" "black" "black") + (base01 "#586e75" "#465a61" "#585858" "brightgreen" "green") + (base00 "#657b83" "#52676f" "#626262" "brightyellow" "yellow") + (base0 "#839496" "#708183" "#808080" "brightblue" "blue") + (base1 "#93a1a1" "#81908f" "#8a8a8a" "brightcyan" "cyan") + (base2 "#eee8d5" "#e9e2cb" "#e4e4e4" "white" "white") + (base3 "#fdf6e3" "#fcf4dc" "#ffffd7" "brightwhite" "white") + (yellow "#b58900" "#a57705" "#af8700" "yellow" "yellow") + (orange "#cb4b16" "#bd3612" "#d75f00" "brightred" "red") + (red "#dc322f" "#c60007" "#d70000" "red" "red") + (magenta "#d33682" "#c61b6e" "#af005f" "magenta" "magenta") + (violet "#6c71c4" "#5859b7" "#5f5faf" "brightmagenta" "magenta") + (blue "#268bd2" "#2075c7" "#0087ff" "blue" "blue") + (cyan "#2aa198" "#259185" "#00afaf" "cyan" "cyan") + (green "#859900" "#728a05" "#5f8700" "green" "green")) "This is a table of all the colors used by the Solarized color theme. Each column is a different set, one of which will be chosen based on term capabilities, etc.") (defun solarized-color-definitions (mode) (flet ((find-color (name) - (let ((index (if window-system - (if solarized-degrade - 3 - (if solarized-broken-srgb 2 1)) - (if (= solarized-termcolors 256) - 3 - 4)))) + (let* ((index (if window-system + (if solarized-degrade + 3 + (if solarized-broken-srgb 2 1)) + (case (display-color-cells) + (16 4) + (8 5) + (otherwise 3))))) (nth index (assoc name solarized-colors))))) (let ((base03 (find-color 'base03)) (base02 (find-color 'base02)) @@ -120,14 +111,19 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (rotatef base01 base1) (rotatef base00 base0)) (let ((back base03)) - (cond ((eq 'high solarized-contrast) + (cond ((< (display-color-cells) 16) + (setf back nil)) + ((eq 'high solarized-contrast) (let ((orig-base3 base3)) (rotatef base01 base00 base0 base1 base2 base3) (setf base3 orig-base3))) ((eq 'low solarized-contrast) (setf back base02 opt-under t))) - (let ((bg-back `(:background ,back)) + ;; NOTE: We try to turn an 8-color term into a 10-color term by not + ;; using default background and foreground colors, expecting the + ;; user to have the right colors set for them. + (let ((bg-back `(:background ,back)) (bg-base03 `(:background ,base03)) (bg-base02 `(:background ,base02)) (bg-base01 `(:background ,base01)) @@ -149,8 +145,10 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (fg-base02 `(:foreground ,base02)) (fg-base01 `(:foreground ,base01)) (fg-base00 `(:foreground ,base00)) - (fg-base0 `(:foreground ,base0)) - (fg-base1 `(:foreground ,base1)) + (fg-base0 `(:foreground ,(when (<= 16 (display-color-cells)) + base0))) + (fg-base1 `(:foreground ,(when (<= 16 (display-color-cells)) + base1))) (fg-base2 `(:foreground ,base2)) (fg-base3 `(:foreground ,base3)) (fg-green `(:foreground ,green)) @@ -187,7 +185,7 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (linum ((t (,@fg-base01 ,@bg-base02)))) (header-line ((t (,@fg-base0 ,@bg-base02 ,@fmt-revbb)))) ; Pmenu (highlight ((t (,@bg-base02)))) - (hl-line ((t (,@fmt-uopt ,@bg-base02)))) ; CursorLine + (hl-line ((t (:underline ,opt-under ,@bg-base02)))) ; CursorLine (isearch ((t (,@fmt-stnd ,@fg-orange ,@bg-back)))) ; IncSearch (isearch-fail ((t (,@fmt-stnd ,@fg-orange ,@bg-back)))) ; IncSearch (lazy-highlight ((t (,@fmt-revr ,@fg-yellow ,@bg-back)))) ; Search @@ -289,11 +287,12 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (font-lock-variable-name-face ; Identifier ((t (,@fmt-none ,@fg-blue)))) (font-lock-warning-face ((t (,@fmt-bold ,@fg-red)))) ; Error - (font-lock-doc-face ((t (,@fmt-none ,@fg-red)))) ; Special + (font-lock-doc-face ((t (,@fmt-ital ,@fg-base01)))) ; Comment + (font-lock-doc-string-face ; Comment (XEmacs-only) + ((t (,@fmt-ital ,@fg-base01)))) (font-lock-color-constant-face ((t (,@fmt-none ,@fg-green)))) (font-lock-comment-delimiter-face ; Comment ((t (,@fmt-ital ,@fg-base01)))) - (font-lock-doc-string-face ((t (,@fmt-none ,@fg-red)))) ; Special (font-lock-preprocessor-face ; PreProc ((t (,@fmt-none ,@fg-orange)))) (font-lock-reference-face ((t (,@fmt-none ,@fg-cyan)))) @@ -301,7 +300,8 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (font-lock-other-type-face ((t (,@fmt-ital ,@fg-blue)))) (font-lock-regexp-grouping-construct ((t (,@fmt-none ,@fg-orange)))) - (font-lock-special-keyword-face ((t (,@fmt-none ,@fg-magenta)))) + (font-lock-special-keyword-face ; Special + ((t (,@fmt-none ,@fg-red)))) (font-lock-exit-face ((t (,@fmt-none ,@fg-red)))) (font-lock-other-emphasized-face ((t (,@fmt-bldi ,@fg-violet)))) (font-lock-regexp-grouping-backslash @@ -341,8 +341,9 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." ;; extra modules ;; ------------- ;; Flymake - (flymake-errline ((t (,@bg-base3)))) - (flymake-warnline ((t (,@bg-base02)))) + (flymake-errline ((t (,@fmt-revr ,@fg-red ,@bg-back)))) ; ErrorMsg + (flymake-warnline ; WarningMsg + ((t (,@fmt-bold ,@fg-red ,@bg-back)))) ;; column-marker (column-marker-1 ((t (,@bg-base01)))) (column-marker-2 ((t (,@bg-cyan)))) @@ -479,6 +480,7 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (whitespace-tab ((t (,@fg-base02)))) (whitespace-trailing ((t (,@fmt-bold ,@fg-red ,@bg-base02)))) (whitespace-highlight-face ((t (,@fg-red ,@bg-blue)))) + (whitespace-line ((t (,@fg-magenta ,@bg-base03)))) ;; rcirc (rcirc-my-nick ((t (:foreground ,blue)))) (rcirc-nick-in-message ((t (:foreground ,orange)))) @@ -488,10 +490,11 @@ the \"Gen RGB\" column in solarized-definitions.el to improve them further." (rcirc-server ((t (:foreground ,base1)))) (rcirc-timestamp ((t (:foreground ,base01))))) - ((foreground-color . ,base0) + ((foreground-color . ,(when (<= 16 (display-color-cells)) base0)) (background-color . ,back) (background-mode . ,mode) - (cursor-color . ,base0)))))))) + (cursor-color . ,(when (<= 16 (display-color-cells)) + base0))))))))) (defmacro create-solarized-theme (mode) (let* ((theme-name (intern (concat "solarized-" (symbol-name mode)))) diff --git a/emacs.d/term/gnome.el b/emacs.d/term/gnome.el new file mode 100644 index 0000000000..8e223ab234 --- /dev/null +++ b/emacs.d/term/gnome.el @@ -0,0 +1,9 @@ +(defvar foo-gnome "loaded gnome.el") + +(load "term/xterm") + +(defun terminal-init-gnome () + "Terminal initialization function for gnome terminal." + ;; Use the xterm color initialization code. + (xterm-register-default-colors) + (tty-set-up-initial-frame-faces)) \ No newline at end of file diff --git a/screenrc b/screenrc index bc96d0a10d..1b9e3e496b 100644 --- a/screenrc +++ b/screenrc @@ -1,3 +1,6 @@ +# use 256 colors +term screen-256color + # Set the screen key to control-] escape ^]\\ @@ -14,14 +17,13 @@ startup_message off #caption always "%>%{kw}%1`@%H %{bw}%?%-Lw%?%{bW}%n*%f %t%?(%u)%?%{bw}%?%+Lw%?%" #screen -h 0 emacs -nw -#screen -h 100 - +#screen -h 100 defscrollback 10000 bind b eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'" -vbell on +vbell on # turn off screen locking bind x