Add support of /W prompts
authorEric Andersen <andersen@codepoet.org>
Thu, 5 Apr 2001 23:00:47 +0000 (23:00 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 5 Apr 2001 23:00:47 +0000 (23:00 -0000)
 -Erik

cmdedit.c
shell/cmdedit.c

index e317b86fa69149d5a3a9352bd938efd7b5267056..a3710812f079f13f06e5a90424e14638d4d356dd 100644 (file)
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -441,6 +441,19 @@ static void parse_prompt(const char *prmt_ptr)
                                add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf);
                                continue;
 #endif 
+                       case 'W':
+                               if (pwd_buf[0] == 0) {
+                                       char *z;
+                                       
+                                       getcwd(pwd_buf, PATH_MAX);
+                                       z = strrchr(pwd_buf,'/');
+                                       if ( (z != NULL) && (z != pwd_buf) ) {
+                                               z++;
+                                               strcpy(pwd_buf,z);
+                                       }
+                               }
+                               add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf);
+                               continue;
                        case '!':
                                snprintf(buf, sizeof(buf), "%d", num_ok_lines);
                                add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, buf);
index e317b86fa69149d5a3a9352bd938efd7b5267056..a3710812f079f13f06e5a90424e14638d4d356dd 100644 (file)
@@ -441,6 +441,19 @@ static void parse_prompt(const char *prmt_ptr)
                                add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf);
                                continue;
 #endif 
+                       case 'W':
+                               if (pwd_buf[0] == 0) {
+                                       char *z;
+                                       
+                                       getcwd(pwd_buf, PATH_MAX);
+                                       z = strrchr(pwd_buf,'/');
+                                       if ( (z != NULL) && (z != pwd_buf) ) {
+                                               z++;
+                                               strcpy(pwd_buf,z);
+                                       }
+                               }
+                               add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf);
+                               continue;
                        case '!':
                                snprintf(buf, sizeof(buf), "%d", num_ok_lines);
                                add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, buf);