1
0
mirror of https://github.com/wting/autojump synced 2026-03-02 03:49:26 +00:00

remove unused imports, minor formatting cleanup

This commit is contained in:
William Ting
2013-12-28 07:13:47 -06:00
parent 1c8a4c13cd
commit 80a3f0da4d
5 changed files with 38 additions and 32 deletions

View File

@@ -4,27 +4,31 @@ IPython autojump magic
Written by keith hughitt <keith.hughitt@gmail.com>, based on an earlier
version by Mario Pastorelli <pastorelli.mario@gmail.com>.
To install, `create a new IPython user profile <http://ipython.org/ipython-doc/stable/config/ipython.html#configuring-ipython>`_
if you have not already done so by running:
To install, create a new IPython user profile by running:
ipython profile create
And copy this file into the "startup" folder of your new profile (e.g.
And copy this file into the "startup" folder of your new profile (e.g.
"$HOME/.config/ipython/profile_default/startup/").
@TODO: extend %cd to call "autojump -a"
"""
import os
import subprocess as sub
from IPython.core.magic import (register_line_magic, register_cell_magic,
register_line_cell_magic)
from subprocess import Popen
from subprocess import PIPE
from IPython.core.magic import register_line_magic
ip = get_ipython()
@register_line_magic
def j(path):
cmd = ['autojump'] + path.split()
newpath = sub.Popen(cmd, stdout=sub.PIPE, shell=False).communicate()[0].strip()
newpath = Popen(
cmd,
stdout=PIPE,
shell=False).communicate()[0].strip()
if newpath:
ip.magic('cd %s' % newpath.decode('utf-8'))