ray@GIBBS.PHYSICS.PURDUE.EDU (Ray Moody) (06/14/89)
If suggestions for neat-o-keen additions to decode_prompt_string
are being solicited, then here is mine. I have added \H, which
inserts the host name like \h, but it only inserts up to the first
dot. I.E., I can put "gibbs" in my prompt instead of
"gibbs.physics.purdue.edu", which is a bit long to put in every prompt.
You need to apply Anders Ellefsrud's patch for \~ before you can
apply mine. Also, I have renamed his addition from \~ to \W because,
in my humble opinion, it would be a ``Good Idea'' to adopt the tcsh
convention of using capital letters as alternates for the lower case
letters.
Ray
-------------------------------------------------------------------------------
RCS file: RCS/shell.c,v
retrieving revision 0.99.1.1
diff -c -r0.99.1.1 shell.c
*** /tmp/,RCSt1018273 Tue Jun 13 15:06:59 1989
--- shell.c Tue Jun 13 15:04:38 1989
***************
*** 36,41
#include <stdio.h>
#include <signal.h>
#include <sys/errno.h>
#include <sys/types.h>
#ifndef SONY
--- 36,42 -----
#include <stdio.h>
#include <signal.h>
+ #include <strings.h> /* Ray Moody: June 13 1989 */
#include <sys/errno.h>
#include <sys/types.h>
#ifndef SONY
***************
*** 86,91
/* The current host's name. */
char *current_host_name = (char *)NULL;
/* Zero value means don't print prompts. */
int prompt_printable = 1;
--- 87,96 -----
/* The current host's name. */
char *current_host_name = (char *)NULL;
+ /* Ray Moody: Jun 13 1989 */
+ /* The current host's name, but only up to the first `.' */
+ char *current_short_host_name = (char *)NULL;
+
/* Zero value means don't print prompts. */
int prompt_printable = 1;
***************
*** 643,648
{
struct passwd *entry = getpwuid (getuid ());
char hostname[255];
#if defined(SYSV) && !defined(HPUX)
current_host_name = "localhost";
--- 648,654 -----
{
struct passwd *entry = getpwuid (getuid ());
char hostname[255];
+ char *dot; /* Ray Moody: June 13 1989 */
#if defined(SYSV) && !defined(HPUX)
current_host_name = "localhost";
***************
*** 652,657
else
current_host_name = savestring (hostname);
#endif
if (entry)
current_user_name = savestring (entry->pw_name);
else
--- 658,668 -----
else
current_host_name = savestring (hostname);
#endif
+ /* Ray Moody: June 13 1989 */
+ if ((dot = index (hostname, '.')) != (char *)NULL)
+ *dot = '\000';
+ current_short_host_name = savestring (hostname);
+
if (entry)
current_user_name = savestring (entry->pw_name);
else
===================================================================
RCS file: RCS/parse.y,v
retrieving revision 0.99.1.1
diff -c -r0.99.1.1 parse.y
*** /tmp/,RCSt1018273 Tue Jun 13 15:07:09 1989
--- parse.y Tue Jun 13 14:47:26 1989
***************
*** 1370,1376
\n CRLF
\s the name of the shell
\w the current working directory
! \~ the current working directory with ~ substituted for $HOME
\u your username
\h the hostname
\# the command number of this command
--- 1370,1376 -----
\n CRLF
\s the name of the shell
\w the current working directory
! \W the current working directory with ~ substituted for $HOME
\u your username
\h the hostname
\H the hostname, but only up to the first `.'
***************
*** 1373,1378
\~ the current working directory with ~ substituted for $HOME
\u your username
\h the hostname
\# the command number of this command
\! the history number of this command
\<octal> character code in octal
--- 1373,1379 -----
\W the current working directory with ~ substituted for $HOME
\u your username
\h the hostname
+ \H the hostname, but only up to the first `.'
\# the command number of this command
\! the history number of this command
\<octal> character code in octal
***************
*** 1457,1463
}
case 'w':
! case '~':
{
/* We would like to use the value of $PWD, but it turns out that
this could be a bad idea because the user could set PWD to
--- 1458,1464 -----
}
case 'w':
! case 'W':
{
/* We would like to use the value of $PWD, but it turns out that
this could be a bad idea because the user could set PWD to
***************
*** 1480,1486
getwd (temp);
#endif /* EFFICIENT */
! if (c == '~') {
int idx;
if (t_string = get_string_value ("HOME")) {
idx = strlen(t_string);
--- 1481,1487 -----
getwd (temp);
#endif /* EFFICIENT */
! if (c == 'W') {
int idx;
if (t_string = get_string_value ("HOME")) {
idx = strlen(t_string);
***************
*** 1504,1509
{
extern char *current_host_name;
temp = savestring (current_host_name);
goto add_string;
}
--- 1505,1518 -----
{
extern char *current_host_name;
temp = savestring (current_host_name);
+ goto add_string;
+ }
+
+ /* Added Tue Jun 13 14:36:18 EST 1989 by Ray Moody */
+ case 'H':
+ {
+ extern char *current_short_host_name;
+ temp = savestring (current_short_host_name);
goto add_string;
}