OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
5.8 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: misc/archive/bash-xterm.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  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
  15. # version.
  16. # --- T2-COPYRIGHT-NOTE-END ---
  17. Little hack for bash: Adding 'xterm' option which causes bash to print the
  18. PS1 prompt and the command bash is executing now in the title bar.
  19. I'm not sure if my changes in execute_cmd.c will cause any troubles when
  20. used with redirects and complex command blocks.
  21. Written by Clifford <clifford@clifford.at>, 2001-04-08
  22. diff -ruN bash-2.04-orig/builtins/builtins.c bash-2.04/builtins/builtins.c
  23. --- bash-2.04-orig/builtins/builtins.c Sun Apr 8 11:19:48 2001
  24. +++ bash-2.04/builtins/builtins.c Sun Apr 8 11:29:59 2001
  25. @@ -765,6 +765,7 @@
  26. #if defined (READLINE)
  27. " vi use a vi-style line editing interface",
  28. #endif /* READLINE */
  29. + " xterm create xterm title escape codes",
  30. " xtrace same as -x",
  31. " -p Turned on whenever the real and effective user ids do not match.",
  32. " Disables processing of the $ENV file and importing of shell",
  33. diff -ruN bash-2.04-orig/builtins/set.def bash-2.04/builtins/set.def
  34. --- bash-2.04-orig/builtins/set.def Thu Aug 5 13:44:25 1999
  35. +++ bash-2.04/builtins/set.def Sun Apr 8 11:36:59 2001
  36. @@ -49,7 +49,7 @@
  37. # include "../bashhist.h"
  38. #endif
  39. -extern int interactive;
  40. +extern int interactive, xterm_mode;
  41. extern int noclobber, posixly_correct, ignoreeof, eof_encountered_limit;
  42. #if defined (READLINE)
  43. extern int rl_editing_mode, no_line_editing;
  44. @@ -104,6 +104,7 @@
  45. #if defined (READLINE)
  46. vi use a vi-style line editing interface
  47. #endif /* READLINE */
  48. + xterm create xterm title escape codes
  49. xtrace same as -x
  50. -p Turned on whenever the real and effective user ids do not match.
  51. Disables processing of the $ENV file and importing of shell
  52. @@ -195,6 +196,7 @@
  53. { "emacs", (int *)NULL, set_edit_mode, get_edit_mode },
  54. { "vi", (int *)NULL, set_edit_mode, get_edit_mode },
  55. #endif
  56. + { "xterm", &xterm_mode, (Function *)NULL, (Function *)NULL },
  57. { (char *)NULL, (int *)NULL }
  58. };
  59. diff -ruN bash-2.04-orig/execute_cmd.c bash-2.04/execute_cmd.c
  60. --- bash-2.04-orig/execute_cmd.c Tue Jan 25 17:29:11 2000
  61. +++ bash-2.04/execute_cmd.c Sun Apr 8 12:49:23 2001
  62. @@ -98,7 +98,7 @@
  63. # include "bashhist.h"
  64. #endif
  65. -extern int posixly_correct;
  66. +extern int posixly_correct, xterm_mode;
  67. extern int executing, breaking, continuing, loop_level;
  68. extern int interactive, interactive_shell, login_shell, expand_aliases;
  69. extern int parse_and_execute_level, running_trap, trap_line_number;
  70. @@ -2367,6 +2367,16 @@
  71. /* Remember what this command line looks like at invocation. */
  72. command_string_index = 0;
  73. print_simple_command (simple_command);
  74. +
  75. + /* Create xterm title */
  76. + if (xterm_mode)
  77. + {
  78. + char *txt = get_string_value ("PS1");
  79. + txt = txt ? decode_prompt_string (txt) : NULL;
  80. + fprintf(stderr, "\033]0;%s%s\007", txt ? txt : "bash: ",
  81. + the_printed_command);
  82. + FREE(txt); fflush(stderr);
  83. + }
  84. first_word_quoted =
  85. simple_command->words ? (simple_command->words->word->flags & W_QUOTED): 0;
  86. diff -ruN bash-2.04-orig/flags.c bash-2.04/flags.c
  87. --- bash-2.04-orig/flags.c Thu Aug 5 13:20:28 1999
  88. +++ bash-2.04/flags.c Sun Apr 8 11:35:24 2001
  89. @@ -147,6 +147,11 @@
  90. int brace_expansion = 1;
  91. #endif
  92. +/* Non-zero means that the shell prints xterm escape codes for creating
  93. + a new title text before printing the promt and before exetucing a
  94. + command. */
  95. +int xterm_mode = 0;
  96. +
  97. /* **************************************************************** */
  98. /* */
  99. /* The Flags ALIST. */
  100. diff -ruN bash-2.04-orig/parse.y bash-2.04/parse.y
  101. --- bash-2.04-orig/parse.y Tue Feb 22 19:12:03 2000
  102. +++ bash-2.04/parse.y Sun Apr 8 12:32:08 2001
  103. @@ -99,6 +99,7 @@
  104. #if defined (BUFFERED_INPUT)
  105. extern int bash_input_fd_changed;
  106. #endif
  107. +extern int xterm_mode;
  108. extern int errno;
  109. /* **************************************************************** */
  110. @@ -153,6 +154,7 @@
  111. /* The decoded prompt string. Used if READLINE is not defined or if
  112. editing is turned off. Analogous to current_readline_prompt. */
  113. static char *current_decoded_prompt;
  114. +static char *current_decoded_ps1_prompt;
  115. /* The number of lines read from input while creating the current command. */
  116. int current_command_line_count;
  117. @@ -975,6 +977,10 @@
  118. interrupt_immediately++;
  119. }
  120. + if (xterm_mode) fprintf(stderr, "\033]0;%s\007",
  121. + current_decoded_ps1_prompt ?
  122. + current_decoded_ps1_prompt : "bash");
  123. +
  124. current_readline_line = readline (current_readline_prompt ?
  125. current_readline_prompt : "");
  126. @@ -3421,6 +3427,10 @@
  127. ps1_prompt = get_string_value ("PS1");
  128. ps2_prompt = get_string_value ("PS2");
  129. + FREE (current_decoded_ps1_prompt);
  130. + current_decoded_ps1_prompt = ps1_prompt ?
  131. + decode_prompt_string (ps1_prompt) : (char *)NULL;
  132. +
  133. if (!prompt_string_pointer)
  134. prompt_string_pointer = &ps1_prompt;
  135. @@ -3468,6 +3478,8 @@
  136. static void
  137. print_prompt ()
  138. {
  139. + if (xterm_mode) fprintf(stderr, "\033]0;%s\007",
  140. + current_decoded_ps1_prompt ? current_decoded_ps1_prompt : "bash");
  141. fprintf (stderr, "%s", current_decoded_prompt);
  142. fflush (stderr);
  143. }