Repository: metalelf0/gnome-terminal-colors Branch: master Commit: 483888df134e Files: 69 Total size: 29.3 KB Directory structure: gitextract_06r3s5u8/ ├── LICENSE.mkd ├── README.mkd ├── colors/ │ ├── challenger-deep/ │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── dark/ │ │ └── palette │ ├── dark_alternative/ │ │ └── palette │ ├── dracula/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── gotham/ │ │ ├── README │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── gruvbox-dark/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── gruvbox-light/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── hemisu_dark/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── hemisu_light/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── jellybeans/ │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ ├── palette_dconf │ │ └── palette_gconf │ ├── light/ │ │ └── palette │ ├── nova/ │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── solarized_dark/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ ├── solarized_dark_alternative/ │ │ ├── README.md │ │ ├── bd_color │ │ ├── bg_color │ │ ├── fg_color │ │ └── palette │ └── solarized_light/ │ ├── README.md │ ├── bd_color │ ├── bg_color │ ├── fg_color │ └── palette ├── install.sh ├── src/ │ ├── color_conversions.rb │ ├── dircolors.sh │ ├── profiles.sh │ └── tools.sh └── tools/ └── import_from_iterm.rb ================================================ FILE CONTENTS ================================================ ================================================ FILE: LICENSE.mkd ================================================ License ======= Copyright (c) 2011 Sigurd Gartmann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.mkd ================================================ Colorschemes for Gnome Terminal ======================================== Scripts for setting various colorschemes with Gnome Terminal. To get nicely colored directory listings, you will also need to set up a [dircolors solarised color theme]. For Mate Terminal, you can use [mate-terminal-colors-solarized], maintained by @cledoux. Colorschemes ------------ [Dracula][dracula]: ![Dracula](/screenshots/dracula.png?raw=true "Dracula") [Gotham][vim-gotham]: ![Gotham](/screenshots/gotham.png?raw=true "Gotham") [Hemisu][vim-hemisu] dark: ![Hemisu (dark)](/screenshots/hemisu-dark.png?raw=true "Hemisu (dark)") [Hemisu][vim-hemisu] light: ![Hemisu (light)](/screenshots/hemisu-light.png?raw=true "Hemisu (light)") [Solarized][Solarized homepage] dark: ![Solarized (dark)](/screenshots/solarized-dark.png?raw=true "Solarized (dark)") [Solarized][Solarized homepage] dark (alternative): ![Solarized (dark alternative)](/screenshots/solarized-dark-alternative.png?raw=true "Solarized (dark alternative)") [Solarized][Solarized homepage] light: ![Solarized (light)](/screenshots/solarized-light.png?raw=true "Solarized (light)") Previews -------- [Hemisu][vim-hemisu] dark: ![Hemisu (dark)](/screenshots/hemisu-dark.png?raw=true "Hemisu (dark)") [Hemisu][vim-hemisu] light: ![Hemisu (light)](/screenshots/hemisu-light.png?raw=true "Hemisu (light)") [Solarized][Solarized homepage] dark: ![Solarized (dark)](/screenshots/solarized-dark.png?raw=true "Solarized (dark)") [Solarized][Solarized homepage] dark (alternative): ![Solarized (dark alternative)](/screenshots/solarized-dark-alternative.png?raw=true "Solarized (dark alternative)") [Solarized][Solarized homepage] light: ![Solarized (light)](/screenshots/solarized-light.png?raw=true "Solarized (light)") Installation and usage ---------------------- To be able to uninstall, we highly recommend that you create a new Gnome Terminal profile, using the menus in Gnome Terminal (File... New Profile). You need the `dconf` command (if you run a recent Gnome version). With Ubuntu, this can be installed by running $ sudo apt-get install dconf-cli Then clone the repository and you can run the installation script: $ git clone https://github.com/metalelf0/gnome-terminal-colors.git $ cd gnome-terminal-colors-solarized $ ./install.sh And just follow the instructions. To run this script remotely or via cron (or from any shell where `DBUS_SESSION_BUS_ADDRESS` is not set), you need to start a dbus connection: $ dbus-launch ./install.sh Uninstall --------- Change to another profile in Gnome Terminal, then remove the Solarized profile by running: ### Gnome 3.6 or lower $ rm -r ~/.gconf/apps/gnome-terminal/profiles/Solarized/ $ gconftool-2 --recursive-unset /apps/gnome-terminal ### Gnome 3.8 or higher Be sure to have the dconf-cli package installed and do: $ dconf reset -f /org/gnome/terminal/legacy/profiles:/PROFILE_ID" Replace PROFILE_ID by your profile ID (you can get it in your profile configuration in gnome-terminal). Themes ------ Each theme has is own folder in the `colors` dir. It contains the following files: * bd_color: bold color * bg_color: background color * fg_color: foreground color * palette: list of colors for all standard color codes. No additional configuration is needed to add a theme, the installation script just list at launch the children folders in the `colors` dir. Dircolors --------- The installation script will ask if a solarized dircolors is wanted. It will be downloaded and installed as `~/.dir_colors/dircolors`. On CentOS, it can be an issue (see issue #62), as the default setup use `~/.dir_colors` as dircolors. In that case, you should manually move `~/.dir_colors` as `~/.dir_colors/dircolors` before starting the installation script. If the dircolors is not applied, please check that your shell actually source your dircolors: ``` if [ -f ~/.dir_colors/dircolors ] then eval `dircolors ~/.dir_colors/dircolors` fi ``` This should not be necessary on major distributions (such as Ubuntu, Fedora, etc.) but could be on ArchLinux, Gentoo and others. Importing iTerm themes ---------------------- It's possible to import an iTerm colorscheme to a gnome-terminal one. Use the script `tools/import_from_iterm.rb`. Prerequisites: a working ruby installation with the `nokogiri-plist` ruby gem (`gem install nokogiri-plist`). Example call: `tools/import_from_iterm.rb my_iterm_colorscheme.itermcolors my_iterm_colorscheme` Contributors ------------ The original [Gnome Terminal Colors Solarized repository] project: * Sigurd Gartmann * Anthony Ruhier * Paul Thomson * Techlive Zheng * Daniel Graña Colorscheme authors ------------------- * [Solarized][Solarized homepage]: Ethan Schoonover * [Gotham][vim-gotham]: Andrea Leopardi * [Hemisu][vim-hemisu]: Noah Frederick Solarized === Colors ------ Only the foreground, background and highlight colors are different in the light and dark color sets, as one of the main ideas behind Ethan Schonoovers work is to use the same colors in the palette for both. See the [Solarized homepage] for theory behind the colors, screenshots, details and colorscheme versions for Vim, Mutt, popular terminal emulators and other applications. For the original works of Ethan Schoonover, visit the [Solarized repository]. The scripts for Gnome Terminal is maintained in [Gnome Terminal Colors Solarized repository]. Colorscheme authors ------------------- * [Solarized][Solarized homepage]: Ethan Schoonover * [Gotham][vim-gotham]: Andrea Leopardi * [Hemisu][vim-hemisu]: Noah Frederick * [Dracula][dracula]: Zeno Rocha Solarized === Colors ------ Only the foreground, background and highlight colors are different in the light and dark color sets, as one of the main ideas behind Ethan Schonoovers work is to use the same colors in the palette for both. See the [Solarized homepage] for theory behind the colors, screenshots, details and colorscheme versions for Vim, Mutt, popular terminal emulators and other applications. For the original works of Ethan Schoonover, visit the [Solarized repository]. The scripts for Gnome Terminal is maintained in [Gnome Terminal Colors Solarized repository]. FAQ === Conflicting background colors in VIM ------------------------------------ Use the 16 colors terminal option to get VIM to look like GVIM with solarized colors. set t_Co=16 [mate-terminal-colors-solarized]: https://github.com/cledoux/mate-terminal-colors-solarized [Solarized homepage]: http://ethanschoonover.com/solarized [Solarized repository]: https://github.com/altercation/solarized [Gnome Terminal Colors Solarized repository]: https://github.com/sigurdga/gnome-terminal-colors-solarized [dircolors solarised color theme]: https://github.com/seebi/dircolors-solarized [Gotham] [vim-gotham]: https://github.com/whatyouhide/vim-gotham [vim-hemisu]: https://github.com/noahfrederick/vim-hemisu [dracula]: https://github.com/zenorocha/dracula-theme ================================================ FILE: colors/challenger-deep/bd_color ================================================ #cbe3e7 ================================================ FILE: colors/challenger-deep/bg_color ================================================ #1b182c ================================================ FILE: colors/challenger-deep/fg_color ================================================ #cbe3e7 ================================================ FILE: colors/challenger-deep/palette ================================================ #565575 #ff8080 #95ffa4 #ffe9aa #91ddff #c991e1 #aaffe4 #cbe3e7 #100e23 #ff5458 #62d196 #ffb378 #65b2ff #906cff #63f2f1 #a6b3cc ================================================ FILE: colors/dark/palette ================================================ #070736364242 #DCDC32322F2F #858599990000 #B5B589890000 #26268B8BD2D2 #D3D336368282 #2A2AA1A19898 #EEEEE8E8D5D5 #00002B2B3636 #CBCB4B4B1616 #58586E6E7575 #65657B7B8383 #838394949696 #6C6C7171C4C4 #9393A1A1A1A1 #FDFDF6F6E3E3 ================================================ FILE: colors/dark_alternative/palette ================================================ #00002B2B3636 #CBCB4B4B1616 #58586E6E7575 #65657B7B8383 #838394949696 #6C6C7171C4C4 #9393A1A1A1A1 #FDFDF6F6E3E3 #070736364242 #DCDC32322F2F #858599990000 #B5B589890000 #26268B8BD2D2 #D3D336368282 #2A2AA1A19898 #EEEEE8E8D5D5 ================================================ FILE: colors/dracula/README.md ================================================ Colorscheme dracula - imported from iterm on 2015-04-08 10:33:45 +0200 ================================================ FILE: colors/dracula/bd_color ================================================ #ffffffffffff ================================================ FILE: colors/dracula/bg_color ================================================ #1e1f1f4528e7 ================================================ FILE: colors/dracula/fg_color ================================================ #f8f8f8f8f2f2 ================================================ FILE: colors/dracula/palette ================================================ #000000000000 #ffff55555555 #5050fafa7b7b #f1f1fafa8c8c #bdbd9393f9f9 #ffff7979c6c6 #8b8be9e9fdfd #bbbbbbbbbbbb #555555555555 #ffff55555555 #5050fafa7b7b #f1f1fafa8c8c #bdbd9393f9f9 #ffff7979c6c6 #8b8be9e9fdfd #ffffffffffff ================================================ FILE: colors/gotham/README ================================================ # Gotham colorscheme https://github.com/whatyouhide/vim-gotham https://github.com/whatyouhide/gotham-contrib ================================================ FILE: colors/gotham/bd_color ================================================ #9898d1d1cece ================================================ FILE: colors/gotham/bg_color ================================================ #0a0a0f0f1414 ================================================ FILE: colors/gotham/fg_color ================================================ #9898d1d1cece ================================================ FILE: colors/gotham/palette ================================================ #0a0a0f0f1414 #c3c330302727 #2626a9a98b8b #ededb5b54b4b #191954546565 #4e4e51516565 #333385859d9d #9898d1d1cece #101015151b1b #d2d269693939 #08081f1f2d2d #242453536161 #090937374848 #88888b8ba5a5 #59599c9caaaa #d3d3ebebe9e9 ================================================ FILE: colors/gruvbox-dark/README.md ================================================ Colorscheme gruvbox-dark - imported from iterm on 2015-06-09 14:46:18 +0200 ================================================ FILE: colors/gruvbox-dark/bd_color ================================================ #000000000000 ================================================ FILE: colors/gruvbox-dark/bg_color ================================================ #282828282828 ================================================ FILE: colors/gruvbox-dark/fg_color ================================================ #ebebdbdbb2b2 ================================================ FILE: colors/gruvbox-dark/palette ================================================ #282828282828 #cccc24241d1d #989897971a1a #d7d799992121 #454585858888 #b1b162628686 #68689d9d6a6a #bdbdaeae9393 #7c7c6f6f6464 #fbfb49493434 #b8b8bbbb2626 #fafabdbd2f2f #8383a5a59898 #d3d386869b9b #8e8ec0c07c7c #ebebdbdbb2b2 ================================================ FILE: colors/gruvbox-light/README.md ================================================ Colorscheme gruvbox-light - imported from iterm on 2015-06-09 14:46:31 +0200 ================================================ FILE: colors/gruvbox-light/bd_color ================================================ #000000000000 ================================================ FILE: colors/gruvbox-light/bg_color ================================================ #fdfdf4f4c1c1 ================================================ FILE: colors/gruvbox-light/fg_color ================================================ #3c3c38383636 ================================================ FILE: colors/gruvbox-light/palette ================================================ #fdfdf4f4c1c1 #cccc24241d1d #989897971a1a #d7d799992121 #454585858888 #b1b162628686 #68689d9d6a6a #66665c5c5454 #a8a899998484 #9d9d00000606 #797974740e0e #b5b576761414 #070766667878 #8f8f3f3f7171 #42427b7b5858 #3c3c38383636 ================================================ FILE: colors/hemisu_dark/README.md ================================================ # Official dark hemisu colorscheme ================================================ FILE: colors/hemisu_dark/bd_color ================================================ #ffffffffffff ================================================ FILE: colors/hemisu_dark/bg_color ================================================ #000000000000 ================================================ FILE: colors/hemisu_dark/fg_color ================================================ #eeeeeeeeeeee ================================================ FILE: colors/hemisu_dark/palette ================================================ #444444444444 #ffff00005555 #b1b1d6d63131 #aeae9b9b7272 #6868bebee4e4 #b5b57777bcbc #57579a9a9f9f #eeeeeeeeeeee #777777777777 #d6d65e5e7676 #bbbbffffaaaa #ececffffc8c8 #9f9fd3d3e6e6 #e5e5c3c3e5e5 #b6b6e0e0e6e6 #ffffffffffff ================================================ FILE: colors/hemisu_light/README.md ================================================ # Official light hemisu colorscheme ================================================ FILE: colors/hemisu_light/bd_color ================================================ #000000000000 ================================================ FILE: colors/hemisu_light/bg_color ================================================ #ffffffffffff ================================================ FILE: colors/hemisu_light/fg_color ================================================ #282828282828 ================================================ FILE: colors/hemisu_light/palette ================================================ #777777777777 #ffff00005555 #737392920000 #50503d3d1515 #535381819292 #5c5c34345f5f #535381819292 #999999999999 #999999999999 #d6d65e5e7676 #9d9dc7c70000 #959576765656 #9e9eb3b3cdcd #a2a28484a5a5 #8585b2b2abab #bbbbbbbbbbbb ================================================ FILE: colors/jellybeans/bd_color ================================================ #adadadadadad ================================================ FILE: colors/jellybeans/bg_color ================================================ #151515151515 ================================================ FILE: colors/jellybeans/fg_color ================================================ #e8e8e8e8d3d3 ================================================ FILE: colors/jellybeans/palette_dconf ================================================ '#888888888888', '#cfcf6a6a4c4c', '#8787afaf5f5f', '#fafad0cf7a79', '#8181a3a3eded', '#c6c5b6b6eeee', '#8f8fbfbedcdc', '#e8e8e8e8d3d3', '#888888888888', '#cfcf6a6a4c4c', '#8787afaf5f5f', '#fafad0cf7a79', '#8181a3a3eded', '#c6c5b6b6eeee', '#8f8fbfbedcdc', '#e8e8e8e8d3d3' ================================================ FILE: colors/jellybeans/palette_gconf ================================================ #888888888888:#cfcf6a6a4c4c:#8787afaf5f5f:#fafad0cf7a79:#8181a3a3eded:#c6c5b6b6eeee:#8f8fbfbedcdc:#e8e8e8e8d3d3:#888888888888:#cfcf6a6a4c4c:#8787afaf5f5f:#fafad0cf7a79:#8181a3a3eded:#c6c5b6b6eeee:#8f8fbfbedcdc:#e8e8e8e8d3d3 ================================================ FILE: colors/light/palette ================================================ #070736364242 #DCDC32322F2F #858599990000 #B5B589890000 #26268B8BD2D2 #D3D336368282 #2A2AA1A19898 #EEEEE8E8D5D5 #00002B2B3636 #CBCB4B4B1616 #58586E6E7575 #65657B7B8383 #838394949696 #6C6C7171C4C4 #9393A1A1A1A1 #FDFDF6F6E3E3 ================================================ FILE: colors/nova/bd_color ================================================ #C5D4DD ================================================ FILE: colors/nova/bg_color ================================================ #3C4C55 ================================================ FILE: colors/nova/fg_color ================================================ #C5D4DD ================================================ FILE: colors/nova/palette ================================================ #3C4C55 #DF8C8C #A8CE93 #DADA93 #83AFE5 #9A93E1 #7FC1CA #C5D4DD #899BA6 #F2C38F #A8CE93 #DADA93 #83AFE5 #D18EC2 #7FC1CA #E6EEF3 ================================================ FILE: colors/solarized_dark/README.md ================================================ # Official dark solarized colorscheme http://ethanschoonover.com/solarized ================================================ FILE: colors/solarized_dark/bd_color ================================================ #9393a1a1a1a1 ================================================ FILE: colors/solarized_dark/bg_color ================================================ #00002B2B3636 ================================================ FILE: colors/solarized_dark/fg_color ================================================ #838394949696 ================================================ FILE: colors/solarized_dark/palette ================================================ #070736364242 #DCDC32322F2F #858599990000 #B5B589890000 #26268B8BD2D2 #D3D336368282 #2A2AA1A19898 #EEEEE8E8D5D5 #00002B2B3636 #CBCB4B4B1616 #58586E6E7575 #65657B7B8383 #838394949696 #6C6C7171C4C4 #9393A1A1A1A1 #FDFDF6F6E3E3 ================================================ FILE: colors/solarized_dark_alternative/README.md ================================================ # Dark solarized alternative, by reychino (Reinaldo Zapata) Dark solarized colorscheme fork, with a different palette, to avoid the "invisible" text bug. ================================================ FILE: colors/solarized_dark_alternative/bd_color ================================================ #9393a1a1a1a1 ================================================ FILE: colors/solarized_dark_alternative/bg_color ================================================ #00002B2B3636 ================================================ FILE: colors/solarized_dark_alternative/fg_color ================================================ #838394949696 ================================================ FILE: colors/solarized_dark_alternative/palette ================================================ #00002B2B3636 #CBCB4B4B1616 #58586E6E7575 #65657B7B8383 #838394949696 #6C6C7171C4C4 #9393A1A1A1A1 #FDFDF6F6E3E3 #070736364242 #DCDC32322F2F #858599990000 #B5B589890000 #26268B8BD2D2 #D3D336368282 #2A2AA1A19898 #EEEEE8E8D5D5 ================================================ FILE: colors/solarized_light/README.md ================================================ # Official light solarized colorscheme http://ethanschoonover.com/solarized ================================================ FILE: colors/solarized_light/bd_color ================================================ #58586e6e7575 ================================================ FILE: colors/solarized_light/bg_color ================================================ #fdfdf6f6e3e3 ================================================ FILE: colors/solarized_light/fg_color ================================================ #65657b7b8383 ================================================ FILE: colors/solarized_light/palette ================================================ #070736364242 #DCDC32322F2F #858599990000 #B5B589890000 #26268B8BD2D2 #D3D336368282 #2A2AA1A19898 #EEEEE8E8D5D5 #00002B2B3636 #CBCB4B4B1616 #58586E6E7575 #65657B7B8383 #838394949696 #6C6C7171C4C4 #9393A1A1A1A1 #FDFDF6F6E3E3 ================================================ FILE: install.sh ================================================ #!/usr/bin/env bash dir=$(dirname "$0") declare -a schemes schemes=($(cd $dir/colors && echo * && cd - > /dev/null)) source $dir/src/tools.sh source $dir/src/profiles.sh source $dir/src/dircolors.sh show_help() { echo "Usage: install.sh [-h] [-s ] [-p ]" echo echo "Options" echo " -h, --help" echo " Show this information" echo " -s scheme, --scheme scheme, --scheme=scheme" echo " Color scheme to be used (will be asked otherwise)" echo " -p profile, --profile profile, --profile profile" echo " Gnome Terminal profile to overwrite (will be asked otherwise)" echo " --install-dircolors, --skip-dircolors" echo " Do or skip the dircolors installation in a non interactive mode" } validate_scheme() { local profile=$1 in_array $scheme "${schemes[@]}" || die "$scheme is not a valid scheme" 2 } set_profile_colors() { local profile=$1 local scheme=$2 local scheme_dir=$dir/colors/$scheme local bg_color_file=$scheme_dir/bg_color local fg_color_file=$scheme_dir/fg_color local bd_color_file=$scheme_dir/bd_color if [ "$newGnome" = "1" ] then local profile_path=$dconfdir/$profile # set color palette dconf write $profile_path/palette "$(to_dconf < $scheme_dir/palette)" # set foreground, background and highlight color dconf write $profile_path/bold-color "'$(cat $bd_color_file)'" dconf write $profile_path/background-color "'$(cat $bg_color_file)'" dconf write $profile_path/foreground-color "'$(cat $fg_color_file)'" # make sure the profile is set to not use theme colors dconf write $profile_path/use-theme-colors "false" # set highlighted color to be different from foreground color dconf write $profile_path/bold-color-same-as-fg "false" else local profile_path=$gconfdir/$profile # set color palette gconftool-2 -s -t string $profile_path/palette "$(to_gconf < $scheme_dir/palette)" # set foreground, background and highlight color gconftool-2 -s -t string $profile_path/bold_color $(cat $bd_color_file) gconftool-2 -s -t string $profile_path/background_color \ $(cat $bg_color_file) gconftool-2 -s -t string $profile_path/foreground_color \ $(cat $fg_color_file) # make sure the profile is set to not use theme colors gconftool-2 -s -t bool $profile_path/use_theme_colors false # set highlighted color to be different from foreground color gconftool-2 -s -t bool $profile_path/bold_color_same_as_fg false fi } interactive_help() { echo echo -en "This script will ask you which color scheme you want, and which " echo -en "Gnome Terminal profile to overwrite.\n" echo echo -en "Please note that there is no uninstall option yet. If you do not " echo -en "wish to overwrite any of your profiles, you should create a new " echo -en "profile before you run this script. However, you can reset your " echo -en "colors to the Gnome default, by running:\n" echo echo " Gnome >= 3.8 dconf reset -f /org/gnome/terminal/legacy/profiles:/" echo " Gnome < 3.8 gconftool-2 --recursive-unset /apps/gnome-terminal" echo echo -en "By default, it runs in the interactive mode, but it also can be " echo -en "run non-interactively, just feed it with the necessary options, " echo -en "see 'install.sh --help' for details.\n" echo } interactive_select_scheme() { echo "Please select a color scheme:" select scheme do if [[ -z $scheme ]] then die "ERROR: Invalid selection -- ABORTING!" 2 fi break done echo } interactive_confirm() { local confirmation echo "You have selected:" echo echo " Scheme: $scheme" echo " Profile: $(get_profile_name $profile) ($profile)" echo echo "Are you sure you want to overwrite the selected profile?" echo -n "(YES to continue) " read confirmation if [[ $(echo $confirmation | tr '[:lower:]' '[:upper:]') != YES ]] then die "ERROR: Confirmation failed -- ABORTING!" fi echo "Confirmation received -- applying settings" } while [ $# -gt 0 ] do case $1 in -h | --help ) show_help exit 0 ;; --scheme=* ) scheme=${1#*=} ;; -s | --scheme ) scheme=$2 shift ;; --profile=* ) profile=${1#*=} ;; -p | --profile ) profile=$2 shift ;; --install-dircolors ) install_dircolors=true ;; --skip-dircolors ) install_dircolors=false ;; esac shift done if [[ -z "$scheme" ]] || [[ -z "$profile" ]] then interactive_help fi if [[ -n "$scheme" ]] then validate_scheme $scheme else interactive_select_scheme "${schemes[@]}" fi if [[ -n "$profile" ]] then if [ "$newGnome" = "1" ] then profile="$(get_uuid "$profile")" fi validate_profile $profile else if [ "$newGnome" = "1" ] then check_empty_profile fi interactive_select_profile "${profiles[@]}" interactive_confirm fi set_profile_colors $profile $scheme if [ -n "$install_dircolors" ] then if "$install_dircolors" then copy_dircolors fi else check_dircolors || warning_message_dircolors fi ================================================ FILE: src/color_conversions.rb ================================================ # input: a string like "rgb(68,68,68)" # output: the hex code like #444444444444 def rgb_to_48bit_hex(rgb_color) colors = rgb_color.gsub("rgb\(", "").gsub("\)", "").split(",") hex_color = "#" colors.each do |color| hex_color += sprintf("%02x%02x", color.to_i, color.to_i) end return hex_color end # input: an array of colors in rgb format, like: [ 'rgb(68,68,68)', 'rgb(255,0,85)', ... ] # output: a dconf-compatible 48 bit color palette, like: '#444444444444', '#ffff00005555', ... def rgb_palette_to_dconf(rgb_palette) hex_palette = rgb_palette_to_hex(rgb_palette) hex_palette.map { |hex_color| "'#{hex_color}'" }.join(", ") end # input: an array of colors in rgb format, like: [ 'rgb(68,68,68)', 'rgb(255,0,85)', ... ] # output: a gconf-compatible 48 bit color palette, like: #444444444444:#ffff00005555:... def rgb_palette_to_gconf(rgb_palette) hex_palette = rgb_palette_to_hex(rgb_palette) hex_palette.join(":") end def rgb_palette_to_hex(rgb_palette) hex_colors = [] rgb_palette.each do |rgb_color| hex_colors << rgb_to_48bit_hex(rgb_color) end hex_colors end # Example script: # rgb_palette = ['rgb(68,68,68)','rgb(255,0,85)','rgb(177,214,49)','rgb(174,155,114)','rgb(104,190,228)','rgb(181,119,188)','rgb(87,154,159)','rgb(238,238,238)','rgb(119,119,119)','rgb(214,94,118)','rgb(187,255,170)','rgb(236,255,200)','rgb(159,211,230)','rgb(229,195,229)','rgb(182,224,230)','rgb(255,255,255)'] # background_color = 'rgb(0,0,0)' # foreground_color = 'rgb(238,238,238)' # bold_color = 'rgb(255,255,255)' # puts " --- Gconf:" # puts rgb_palette_to_gconf rgb_palette # puts " --- Dconf:" # puts rgb_palette_to_dconf rgb_palette # puts " --- Background:" # puts rgb_to_48bit_hex background_color # puts " --- Foreground:" # puts rgb_to_48bit_hex foreground_color # puts " --- Bold:" # puts rgb_to_48bit_hex bold_color ================================================ FILE: src/dircolors.sh ================================================ #!/usr/bin/env bash dircolors_checked=false DIRCOLORS_DIR="$(echo ~/.dir_colors)" DIRCOLORS_SOLARIZED="$(pwd)" DIRCOLORS_REPO_ADRESS="https://github.com/seebi/dircolors-solarized" DIRCOLORS_DL_ADRESS="https://raw.github.com/seebi/dircolors-solarized/master/" dl_dircolors() { echo eval "wget -O "$DIRCOLORS_SOLARIZED/dircolors" \ "$DIRCOLORS_DL_ADRESS/dircolors.ansi-$scheme"" valid=$? if [ ! "$valid" == "0" -o ! -e "$DIRCOLORS_SOLARIZED/dircolors" ] then echo -e "Download failed, dircolors will not be copied but you " echo -en "can install it from the official repository : " echo "$DIRCOLORS_REPO_ADRESS" return 1 fi return 0 } copy_dircolors() { dircolors_dest_path="$DIRCOLORS_DIR/dircolors" eval dl_dircolors dl_ok=$? if [ $dl_ok ] # CentOS uses ~/.dir_colors as dir_colors file then if [ -f "$DIRCOLORS_DIR" ] then dircolors_dest_path="$DIRCOLORS_DIR" else mkdir -p "$DIRCOLORS_DIR" fi if [ -f "$dircolors_dest_path" ] then mv "$dircolors_dest_path" "$dircolors_dest_path.old" echo -n "$dircolors_dest_path already exists, renaming it to " echo "$dircolors_dest_path.old" fi fi cp "$DIRCOLORS_SOLARIZED/dircolors" "$dircolors_dest_path" echo echo "The new dircolors have been installed as $dircolors_dest_path." echo echo -n "Add \"eval \`dircolors /path/to/dircolorsdb\`\" in your shell " echo "configuration file (.bashrc, .zshrc, etc...) to use new dircolors." echo "For Fish, add the following to config.fish instead:" echo -e "\teval (dircolors /path/to/dircolorsdb | head -n 1 | sed 's/^LS_COLORS=/set -x LS_COLORS /;s/;$//')" echo echo -en "Do not forget to remove old dircolors from your shell " echo -en "configuration file if they were named differently than " echo -en "the one newly installed.\n" echo } msg_create_dircolors() { echo -en "A dircolors adapted to solarized can be automatically " echo -en "downloaded.\n" echo echo -en "1) Download seebi' dircolors-solarized: " echo -en "https://github.com/seebi/dircolors-solarized\n" echo echo -en "2) [DEFAULT] I don't need any dircolors.\n" } msg_already_existing_dircolors() { echo -en "A dircolors already exists in $DIRCOLORS_DIR, but can be " echo -en "incompatible with the solarized color scheme causing some colors " echo -en "problems when doing a \"ls\".\n" echo echo -en "1) Replace the actual dircolors by seebi' " echo -en "dircolors-solarized: " echo -en "https://github.com/seebi/dircolors-solarized (the actual " echo -en "dircolors will be keeped as backup).\n" echo echo -en "2) [DEFAULT] I am awared about this potentiall problem and will " echo -en "check my dircolors (default path: ~/.dir_colors/dircolors) " echo -en "in case of conflict.\n" } interactive_dircolors() { already_existing_dircolors=$1 noselect=true while $noselect do echo if $already_existing_dircolors then msg_already_existing_dircolors else msg_create_dircolors fi echo read -p "Enter your choice : [2] " selection selection=${selection:-2} if [[ "$selection" -gt 2 || "$selection" -lt 1 ]] then echo "$selection is not a valid entry. Please Restart" echo noselect=true else noselect=false fi done if [ "$selection" == 1 ] then copy_dircolors fi } check_dircolors() { nonempty=false if [ -d "$DIRCOLORS_DIR" ] then [ "$(ls -A $DIRCOLORS_DIR)" ] && nonempty=true || nonempty=false fi interactive_dircolors $nonempty return $(! $nonempty) } warning_message_dircolors() { echo -en "If there is any problem with the colors when doing a \"ls\", " echo -en "please check your dircolors.\n" } ================================================ FILE: src/profiles.sh ================================================ #!/usr/bin/env bash gnomeVersion="$(expr "$(gnome-terminal --version)" : '.* \(.*[.].*[.].*\)$')" dircolors_checked=false declare -a profiles if [ "$newGnome" = "1" ] then profiles=($(dconf list $dconfdir/ | grep ^: | sed 's/\///g')) else profiles=($(gconftool-2 -R $gconfdir | grep $gconfdir | cut -d/ -f5 | \ cut -d: -f1)) fi create_new_profile() { profile_id="$(uuidgen)" dconf write $dconfdir/default "'$profile_id'" dconf write $dconfdir/list "['$profile_id']" profile_dir="$dconfdir/:$profile_id" dconf write $profile_dir/visible-name "'Default'" } get_uuid() { # Print the UUID linked to the profile name sent in parameter local profile_name=$1 for i in ${!profiles[*]} do if [[ "$(dconf read $dconfdir/${profiles[i]}/visible-name)" == \ "'$profile_name'" ]] then echo "${profiles[i]}" return 0 fi done echo "$profile_name" } validate_profile() { local profile=$1 in_array $profile "${profiles[@]}" || die "$profile is not a valid profile" 3 } get_profile_name() { local profile_name # dconf still return "" when the key does not exist, gconftool-2 return 0, # but it does priint error message to STDERR, and command substitution # only gets STDOUT which means nothing at this point. if [ "$newGnome" = "1" ] then profile_name="$(dconf read $dconfdir/$1/visible-name | sed s/^\'// | \ sed s/\'$//)" else profile_name=$(gconftool-2 -g $gconfdir/$1/visible_name) fi [[ -z $profile_name ]] && die "$1 (No name)" 3 echo $profile_name } interactive_new_profile() { local confirmation echo "No profile found" echo "You need to create a new default profile to continue. Continue?" echo -n "(YES to continue) " read confirmation if [[ $(echo $confirmation | tr '[:lower:]' '[:upper:]') != YES ]] then die "ERROR: Confirmation failed -- ABORTING!" fi echo -e "Profile \"Default\" created\n" } interactive_select_profile() { local profile_key local profile_name local profile_names local profile_count=$# declare -a profile_names while [ $# -gt 0 ] do profile_names[$(($profile_count - $#))]=$(get_profile_name $1) shift done set -- "${profile_names[@]}" echo "Please select a Gnome Terminal profile:" select profile_name do if [[ -z $profile_name ]] then die "ERROR: Invalid selection -- ABORTING!" 3 fi profile_key=$(expr ${REPLY} - 1) break done echo profile=${profiles[$profile_key]} } check_empty_profile() { if [ "$profiles" = "" ] then interactive_new_profile create_new_profile profiles=($(dconf list $dconfdir/ | grep ^: | sed 's/\///g')) fi } ================================================ FILE: src/tools.sh ================================================ #!/usr/bin/env bash gnomeVersion="$(expr \ "$(LANGUAGE=en_US.UTF-8 gnome-terminal --version)" : \ '^[^[:digit:]]* \(\([[:digit:]]*\.*\)*\)' \ )" # newGnome=1 if the gnome-terminal version >= 3.8 if [[ ("$(echo "$gnomeVersion" | cut -d"." -f1)" = "3" && \ "$(echo "$gnomeVersion" | cut -d"." -f2)" -ge 8) || \ "$(echo "$gnomeVersion" | cut -d"." -f1)" -ge 4 ]] then newGnome="1" dconfdir=/org/gnome/terminal/legacy/profiles: else newGnome=0 gconfdir=/apps/gnome-terminal/profiles fi die() { echo $1 exit ${2:-1} } in_array() { local e for e in "${@:2}"; do [[ $e == $1 ]] && return 0; done return 1 } to_gconf() { tr '\n' \: | sed 's#:$#\n#' } to_dconf() { tr '\n' '~' | sed -e "s#~\$#']\n#" -e "s#~#', '#g" -e "s#^#['#" } ================================================ FILE: tools/import_from_iterm.rb ================================================ #!/usr/bin/env ruby # imports an iTerm color profile to gnome terminal # syntax: import_from_iterm.rb require 'nokogiri' require 'nokogiri-plist' class Color attr_accessor :red attr_accessor :green attr_accessor :blue def initialize(args={}) args.each_pair do |k, v| self.send("#{k}=", v) end end def to_48bit_hex red_part = sprintf("%04x", (red.to_f * 65535).round) green_part = sprintf("%04x", (green.to_f * 65535).round) blue_part = sprintf("%04x", (blue.to_f * 65535).round) "##{red_part}#{green_part}#{blue_part}" end end file_path = ARGV[0] profile_name = ARGV[1] unless file_path && profile_name puts "Syntax: import_from_iterm.rb " exit(-1) end if Dir.exists?("colors/#{profile_name}") puts "Color #{profile_name} already exists, delete it or choose a different name" exit(-1) end input = File.open(file_path) plist = Nokogiri::PList(input) input.close # First of all, we need to collect values for each ansi color # Label inside plist file is like "Ansi 0 Color" colors = {} (0).upto(15) do |count| label = "Ansi #{count} Color" data = plist[label] colors[label] = Color.new( red: data['Red Component'], green: data['Green Component'], blue: data['Blue Component'], ) end # Now, we need to collect other data: background color, foreground color, and bold color ['Background Color', 'Foreground Color', 'Bold Color'].each do |label| data = plist[label] || {} colors[label] = Color.new( red: data['Red Component'], green: data['Green Component'], blue: data['Blue Component'], ) end # Very good. Now we have all we need to generate the Gnome Terminal color profile. # Let's start creating a directory Dir.mkdir("colors/#{profile_name}") # now, the palettes. Let's build it first palette = [] (0).upto(15) do |count| label = "Ansi #{count} Color" color_code_48_bit = colors[label].to_48bit_hex palette << color_code_48_bit end # now let's write the dconf palette File.open("colors/#{profile_name}/palette_dconf", "w") do |f| f.puts palette.map { |color| "'#{color}'"}.join(", ") end # and the gconf palette File.open("colors/#{profile_name}/palette_gconf", "w") do |f| f.puts palette.join(":") end # bold color File.open("colors/#{profile_name}/bd_color", "w") do |f| f.puts colors['Bold Color'].to_48bit_hex end # background color File.open("colors/#{profile_name}/bg_color", "w") do |f| f.puts colors['Background Color'].to_48bit_hex end # Foreground color File.open("colors/#{profile_name}/fg_color", "w") do |f| f.puts colors['Foreground Color'].to_48bit_hex end # A little README.md file File.open("colors/#{profile_name}/README.md", "w") do |f| f.puts "Colorscheme #{profile_name} - imported from iterm on #{Time.now}" end puts "Done!"