# HG changeset patch # User Myhailo Danylenko # Date 1258127293 -7200 # Node ID 490c62fe90ebdd40c55ebbdd6a35cc67e5a967f8 # Parent 06943b72945ebea0d91a0a97c6c6ab77ae4ee64c Added command cd diff -r 06943b72945e -r 490c62fe90eb README --- 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 diff -r 06943b72945e -r 490c62fe90eb env.c --- 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 #include #include +#include +#include #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: */ diff -r 06943b72945e -r 490c62fe90eb help/en/hlp_cd.txt --- /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.