mirror of the now-defunct rocklinux.org
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.

161 lines
6.0 KiB

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