1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: misc/archive/bash-xterm.patch
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
8 # More information can be found in the files COPYING and README.
10 # This patch file is dual-licensed. It is available under the license the
11 # patched project is licensed under, as long as it is an OpenSource license
12 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
13 # of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
16 # --- T2-COPYRIGHT-NOTE-END ---
19 Little hack for bash: Adding 'xterm' option which causes bash to print the
20 PS1 prompt and the command bash is executing now in the title bar.
22 I'm not sure if my changes in execute_cmd.c will cause any troubles when
23 used with redirects and complex command blocks.
25 Written by Clifford <clifford@clifford.at>, 2001-04-08
27 diff -ruN bash-2.04-orig/builtins/builtins.c bash-2.04/builtins/builtins.c
28 --- bash-2.04-orig/builtins/builtins.c Sun Apr 8 11:19:48 2001
29 +++ bash-2.04/builtins/builtins.c Sun Apr 8 11:29:59 2001
31 #if defined (READLINE)
32 " vi use a vi-style line editing interface",
34 + " xterm create xterm title escape codes",
36 " -p Turned on whenever the real and effective user ids do not match.",
37 " Disables processing of the $ENV file and importing of shell",
38 diff -ruN bash-2.04-orig/builtins/set.def bash-2.04/builtins/set.def
39 --- bash-2.04-orig/builtins/set.def Thu Aug 5 13:44:25 1999
40 +++ bash-2.04/builtins/set.def Sun Apr 8 11:36:59 2001
42 # include "../bashhist.h"
45 -extern int interactive;
46 +extern int interactive, xterm_mode;
47 extern int noclobber, posixly_correct, ignoreeof, eof_encountered_limit;
48 #if defined (READLINE)
49 extern int rl_editing_mode, no_line_editing;
51 #if defined (READLINE)
52 vi use a vi-style line editing interface
54 + xterm create xterm title escape codes
56 -p Turned on whenever the real and effective user ids do not match.
57 Disables processing of the $ENV file and importing of shell
59 { "emacs", (int *)NULL, set_edit_mode, get_edit_mode },
60 { "vi", (int *)NULL, set_edit_mode, get_edit_mode },
62 + { "xterm", &xterm_mode, (Function *)NULL, (Function *)NULL },
63 { (char *)NULL, (int *)NULL }
66 diff -ruN bash-2.04-orig/execute_cmd.c bash-2.04/execute_cmd.c
67 --- bash-2.04-orig/execute_cmd.c Tue Jan 25 17:29:11 2000
68 +++ bash-2.04/execute_cmd.c Sun Apr 8 12:49:23 2001
70 # include "bashhist.h"
73 -extern int posixly_correct;
74 +extern int posixly_correct, xterm_mode;
75 extern int executing, breaking, continuing, loop_level;
76 extern int interactive, interactive_shell, login_shell, expand_aliases;
77 extern int parse_and_execute_level, running_trap, trap_line_number;
78 @@ -2367,6 +2367,16 @@
79 /* Remember what this command line looks like at invocation. */
80 command_string_index = 0;
81 print_simple_command (simple_command);
83 + /* Create xterm title */
86 + char *txt = get_string_value ("PS1");
87 + txt = txt ? decode_prompt_string (txt) : NULL;
88 + fprintf(stderr, "\033]0;%s%s\007", txt ? txt : "bash: ",
89 + the_printed_command);
90 + FREE(txt); fflush(stderr);
94 simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
95 diff -ruN bash-2.04-orig/flags.c bash-2.04/flags.c
96 --- bash-2.04-orig/flags.c Thu Aug 5 13:20:28 1999
97 +++ bash-2.04/flags.c Sun Apr 8 11:35:24 2001
99 int brace_expansion = 1;
102 +/* Non-zero means that the shell prints xterm escape codes for creating
103 + a new title text before printing the promt and before exetucing a
107 /* **************************************************************** */
109 /* The Flags ALIST. */
110 diff -ruN bash-2.04-orig/parse.y bash-2.04/parse.y
111 --- bash-2.04-orig/parse.y Tue Feb 22 19:12:03 2000
112 +++ bash-2.04/parse.y Sun Apr 8 12:32:08 2001
114 #if defined (BUFFERED_INPUT)
115 extern int bash_input_fd_changed;
117 +extern int xterm_mode;
120 /* **************************************************************** */
122 /* The decoded prompt string. Used if READLINE is not defined or if
123 editing is turned off. Analogous to current_readline_prompt. */
124 static char *current_decoded_prompt;
125 +static char *current_decoded_ps1_prompt;
127 /* The number of lines read from input while creating the current command. */
128 int current_command_line_count;
130 interrupt_immediately++;
133 + if (xterm_mode) fprintf(stderr, "\033]0;%s\007",
134 + current_decoded_ps1_prompt ?
135 + current_decoded_ps1_prompt : "bash");
137 current_readline_line = readline (current_readline_prompt ?
138 current_readline_prompt : "");
140 @@ -3421,6 +3427,10 @@
141 ps1_prompt = get_string_value ("PS1");
142 ps2_prompt = get_string_value ("PS2");
144 + FREE (current_decoded_ps1_prompt);
145 + current_decoded_ps1_prompt = ps1_prompt ?
146 + decode_prompt_string (ps1_prompt) : (char *)NULL;
148 if (!prompt_string_pointer)
149 prompt_string_pointer = &ps1_prompt;
151 @@ -3468,6 +3478,8 @@
155 + if (xterm_mode) fprintf(stderr, "\033]0;%s\007",
156 + current_decoded_ps1_prompt ? current_decoded_ps1_prompt : "bash");
157 fprintf (stderr, "%s", current_decoded_prompt);