Browse Source

Launcher: Replace ~/ by $HOME/

Philippe Pepiot 14 years ago
parent
commit
39ef26690c
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/launcher.c

+ 11 - 1
src/launcher.c

@@ -275,7 +275,17 @@ complete_on_files(char *start, size_t hits)
           path = _strdup(".");
      else
      {
-          dirname = _strdup(p);
+          /* remplace ~ by $HOME in dirname */
+          if (!strncmp(p, "~/", 2) && getenv("HOME"))
+               asprintf(&dirname, "%s%s", getenv("HOME"), p+1);
+          else
+               dirname = _strdup(p);
+
+          /* Set p to filename to be complete
+           * and path the directory containing the file
+           * /foooooo/baaaaaar/somethinglikethis<tab>
+           * <---- path - ---><------- p ------>
+           */
           p = strrchr(dirname, '/');
           if (p != dirname)
           {