Commit 743d1a23 authored by Romain Deville's avatar Romain Deville

馃敄馃崕v0.0.6 Improving support for Mac OSX-iTerm.app

Update prompt.sh to add support of darwin TERM_PROGRAM variable.

Move variable HOST, UNICODE_SUPPORTED_TERM, TRUE_COLOR_TERM in
prompt_var.sh to be more accessible and to update these value more
easily.

Now sourcing this variables from file promp_var.sh in v1.sh and v2.sh
parents 26f886e0 6209d7f7
......@@ -16,9 +16,12 @@ which_term(){
# Main resource come from :
# https://askubuntu.com/questions/476641/how-can-i-get-the-name-of-the-current-terminal-from-command-line
local term
if who am i | grep tty &> /dev/null
if who am i | grep tty &> /dev/null && ! [[ "$(uname)" =~ ".*Darwin.*" ]]
then
term="tty"
elif [[ -n "${TERM_PROGRAM}" ]]
then
term="${TERM_PROGRAM}"
elif ! command -v xdotool &> /dev/null || ! xdotool getactivewindow &> /dev/null
then
term="unkown"
......@@ -80,27 +83,32 @@ export E_INFO="\e[32m" # Green fg
export E_WARNING="\e[33m" # Yellow fg
export E_ERROR="\e[31m" # Red fg
if [[ -n "${SHELL_APP}" ]]
then
export SHELL_APP="${SHELL_APP}"
else
export SHELL_APP="$(which_term)"
fi
main()
{
if [[ -n "${SHELL_APP}" ]]
then
export SHELL_APP="${SHELL_APP}"
else
export SHELL_APP="$(which_term)"
fi
# Determine prompt to load
if [[ -z "${SHELL_APP}" ]] \
|| [[ "${SHELL_APP}" == "tty" ]] \
|| [[ "${SHELL_APP}" == "unkown" ]]
then
# If terminal is tty or unkonwn, force V1 of prompt that is more readable when
# in TTY
PROMPT_VERSION=1
fi
# Determine prompt to load
if [[ -z "${SHELL_APP}" ]] \
|| [[ "${SHELL_APP}" == "tty" ]] \
|| [[ "${SHELL_APP}" == "unkown" ]]
then
# If terminal is tty or unkonwn, force V1 of prompt that is more readable when
# in TTY
PROMPT_VERSION=1
fi
# Load the desired prompt.
source "${PROMPT_DIR}/v${PROMPT_VERSION}.sh"
}
# Load the desired prompt.
source "${PROMPT_DIR}/v${PROMPT_VERSION}.sh"
main
# *****************************************************************************
# EDITOR CONFIG
# vim: ft=sh: ts=2: sw=2: sts=2
# *****************************************************************************
\ No newline at end of file
# *****************************************************************************
#!/bin/bash
# *****************************************************************************
# File : prompt_var.sh
# License : GNU General Public License v3.0
# Author : Romain Deville <contact@romaindeville.fr>
# *****************************************************************************
# DESCRIPTION:
# =============================================================================
# Setup some variables used in common.example.sh, v1.sh and v2.sh to check if
# terminal emulator support unicode characters and true colors
local HOST=$(hostname)
local UNICODE_SUPPORTED_TERM=("st" "terminator" "xterm" "iTerm.app")
local TRUE_COLOR_TERM=("st" "terminator" "iTerm.app")
......@@ -270,10 +270,7 @@ precmd()
return
}
local HOST=$(hostname)
local UNICODE_SUPPORTED_TERM=("st" "terminator" "xterm")
local TRUE_COLOR_TERM=("st" "terminator")
source <(cat "${PROMPT_DIR}/prompt_var.sh")
if [ -f "${PROMPT_DIR}/hosts/common.sh" ]
then
# shellcheck disable=SC1090
......
......@@ -346,9 +346,7 @@ precmd()
return
}
local HOST=$(hostname)
local UNICODE_SUPPORTED_TERM=("st" "terminator" "xterm")
local TRUE_COLOR_TERM=("st" "terminator")
source <(cat "${PROMPT_DIR}/prompt_var.sh")
if [ -f "${PROMPT_DIR}/hosts/common.sh" ]
then
......@@ -502,8 +500,10 @@ precmd()
# Unset function to not be shown as autocompletion
unset -f _prompt_printf
unset -f _prompt_info_line
}
# *****************************************************************************
# EDITOR CONFIG
# vim: ft=sh: ts=2: sw=2: sts=2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment