1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

only use colors if stdout is a terminal

This commit is contained in:
johannes@debussy 2016-02-02 14:15:41 +01:00
parent f26a38e0f9
commit 8fa8b06349
2 changed files with 10 additions and 2 deletions

View File

@ -61,7 +61,11 @@ j() {
output="$(autojump ${@})" output="$(autojump ${@})"
if [[ -d "${output}" ]]; then if [[ -d "${output}" ]]; then
echo -e "\\033[31m${output}\\033[0m" if [ -t 1 ]; then # if stdout is a terminal, use colors
echo -e "\\033[31m${output}\\033[0m"
else
echo -e "${output}"
fi
cd "${output}" cd "${output}"
else else
echo "autojump: directory '${@}' not found" echo "autojump: directory '${@}' not found"

View File

@ -52,7 +52,11 @@ j() {
setopt localoptions noautonamedirs setopt localoptions noautonamedirs
local output="$(autojump ${@})" local output="$(autojump ${@})"
if [[ -d "${output}" ]]; then if [[ -d "${output}" ]]; then
echo -e "\\033[31m${output}\\033[0m" if [ -t 1 ]; then # if stdout is a terminal, use colors
echo -e "\\033[31m${output}\\033[0m"
else
echo -e "${output}"
fi
cd "${output}" cd "${output}"
else else
echo "autojump: directory '${@}' not found" echo "autojump: directory '${@}' not found"