Use \033 instead of \e for color codes, which seems to be more widely supported.
This commit is contained in:
@@ -25,7 +25,7 @@ function _scmb_git_branch_shortcuts {
|
|||||||
line_count = output.lines.to_a.size
|
line_count = output.lines.to_a.size
|
||||||
output.lines.each_with_index do |line, i|
|
output.lines.each_with_index do |line, i|
|
||||||
spaces = (line_count > 9 && i < 9 ? " " : " ")
|
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
|
end
|
||||||
EOF
|
EOF
|
||||||
)"
|
)"
|
||||||
|
|||||||
@@ -35,17 +35,17 @@ git_status_shortcuts() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
local c_rst="\e[0m"
|
local c_rst="\033[0m"
|
||||||
local c_branch="\e[1m"
|
local c_branch="\033[1m"
|
||||||
local c_header="\e[0m"
|
local c_header="\033[0m"
|
||||||
local c_dark="\e[2;37m"
|
local c_dark="\033[2;37m"
|
||||||
local c_del="\e[0;31m"
|
local c_del="\033[0;31m"
|
||||||
local c_mod="\e[0;32m"
|
local c_mod="\033[0;32m"
|
||||||
local c_new="\e[0;33m"
|
local c_new="\033[0;33m"
|
||||||
local c_ren="\e[0;34m"
|
local c_ren="\033[0;34m"
|
||||||
local c_cpy="\e[0;33m"
|
local c_cpy="\033[0;33m"
|
||||||
local c_ign="\e[0;36m"
|
local c_ign="\033[0;36m"
|
||||||
# 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;'
|
||||||
local c_grp_1="33m"; local c_grp_2="31m"; local c_grp_3="32m"; local c_grp_4="36m"
|
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
|
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
|
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 no group specified as param, or specified group is current group
|
||||||
if [ -z "$1" ] || [[ "$1" == "$grp_num" ]]; then
|
if [ -z "$1" ] || [[ "$1" == "$grp_num" ]]; then
|
||||||
local c_arrow="\e[1;$(eval echo \$c_grp_$grp_num)"
|
local c_arrow="\033[1;$(eval echo \$c_grp_$grp_num)"
|
||||||
local c_hash="\e[0;$(eval echo \$c_grp_$grp_num)"
|
local c_hash="\033[0;$(eval echo \$c_grp_$grp_num)"
|
||||||
if [ -n "${stat_grp[$grp_num]}" ]; then
|
if [ -n "${stat_grp[$grp_num]}" ]; then
|
||||||
echo -e "$c_arrow➤$c_header $heading\n$c_hash#$c_rst"
|
echo -e "$c_arrow➤$c_header $heading\n$c_hash#$c_rst"
|
||||||
_gs_output_file_group $grp_num
|
_gs_output_file_group $grp_num
|
||||||
@@ -121,7 +121,7 @@ git_status_shortcuts() {
|
|||||||
_gs_output_file_group() {
|
_gs_output_file_group() {
|
||||||
for i in ${stat_grp[$1]}; do
|
for i in ${stat_grp[$1]}; do
|
||||||
# Print colored hashes & files based on modification groups
|
# 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
|
# Deduce relative path based on current working directory
|
||||||
if [ -z "$project_root" ]; then
|
if [ -z "$project_root" ]; then
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function find_in_cwd_or_parent() {
|
|||||||
|
|
||||||
function fail_if_not_git_repo() {
|
function fail_if_not_git_repo() {
|
||||||
if ! find_in_cwd_or_parent ".git" > /dev/null; then
|
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
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ if [[ "$git_keyboard_shortcuts_enabled" = "true" ]]; then
|
|||||||
if ! set -o | grep -q '^vi .*on$'; then
|
if ! set -o | grep -q '^vi .*on$'; then
|
||||||
if [[ $shell == "zsh" ]]; then
|
if [[ $shell == "zsh" ]]; then
|
||||||
_bind "$git_commit_all_keys" " git_commit_all""\n"
|
_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
|
else
|
||||||
_bind "$git_commit_all_keys" "\" git_commit_all\n\""
|
_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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ function ls_with_file_shortcuts {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(echo "$ll_output" | wc -l)" -gt "50" ]; then
|
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"
|
echo "$ll_output"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -138,7 +138,7 @@ e = 1
|
|||||||
re = /^(([^ ]* +){8})/
|
re = /^(([^ ]* +){8})/
|
||||||
output.lines.each do |line|
|
output.lines.each do |line|
|
||||||
next unless line.match(re)
|
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
|
e += 1
|
||||||
end
|
end
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
@@ -34,21 +34,21 @@ exit if @changes.size > ENV["gs_max_changes"].to_i
|
|||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
@c = {
|
@c = {
|
||||||
:rst => "\e[0m",
|
:rst => "\033[0m",
|
||||||
:del => "\e[0;31m",
|
:del => "\033[0;31m",
|
||||||
:mod => "\e[0;32m",
|
:mod => "\033[0;32m",
|
||||||
:new => "\e[0;33m",
|
:new => "\033[0;33m",
|
||||||
:ren => "\e[0;34m",
|
:ren => "\033[0;34m",
|
||||||
:cpy => "\e[0;33m",
|
:cpy => "\033[0;33m",
|
||||||
:typ => "\e[0;35m",
|
:typ => "\033[0;35m",
|
||||||
:unt => "\e[0;36m",
|
:unt => "\033[0;36m",
|
||||||
:dark => "\e[2;37m",
|
:dark => "\033[2;37m",
|
||||||
:branch => "\e[1m",
|
:branch => "\033[1m",
|
||||||
:header => "\e[0m"
|
: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 = {
|
@group_c = {
|
||||||
:staged => "33m",
|
:staged => "33m",
|
||||||
:unmerged => "31m",
|
: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 no changes, just display green no changes message and exit here
|
||||||
if @git_status == ""
|
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]
|
@c[:dark], @c[:rst], @c[:branch], @c[:dark], @c[:rst]
|
||||||
]
|
]
|
||||||
exit
|
exit
|
||||||
@@ -99,7 +99,7 @@ end
|
|||||||
# If changed 'file' is actually a git submodule
|
# If changed 'file' is actually a git submodule
|
||||||
if @gitmodules.include?(file)
|
if @gitmodules.include?(file)
|
||||||
# Parse long git status for submodule summaries
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ end
|
|||||||
# Output files
|
# Output files
|
||||||
def output_file_group(group)
|
def output_file_group(group)
|
||||||
# Print colored hashes & files based on modification groups
|
# 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|
|
@stat_hash[group].each do |h|
|
||||||
@e += 1
|
@e += 1
|
||||||
@@ -194,8 +194,8 @@ end
|
|||||||
# Allow filtering by specific group (by string or integer)
|
# 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 !ARGV[0] || ARGV[0] == group.to_s || ARGV[0] == (i+1).to_s; then
|
||||||
if !@stat_hash[group].empty?
|
if !@stat_hash[group].empty?
|
||||||
c_arrow="\e[1;#{@group_c[group]}"
|
c_arrow="\033[1;#{@group_c[group]}"
|
||||||
c_hash="\e[0;#{@group_c[group]}"
|
c_hash="\033[0;#{@group_c[group]}"
|
||||||
puts "#{c_arrow}➤#{@c[:header]} #{heading}\n#{c_hash}##{@c[:rst]}"
|
puts "#{c_arrow}➤#{@c[:header]} #{heading}\n#{c_hash}##{@c[:rst]}"
|
||||||
output_file_group(group)
|
output_file_group(group)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ git_status_shortcuts() {
|
|||||||
if [[ -z "$cmd_output" ]]; then
|
if [[ -z "$cmd_output" ]]; then
|
||||||
# Just show regular git status if ruby script returns nothing.
|
# Just show regular git status if ruby script returns nothing.
|
||||||
git status
|
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
|
return 1
|
||||||
fi
|
fi
|
||||||
# Fetch list of files from last line of script output
|
# 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
|
for file in $(git show --pretty="format:" --name-only $@ | \grep -v '^$'); do
|
||||||
let f++
|
let f++
|
||||||
export $git_env_char$f=$file # Export numbered variable.
|
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 "# "
|
done; echo "# "
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ git_commit_prompt() {
|
|||||||
eval $@ # run any prequisite commands
|
eval $@ # run any prequisite commands
|
||||||
echo $commit_msg | git commit -F - | tail -n +2
|
echo $commit_msg | git commit -F - | tail -n +2
|
||||||
else
|
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
|
fi
|
||||||
escaped=$(echo "$commit_msg" | sed -e 's/"/\\"/g' -e 's/!/"'"'"'!'"'"'"/g')
|
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
|
fail_if_not_git_repo || return 1
|
||||||
changes=$(git status --porcelain | wc -l)
|
changes=$(git status --porcelain | wc -l)
|
||||||
if [ "$changes" -gt 0 ]; then
|
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"
|
git_commit_prompt "git add -A"
|
||||||
else
|
else
|
||||||
echo "# No changed files to commit."
|
echo "# No changed files to commit."
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ _create_or_patch_scmbrc() {
|
|||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
# If the patch cannot be applied cleanly, show the updates and tell user to update file manually.
|
# 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
|
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"
|
printf "== Please look at the following changes and manually update '~/.$prefix""scmbrc', if necessary.\n\n"
|
||||||
cat "$HOME/.$prefix""scmbrc.rej"
|
cat "$HOME/.$prefix""scmbrc.rej"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user