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.

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