From d6730b40c9577b0667d99324d0faa7e1a436251f Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 23 Oct 2012 13:44:02 +1300 Subject: [PATCH] Use \033 instead of \e for color codes, which seems to be more widely supported. --- lib/git/branch_shortcuts.sh | 2 +- lib/git/fallback/status_shortcuts_shell.sh | 28 +++++++++--------- lib/git/helpers.sh | 2 +- lib/git/keybindings.sh | 4 +-- lib/git/shell_shortcuts.sh | 4 +-- lib/git/status_shortcuts.rb | 34 +++++++++++----------- lib/git/status_shortcuts.sh | 8 ++--- lib/scm_breeze.sh | 2 +- 8 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index e244227..c57e646 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -25,7 +25,7 @@ function _scmb_git_branch_shortcuts { line_count = output.lines.to_a.size output.lines.each_with_index do |line, i| spaces = (line_count > 9 && i < 9 ? " " : " ") - puts line.sub(/^([ *]{2})/, "\\\1\e[2;37m[\e[0m#{i+1}\e[2;37m]\e[0m" << spaces) + puts line.sub(/^([ *]{2})/, "\\\1\033[2;37m[\033[0m#{i+1}\033[2;37m]\033[0m" << spaces) end EOF )" diff --git a/lib/git/fallback/status_shortcuts_shell.sh b/lib/git/fallback/status_shortcuts_shell.sh index a1f54c7..86c6694 100644 --- a/lib/git/fallback/status_shortcuts_shell.sh +++ b/lib/git/fallback/status_shortcuts_shell.sh @@ -35,17 +35,17 @@ git_status_shortcuts() { fi # Colors - local c_rst="\e[0m" - local c_branch="\e[1m" - local c_header="\e[0m" - local c_dark="\e[2;37m" - local c_del="\e[0;31m" - local c_mod="\e[0;32m" - local c_new="\e[0;33m" - local c_ren="\e[0;34m" - local c_cpy="\e[0;33m" - local c_ign="\e[0;36m" - # Following colors must be prepended with modifiers e.g. '\e[1;', '\e[0;' + local c_rst="\033[0m" + local c_branch="\033[1m" + local c_header="\033[0m" + local c_dark="\033[2;37m" + local c_del="\033[0;31m" + local c_mod="\033[0;32m" + local c_new="\033[0;33m" + local c_ren="\033[0;34m" + local c_cpy="\033[0;33m" + local c_ign="\033[0;36m" + # Following colors must be prepended with modifiers e.g. '\033[1;', '\033[0;' local c_grp_1="33m"; local c_grp_2="31m"; local c_grp_3="32m"; local c_grp_4="36m" local f=1; local e=1 # Counters for number of files, and ENV variables @@ -100,8 +100,8 @@ git_status_shortcuts() { for heading in 'Changes to be committed' 'Unmerged paths' 'Changes not staged for commit' 'Untracked files'; do # If no group specified as param, or specified group is current group if [ -z "$1" ] || [[ "$1" == "$grp_num" ]]; then - local c_arrow="\e[1;$(eval echo \$c_grp_$grp_num)" - local c_hash="\e[0;$(eval echo \$c_grp_$grp_num)" + local c_arrow="\033[1;$(eval echo \$c_grp_$grp_num)" + local c_hash="\033[0;$(eval echo \$c_grp_$grp_num)" if [ -n "${stat_grp[$grp_num]}" ]; then echo -e "$c_arrow➤$c_header $heading\n$c_hash#$c_rst" _gs_output_file_group $grp_num @@ -121,7 +121,7 @@ git_status_shortcuts() { _gs_output_file_group() { for i in ${stat_grp[$1]}; do # Print colored hashes & files based on modification groups - local c_group="\e[0;$(eval echo -e \$c_grp_$1)" + local c_group="\033[0;$(eval echo -e \$c_grp_$1)" # Deduce relative path based on current working directory if [ -z "$project_root" ]; then diff --git a/lib/git/helpers.sh b/lib/git/helpers.sh index e73bd6d..f2d4107 100644 --- a/lib/git/helpers.sh +++ b/lib/git/helpers.sh @@ -9,7 +9,7 @@ function find_in_cwd_or_parent() { function fail_if_not_git_repo() { if ! find_in_cwd_or_parent ".git" > /dev/null; then - echo -e "\e[31mNot a git repository (or any of the parent directories)\e[0m" + echo -e "\033[31mNot a git repository (or any of the parent directories)\033[0m" return 1 fi return 0 diff --git a/lib/git/keybindings.sh b/lib/git/keybindings.sh index 3dd47e0..d077353 100644 --- a/lib/git/keybindings.sh +++ b/lib/git/keybindings.sh @@ -28,10 +28,10 @@ if [[ "$git_keyboard_shortcuts_enabled" = "true" ]]; then if ! set -o | grep -q '^vi .*on$'; then if [[ $shell == "zsh" ]]; then _bind "$git_commit_all_keys" " git_commit_all""\n" - _bind "$git_add_and_commit_keys" " \e[1~ git_add_and_commit ""\n" + _bind "$git_add_and_commit_keys" " \033[1~ git_add_and_commit ""\n" else _bind "$git_commit_all_keys" "\" git_commit_all\n\"" - _bind "$git_add_and_commit_keys" "\"\e[1~ git_add_and_commit \n\"" + _bind "$git_add_and_commit_keys" "\"\033[1~ git_add_and_commit \n\"" fi fi diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 865f0e1..1134fdd 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -126,7 +126,7 @@ function ls_with_file_shortcuts { fi if [ "$(echo "$ll_output" | wc -l)" -gt "50" ]; then - echo -e "\e[33mToo many files to create shortcuts. Running plain ll command...\e[0m" + echo -e "\033[33mToo many files to create shortcuts. Running plain ll command...\033[0m" echo "$ll_output" return 1 fi @@ -138,7 +138,7 @@ e = 1 re = /^(([^ ]* +){8})/ output.lines.each do |line| next unless line.match(re) - puts line.sub(re, "\\\1\e[2;37m[\e[0m#{e}\e[2;37m]\e[0m" << (e < 10 ? " " : " ")) + puts line.sub(re, "\\\1\033[2;37m[\033[0m#{e}\033[2;37m]\033[0m" << (e < 10 ? " " : " ")) e += 1 end EOF diff --git a/lib/git/status_shortcuts.rb b/lib/git/status_shortcuts.rb index cd7d8ea..fcb37ec 100644 --- a/lib/git/status_shortcuts.rb +++ b/lib/git/status_shortcuts.rb @@ -34,21 +34,21 @@ exit if @changes.size > ENV["gs_max_changes"].to_i # Colors @c = { - :rst => "\e[0m", - :del => "\e[0;31m", - :mod => "\e[0;32m", - :new => "\e[0;33m", - :ren => "\e[0;34m", - :cpy => "\e[0;33m", - :typ => "\e[0;35m", - :unt => "\e[0;36m", - :dark => "\e[2;37m", - :branch => "\e[1m", - :header => "\e[0m" + :rst => "\033[0m", + :del => "\033[0;31m", + :mod => "\033[0;32m", + :new => "\033[0;33m", + :ren => "\033[0;34m", + :cpy => "\033[0;33m", + :typ => "\033[0;35m", + :unt => "\033[0;36m", + :dark => "\033[2;37m", + :branch => "\033[1m", + :header => "\033[0m" } -# Following colors must be prepended with modifiers e.g. '\e[1;', '\e[0;' +# Following colors must be prepended with modifiers e.g. '\033[1;', '\033[0;' @group_c = { :staged => "33m", :unmerged => "31m", @@ -74,7 +74,7 @@ ahead = @ahead ? " #{@c[:dark]}| #{@c[:new]}+#{@ahead}#{@c[:rst]}" : "" # If no changes, just display green no changes message and exit here if @git_status == "" - puts "%s#%s On branch: %s#{@branch}#{ahead} %s| \e[0;32mNo changes (working directory clean)%s" % [ + puts "%s#%s On branch: %s#{@branch}#{ahead} %s| \033[0;32mNo changes (working directory clean)%s" % [ @c[:dark], @c[:rst], @c[:branch], @c[:dark], @c[:rst] ] exit @@ -99,7 +99,7 @@ end # If changed 'file' is actually a git submodule if @gitmodules.include?(file) # Parse long git status for submodule summaries - @git_status_long = `git status`.gsub(/\e\[[^m]*m/, "") # (strip colors) + @git_status_long = `git status`.gsub(/\033\[[^m]*m/, "") # (strip colors) end end @@ -148,7 +148,7 @@ end # Output files def output_file_group(group) # Print colored hashes & files based on modification groups - c_group = "\e[0;#{@group_c[group]}" + c_group = "\033[0;#{@group_c[group]}" @stat_hash[group].each do |h| @e += 1 @@ -194,8 +194,8 @@ end # Allow filtering by specific group (by string or integer) if !ARGV[0] || ARGV[0] == group.to_s || ARGV[0] == (i+1).to_s; then if !@stat_hash[group].empty? - c_arrow="\e[1;#{@group_c[group]}" - c_hash="\e[0;#{@group_c[group]}" + c_arrow="\033[1;#{@group_c[group]}" + c_hash="\033[0;#{@group_c[group]}" puts "#{c_arrow}➤#{@c[:header]} #{heading}\n#{c_hash}##{@c[:rst]}" output_file_group(group) end diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index 448b6ad..345dcb4 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -29,7 +29,7 @@ git_status_shortcuts() { if [[ -z "$cmd_output" ]]; then # Just show regular git status if ruby script returns nothing. git status - echo -e "\n\e[33mThere were more than $gs_max_changes changed files. SCM Breeze has fallen back to standard \`git status\` for performance reasons.\e[0m" + echo -e "\n\033[33mThere were more than $gs_max_changes changed files. SCM Breeze has fallen back to standard \`git status\` for performance reasons.\033[0m" return 1 fi # Fetch list of files from last line of script output @@ -106,7 +106,7 @@ git_show_affected_files(){ for file in $(git show --pretty="format:" --name-only $@ | \grep -v '^$'); do let f++ export $git_env_char$f=$file # Export numbered variable. - echo -e "# \e[2;37m[\e[0m$f\e[2;37m]\e[0m $file" + echo -e "# \033[2;37m[\033[0m$f\033[2;37m]\033[0m $file" done; echo "# " } @@ -187,7 +187,7 @@ git_commit_prompt() { eval $@ # run any prequisite commands echo $commit_msg | git commit -F - | tail -n +2 else - echo -e "\e[0;31mAborting commit due to empty commit message.\e[0m" + echo -e "\033[0;31mAborting commit due to empty commit message.\033[0m" fi escaped=$(echo "$commit_msg" | sed -e 's/"/\\"/g' -e 's/!/"'"'"'!'"'"'"/g') @@ -206,7 +206,7 @@ git_commit_all() { fail_if_not_git_repo || return 1 changes=$(git status --porcelain | wc -l) if [ "$changes" -gt 0 ]; then - echo -e "\e[0;33mCommitting all files (\e[0;31m$changes\e[0;33m)\e[0m" + echo -e "\033[0;33mCommitting all files (\033[0;31m$changes\033[0;33m)\033[0m" git_commit_prompt "git add -A" else echo "# No changed files to commit." diff --git a/lib/scm_breeze.sh b/lib/scm_breeze.sh index e4163d1..180b5cb 100644 --- a/lib/scm_breeze.sh +++ b/lib/scm_breeze.sh @@ -44,7 +44,7 @@ _create_or_patch_scmbrc() { cd "$HOME" # If the patch cannot be applied cleanly, show the updates and tell user to update file manually. if ! patch -f "$HOME/.$prefix""scmbrc" $patchfile; then - printf "== \e[0;31mUpdates could not be applied to '\e[1m~/.$prefix""scmbrc\e[0;31m'.\e[0m\n" + printf "== \033[0;31mUpdates could not be applied to '\033[1m~/.$prefix""scmbrc\033[0;31m'.\033[0m\n" printf "== Please look at the following changes and manually update '~/.$prefix""scmbrc', if necessary.\n\n" cat "$HOME/.$prefix""scmbrc.rej" fi