diff options
author | Philip van der Hoeven <philip@vd-hoeven.nl> | 2016-11-23 20:32:26 +0000 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2016-11-26 11:47:24 +0700 |
commit | 43d5330383178fd340dcda8dae190d5134d04cc4 (patch) | |
tree | 700aaf8304d09237a7df334484f15db1c2de8f79 /system/terminix/vte_terminix.sh | |
parent | 8085ca337ba8965167ca0b6bfe101e0e6d8d0bae (diff) |
system/terminix: Added (Tiling terminal emulator).
Signed-off-by: David Spencer <idlemoor@slackbuilds.org>
Diffstat (limited to 'system/terminix/vte_terminix.sh')
-rw-r--r-- | system/terminix/vte_terminix.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/system/terminix/vte_terminix.sh b/system/terminix/vte_terminix.sh new file mode 100644 index 0000000000000..ec037f77b93c5 --- /dev/null +++ b/system/terminix/vte_terminix.sh @@ -0,0 +1,65 @@ +# Copyright © 2006 Shaun McCance <shaunm@gnome.org> +# Copyright © 2013 Peter De Wachter <pdewacht@gmail.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Not bash or zsh? +[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0 + +# Not an interactive shell? +[[ $- == *i* ]] || return 0 + +# Not running under vte? +[ "${VTE_VERSION:-0}" -ge 3405 ] || return 0 + +__vte_urlencode() ( + # This is important to make sure string manipulation is handled + # byte-by-byte. + LC_ALL=C + str="$1" + while [ -n "$str" ]; do + safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}" + printf "%s" "$safe" + str="${str#"$safe"}" + if [ -n "$str" ]; then + printf "%%%02X" "'$str" + str="${str#?}" + fi + done +) + +# Print a warning so that anyone who's added this manually to his PS1 can adapt. +# The function will be removed in a later version. +__vte_ps1() { + echo -n "(__vte_ps1 is obsolete)" +} + +__vte_osc7 () { + printf "\033]7;file://%s%s\007" "${HOSTNAME%%.*}" "$(__vte_urlencode "${PWD}")" +} + +__vte_prompt_command() { + local pwd='~' + [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/} + printf "\033]0;%s@%s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)" +} + +case "$TERM" in + xterm*|vte*) + [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command" + [ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7) + ;; +esac + +true |