Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 6 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 40 additions and 11 deletions.
  1. +0 −4 .gitignore
  2. +23 −1 README.md
  3. +17 −6 __init__.py
View
4 .gitignore
@@ -1,5 +1 @@
-*.pyc
-*.sublime-*
README.html
-mycommands.py
-sites.conf
View
24 README.md
@@ -123,6 +123,11 @@ So what does this mean? It means now in your shell when you type a command your
For now, it is recommended that a new python process be started each time. This makes it easy to do interactive things like prompting for a password securely using the `getpass` module and so forth. However, commander can also read its input from a file via the `--in` command line argument. Thus it is possible for the shell to create a [fifo](http://www.gnu.org/software/libc/manual/html_node/FIFO-Special-Files.html), start a single long-running commander python process, and then feed it commands one at a time via the fifo. This avoids any startup/shutdown overhead and makes it easier for your commands to keep state in memory across multiple commands. However, it is not possible to interact with the tty in this mode, so you can't prompt the user for input (at least I haven't found a clean way yet). On most modern systems, the python startup is fast enough to be negligible, so single-command mode is probably sufficient. However, it's on my todo list to figure out a good way to do a background process IPC version.
+Note that if shell filename globbing is sometimes screwing with your commander arguments when you don't want it to, prefer your command with `noglob` to disable shell globbing for that single command.
+
+ noglob mycommand_that_needs_a_regex f?art
+
+
##More info on command_not_found_handler
`command_not_found_handler` function is a hook that zsh or bash (bash calls it `command_not_found_handle` though) will call whenever you type in something that doesn't match a target operation (a shell builtin command, an alias, a function, a binary in your PATH, etc). Ever seen an Ubuntu box tell you something like "The program 'cowsay' is currently not installed. The program 'cowsay can be found in the following packages...". That's the [command-not-found](http://bazaar.launchpad.net/~command-not-found-developers/command-not-found/trunk/files) package using this hook to make that happen.
@@ -142,6 +147,9 @@ Now you can be hacking away in your shell, type `gh` (for example) and have [htt
To add a new site to the configuration file, use the `site` commander command, so just type "site zefrank http://www.zefrank.com/" and it will be added to the configuration file and immediately available.
+Note that `sites.conf` supports aliases as the site keywords as well as multiple URLs opened in browser tabs. This is handy for projects. For example, if you have a project "zippio" and you always need your docs, development server, art repo, and github repo open in browser tabs, you can make a site called "zippio" that will open all of those pages in tabs.
+
+
#Built in commands
* quit (also CTRL-D or just "q")
* quits commander.py
@@ -150,10 +158,24 @@ To add a new site to the configuration file, use the `site` commander command, s
#Supported Environments
-* Python 2.7 (probably earlier versions, too)
+* Python 2.7 (probably 2.6 will also work)
* OS X (10.7, 10.6, probably the rest of them)
* Linux
+#Using Commander over the network
+
+It is pretty straightforward to use the basic unix utilities of fifos and netcat to make commander work across the network. Note this is entirely cleartext and insecure. Also, netcat will only handle one connection at a time.
+
+* Create a [fifo](http://www.gnu.org/software/libc/manual/html_node/FIFO-Special-Files.html) for commander to use
+ * `mkfifo ~/.commander.fifo`
+* Start commander reading commands from that fifo
+ * `./commander.py --in ~/.commander.fifo --out ~/.commander.fifo --repl`
+* Start a local netcat daemon, sending its output to commander's fifo
+ * `nc -k -l 1234 > ~/.commander.fifo`
+* On a remote machine, use netcat as your commander shell
+ * nc host.where.you.started.commander.and.netcat.example 1234
+* Type your commander commands into that nc prompt and they will execute on the remote machine
+
# Keyboard Maestro
View
23 __init__.py
@@ -27,7 +27,7 @@
#logger.setLevel(logging.DEBUG)
-pyc = functools.partial(re.compile("\.pyc$").sub, ".py")
+pyc = functools.partial(re.compile("\.pyc$", re.I).sub, ".py")
"This is the shared global engine instance that holds the state"
engine = _engine.Engine()
@@ -38,16 +38,28 @@ def command(*args, **kwargs):
def fullReload(command=""):
- logger.debug("Reloading commander.py")
+ """Restart the Commander python process, preserving arguments"""
+ currentArgs = vars(parseArgs())
+ newArgs = []
+ for arg in ["in", "out"]:
+ fileName = currentArgs[arg].name
+ if fileName and fileName != "<std%s>" % arg:
+ newArgs.extend(["--" + arg, fileName])
+ if currentArgs["repl"]:
+ newArgs.append("--repl")
#This makes sure the current command is not dropped, but
#passed on to the next process via command line
- args = [sys.argv[0], command]
+ newArgs.append(command)
+ newArgs.insert(0, sys.argv[0])
sys.stdout.flush()
sys.stderr.flush()
+ logger.debug(
+ "Commander reloading with args: %s %s" %
+ (sys.argv[0], " ".join(newArgs)))
if wrapped():
- os.execvp("rlwrap", ["rlwrap"] + args)
+ os.execvp("rlwrap", ["rlwrap"] + newArgs)
else:
- os.execvp(sys.argv[0], args)
+ os.execvp(sys.argv[0], newArgs)
def wrapped():
@@ -79,7 +91,6 @@ def main(args=sys.argv):
engine.addReloader(pyc(builtins.__file__), fullReload)
import sites
engine.addReloader(pyc(sites.__file__), fullReload)
- #loadMyCommands()
args = parseArgs(args)
inFile = vars(args)["in"]
commandLineCommand = " ".join(args.command)

No commit comments for this range

Something went wrong with that request. Please try again.