Skip to content
Open

mac #55

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions colorize-spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ regex() {
}

mark-comments() {
regex "s/(#.*)/\\\e[38;5;22m\1\\\e[0m/g"
regex "s/(#.*)/\\\033[38;5;22m\1\\\033[0m/g"
}

mark-unsafe-checkouts() {
spec="$(cat)"
echo "$spec" | head -n 1
echo "$spec" | tail -n +2 | regex "s/^(\s*checkout)/\\\e[91m\1\\\e[0m/g"
echo "$spec" | tail -n +2 | regex "s/^(\s*checkout)/\\\033[91m\1\\\033[0m/g"
}

mark-branch-names() {
regex "s/^(\s*(?!exec)${graph_not_comment}+\s+)(${graph_not_comment}+)/\1\\\e[92m\2\\\e[0m/g"
regex "s/^(\s*(?!exec)${graph_not_comment}+\s+)(${graph_not_comment}+)/\1\\\033[92m\2\\\033[0m/g"
}

mark-execs() {
regex "s/^(\s*exec)(.*)$/\\\e[31m\1\\\e[96m\2\\\e[0m/g"
regex "s/^(\s*exec)(.*)$/\\\033[31m\1\\\033[96m\2\\\033[0m/g"
}

mark-squash-commits-messages() {
regex "s/^(\s*(?:take|rebase)-squash\s+${graph_not_comment}+\s+)((?:(?!#)\N\{\})+)/\1\\\e[37m\2\\\e[0m/g"
regex "s/^(\s*(?:take|rebase)-squash\s+${graph_not_comment}+\s+)((?:(?!#)\N\{\})+)/\1\\\033[37m\2\\\033[0m/g"
}

mark-unsafe-checkouts |
Expand All @@ -35,4 +35,4 @@ mark-unsafe-checkouts |
mark-comments
#sed -r -e \
# -e \
# -e "s/^\([[:graph:]]\+\s\+\)\([[:graph:]]\+\)/\1\\\e[92m\2\\\e[0m/g"
# -e "s/^\([[:graph:]]\+\s\+\)\([[:graph:]]\+\)/\1\\\033[92m\2\\\033[0m/g"
6 changes: 3 additions & 3 deletions detoul
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ save-spec() {
case "$1" in
test)
git branch -D "$DETOUL_BRANCH" >/dev/null 2>&1
echo -e "\e[32mIntegration branch succesfully created.\e[0m"
echo -e "\033[32mIntegration branch succesfully created.\033[0m"
;;
make)
git checkout "$DETOUL_BRANCH" >/dev/null 2>&1
Expand All @@ -298,7 +298,7 @@ save-spec() {
;;
*)
git branch -D "$DETOUL_BRANCH" >/dev/null 2>&1
echo -e "\e[31mUnknown operation '$1'.\e[0m" >&2
echo -e "\033[31mUnknown operation '$1'.\033[0m" >&2
fail
esac
quit
Expand All @@ -309,7 +309,7 @@ save-spec() {
stash-pop
fi
git branch -D "$DETOUL_BRANCH" >/dev/null 2>&1
echo -e "\e[31mFailure.\e[0m" >&2
echo -e "\033[31mFailure.\033[0m" >&2
fail
fi

Expand Down
24 changes: 12 additions & 12 deletions detoul-base
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ make-detoul-dependency() {
export DETOUL_COLOR_ALWAYS="1"
if ( detoul cat "$1" >/dev/null 2>&1 ); then
if ( git ls-tree detoul-spec | grep -q "\s$1$" ); then
echo -e "Making spec '\e[92m$1\e[0m...'" &&
echo -e "Making spec '\033[92m$1\033[0m...'" &&
detoul make "$1" &&
echo "0" >"$exit_code_file"
else
echo -e "\e[93mWarning: there is an archived detoul spec called '\e[92m$1\e[93m'.\e[0m"
echo -e "\033[93mWarning: there is an archived detoul spec called '\033[92m$1\033[93m'.\033[0m"
echo "0" >"$exit_code_file"
fi
else
Expand Down Expand Up @@ -56,12 +56,12 @@ validate-ref-name() {

checkout() {
if [ "$first_command" == "1" ]; then
color="\e[0m"
color="\033[0m"
first_command=0
else
color="\e[91m"
color="\033[91m"
fi
echo -e "${color}Checking out\e[0m '\e[92m$branch\e[0m'..."
echo -e "${color}Checking out\033[0m '\033[92m$branch\033[0m'..."
if ( (git branch ; git tag) | grep -q "\b${branch}$" ); then
checkout_branch="$branch"
else
Expand Down Expand Up @@ -130,9 +130,9 @@ take() {
cached_commit_key="$(detoul-cache hash take $@)"
if [ "$3" == "" ]; then
if [ "$1" == "" ]; then
echo -e "Taking '\e[92m$branch\e[0m'..."
echo -e "Taking '\033[92m$branch\033[0m'..."
else
echo -e "Taking '\e[92m$branch\e[0m' (\e[96m$(echo "$1" | cut -d'-' -f1)\e[0m)..."
echo -e "Taking '\033[92m$branch\033[0m' (\033[96m$(echo "$1" | cut -d'-' -f1)\033[0m)..."
fi
cached_commit="$(detoul-cache read "$cached_commit_key")"
if [ $? -ne 0 ] || ! (git reset --hard "$cached_commit" >/dev/null 2>&1); then
Expand All @@ -141,7 +141,7 @@ take() {
return
fi
elif [ "$3" == "refresh" ]; then
echo -e "\e[93mAttempting to refresh rerere cache...\e[0m" >&2
echo -e "\033[93mAttempting to refresh rerere cache...\033[0m" >&2
fi
source_branch="$(git show-ref "$branch" | cut -d' ' -f1 | head -n 1)"
if [ "${1/squash}" != "$1" ]; then
Expand Down Expand Up @@ -202,7 +202,7 @@ pick() {
branch="${command[1]}"
checkout
else
echo -e "Picking '\e[92m${command[1]}\e[0m'..."
echo -e "Picking '\033[92m${command[1]}\033[0m'..."
(
git cherry-pick "${command[1]}"
) >/dev/null 2>&1 || fail
Expand All @@ -219,7 +219,7 @@ while read -r line; do
export branch="$(autocomplete "${command[1]//\*/.*}")"
(make-detoul-dependency "$branch") || fail
if ! validate-ref-name "$branch" ; then
echo -e "\e[31mReference not found: '$branch'.\e[0m" >&2
echo -e "\033[31mReference not found: '$branch'.\033[0m" >&2
fail
fi
case "${command[0]}" in
Expand All @@ -239,12 +239,12 @@ while read -r line; do
pick
;;
exec)
echo -e "\e[91mExecuting\e[0m '\e[92m${line/exec /}\e[0m'..."
echo -e "\033[91mExecuting\033[0m '\033[92m${line/exec /}\033[0m'..."
cd "$GIT_WD"
bash -c "${line/exec /}" || fail
;;
*)
echo -e "\e[31mUnknown directive '${command[0]}'.\e[0m" >&2
echo -e "\033[31mUnknown directive '${command[0]}'.\033[0m" >&2
fail
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion load-detoul-spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ else
spec_hash="$(git ls-tree detoul-spec -- .archive/ | grep "\s.archive/$DETOUL_BRANCH$" | xargs echo | cut -d' ' -f3)"
fi
if [ "$spec_hash" == "" ]; then
echo -e "\e[31mBranch specification file not found.\e[0m"
echo -e "\033[31mBranch specification file not found.\033[0m"
exit 1
fi
fi
Expand Down