aboutsummaryrefslogtreecommitdiff
path: root/terminal.dot.link
blob: bda0e57c7e25b27c99a84aaf6730937b52a87a26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
#
# .terminal: sets default behaviour for a X11 console
#

# Load ANSI Art
#cat $HOME/themes/ans/slack.ans

# Make sure to load the profile
source $HOME/.profile

# Default window title
TITLE="terminal"

# Set terminal title
function terminal_title {
  # Set window title
  xtitle $*

  # Set window title inside screen
  # http://stackoverflow.com/questions/899609/gnu-screen-run-script-that-sends-commands-to-the-screen-session-it-is-being-run
  if [ -n "$STY" ]; then
    screen -X title $*
  fi
}

# Set window title, standard version
#trap 'echo -ne "\e]0;terminal: ${TITLE:-$BASH_COMMAND}\007"' DEBUG
#trap 'xtitle ${TITLE:-$BASH_COMMAND}' DEBUG

# Set window title, special version
#
# In the standard version, $_ stops to keep the parameter of the last command.
# The sollution is to save the value of $_ and issue a pointless command with
# it after changing the title so $_ retain it's intended value.
#
#trap 'last="$_" ; echo -ne "\e]0;terminal: ${TITLE:-$BASH_COMMAND}\007"; true $last' DEBUG
#trap 'last="$_" ; xtitle ${TITLE:-$BASH_COMMAND}; true $last' DEBUG
#trap '_last="$_" ; _command=${BASH_COMMAND#command_prompt} ; xtitle ${_command:-$TITLE}; true $_last' DEBUG
trap '_last="$_" ; _command=${BASH_COMMAND#command_prompt} ; terminal_title ${_command:-$TITLE}; true $_last' DEBUG

# Fortune :)
#fortune