Show More
@@ -47,7 +47,7 b' def main():' | |||
|
47 | 47 | |
|
48 | 48 | ip.ex('import os') |
|
49 | 49 | ip.ex("def up(): os.chdir('..')") |
|
50 | ||
|
50 | ip.user_ns['LA'] = LastArgFinder() | |
|
51 | 51 | # Nice prompt |
|
52 | 52 | |
|
53 | 53 | o.prompt_in1= r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Green|\#> ' |
@@ -117,6 +117,23 b' def main():' | |||
|
117 | 117 | |
|
118 | 118 | extend_shell_behavior(ip) |
|
119 | 119 | |
|
120 | class LastArgFinder: | |
|
121 | """ Allow $LA work as "last argument of previous command, like $! in bash | |
|
122 | ||
|
123 | """ | |
|
124 | def __str__(self): | |
|
125 | ip = ipapi.get() | |
|
126 | for cmd in reversed(ip.IP.input_hist_raw): | |
|
127 | parts = cmd.strip().split() | |
|
128 | if len(parts) < 2 or parts[-1] == '$LA': | |
|
129 | continue | |
|
130 | return parts[-1] | |
|
131 | return "" | |
|
132 | ||
|
133 | ||
|
134 | ||
|
135 | ||
|
136 | ||
|
120 | 137 | # XXX You do not need to understand the next function! |
|
121 | 138 | # This should probably be moved out of profile |
|
122 | 139 |
General Comments 0
You need to be logged in to leave comments.
Login now