Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
192 - 1
# Copyright © 2006 Shaun McCance <shaunm@gnome.org>
2
# Copyright © 2013 Peter De Wachter <pdewacht@gmail.com>
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
# Not bash or zsh?
18
[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0
19
 
20
# Not an interactive shell?
21
[[ $- == *i* ]] || return 0
22
 
23
# Not running under vte?
24
[ "${VTE_VERSION:-0}" -ge 3405 ] || return 0
25
 
26
__vte_urlencode() (
27
  # This is important to make sure string manipulation is handled
28
  # byte-by-byte.
29
  LC_ALL=C
30
  str="$1"
31
  while [ -n "$str" ]; do
32
    safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
33
    printf "%s" "$safe"
34
    str="${str#"$safe"}"
35
    if [ -n "$str" ]; then
36
      printf "%%%02X" "'$str"
37
      str="${str#?}"
38
    fi
39
  done
40
)
41
 
42
# Print a warning so that anyone who's added this manually to his PS1 can adapt.
43
# The function will be removed in a later version.
44
__vte_ps1() {
45
  echo -n "(__vte_ps1 is obsolete)"
46
}
47
 
48
__vte_osc7 () {
49
  printf "\033]7;file://%s%s\007" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
50
}
51
 
52
__vte_prompt_command() {
53
  local command=$(HISTTIMEFORMAT= history 1 | sed 's/^ *[0-9]\+ *//')
54
  command="${command//;/ }"
55
  local pwd='~'
56
  [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
57
  printf "\033]777;notify;Command completed;%s\007\033]0;%s@%s:%s\007%s" "${command}" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
58
}
59
 
60
case "$TERM" in
61
  xterm*|vte*)
62
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
63
    [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
64
    ;;
65
esac
66
 
67
true