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.

160 lines
5.9 KiB

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