diff options
| author | [email protected] <[email protected]> | 2010-12-09 00:05:50 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2010-12-09 00:05:50 +0000 |
| commit | 46914144c9f1ae3a67f4bf9d5387bda620ad4ba8 (patch) | |
| tree | 859bed7d697242ee86ec8de7b5f342f354c3cba5 /components | |
| parent | fbe81f8c4c29433859920b2f08f4ff001b891134 (diff) | |
add current path in prompt.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1184 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
| -rw-r--r-- | components/finsh/shell.c | 17 | ||||
| -rw-r--r-- | components/finsh/shell.h | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/components/finsh/shell.c b/components/finsh/shell.c index d78461b532..fec8c1fa77 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -84,6 +84,21 @@ int isprint(unsigned char ch) #endif #endif +#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) +#include <dfs_posix.h> +const char* finsh_get_prompt() +{ + #define _PROMPT "finsh " + static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {_PROMPT}; + + /* get current working directory */ + getcwd(&finsh_prompt[6], RT_CONSOLEBUF_SIZE - 8); + strcat(finsh_prompt, ">"); + + return finsh_prompt; +} +#endif + static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size) { RT_ASSERT(shell != RT_NULL); @@ -172,7 +187,7 @@ void finsh_auto_complete(char* prefix) rt_kprintf("\n"); list_prefix(prefix); - rt_kprintf("finsh>>%s", prefix); + rt_kprintf("%s%s", FINSH_PROMPT, prefix); } void finsh_run_line(struct finsh_parser* parser, const char *line) diff --git a/components/finsh/shell.h b/components/finsh/shell.h index 76b5249c68..0b39369d22 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -13,7 +13,11 @@ #define FINSH_CMD_SIZE 80
#define FINSH_OPTION_ECHO 0x01
+#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
+#define FINSH_PROMPT finsh_get_prompt()
+#else
#define FINSH_PROMPT "finsh>>"
+#endif
#ifdef FINSH_USING_HISTORY
enum input_stat
|
