##// END OF EJS Templates
sh profile: $LA can now be used in place of "last argument of previous command", like $! in bash
Ville M. Vainio -
Show More
@@ -47,7 +47,7 b' def main():'
47
47
48 ip.ex('import os')
48 ip.ex('import os')
49 ip.ex("def up(): os.chdir('..')")
49 ip.ex("def up(): os.chdir('..')")
50
50 ip.user_ns['LA'] = LastArgFinder()
51 # Nice prompt
51 # Nice prompt
52
52
53 o.prompt_in1= r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Green|\#> '
53 o.prompt_in1= r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Green|\#> '
@@ -117,6 +117,23 b' def main():'
117
117
118 extend_shell_behavior(ip)
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 # XXX You do not need to understand the next function!
137 # XXX You do not need to understand the next function!
121 # This should probably be moved out of profile
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