diff --git a/bin/autojump.bash b/bin/autojump.bash index 0c49d75..a7c8fdd 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -61,7 +61,11 @@ j() { output="$(autojump ${@})" 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}" else echo "autojump: directory '${@}' not found" diff --git a/bin/autojump.zsh b/bin/autojump.zsh index fbc0960..25d50ee 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -52,7 +52,11 @@ j() { setopt localoptions noautonamedirs local output="$(autojump ${@})" 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}" else echo "autojump: directory '${@}' not found"