--- a/README Wed Nov 11 15:25:41 2009 +0200
+++ b/README Fri Nov 13 17:48:13 2009 +0200
@@ -1,9 +1,10 @@
This is a module for mcabber, that allows you to view and
-change mcabber's environment variables at run-time.
+change mcabber's environment variables and woring directory
+at run-time.
-To use this module just load it, command 'env' will be
-available.
+To use this module just load it, commands 'env' and 'cd'
+will be available.
INSTALLATION
--- a/env.c Wed Nov 11 15:25:41 2009 +0200
+++ b/env.c Fri Nov 13 17:48:13 2009 +0200
@@ -23,6 +23,8 @@
#include <gmodule.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
#include "utils.h"
#include "compl.h"
@@ -96,10 +98,24 @@
free_arg_lst (args);
}
+// /cd [path]
+static void do_cd (char *arg)
+{
+ if (!*arg) { // get
+ char cwd[256];
+ if (getcwd (cwd, 256) == NULL)
+ scr_LogPrint (LPRINT_NORMAL, "Cannot obtain current working directory: %s.", strerror (errno));
+ else
+ scr_LogPrint (LPRINT_NORMAL, "%s", cwd);
+ } else if (chdir (arg) == -1) // set
+ scr_LogPrint (LPRINT_NORMAL, "Cannot change current working directory: %s.", strerror (errno));
+}
+
const gchar *g_module_check_init(GModule *module)
{
// command
cmd_add ("env", "", 0, 0, do_env, NULL);
+ cmd_add ("cd", "", COMPL_FILENAME, 0, do_cd, NULL);
return NULL;
}
@@ -107,7 +123,8 @@
void g_module_unload(GModule *module)
{
// command
+ cmd_del ("cd");
cmd_del ("env");
}
-/* vim: se ts=4: */
+/* vim: se ts=4 sw=4: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/help/en/hlp_cd.txt Fri Nov 13 17:48:13 2009 +0200
@@ -0,0 +1,4 @@
+
+ /CD [directory]
+
+Changes current working directory. Without argument outputs current working directory.