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 +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