@@ -2745,15 +2745,20 @@ def _cmdloop(self):
27452745 def do_alias (self , arglist ):
27462746 """Define or display aliases
27472747
2748- Usage: Usage: alias [<name> <value>]
2748+ Usage: Usage: alias [name] | [ <name> <value>]
27492749 Where:
2750- name - name of the alias being added or edited
2751- value - what the alias will be resolved to
2750+ name - name of the alias being looked up, added, or edited
2751+ value - what the alias will be resolved to (if adding or editing)
27522752 this can contain spaces and does not need to be quoted
27532753
27542754 Without arguments, 'alias' prints a list of all aliases in a reusable form which
27552755 can be outputted to a startup_script to preserve aliases across sessions.
27562756
2757+ With one argument, 'alias' shows the value of the specified alias.
2758+ Example: alias ls (Prints the value of the alias called 'ls' if it exists)
2759+
2760+ With two or more arguments, 'alias' creates or replaces an alias.
2761+
27572762 Example: alias ls !ls -lF
27582763
27592764 If you want to use redirection or pipes in the alias, then either quote the tokens with these
@@ -2769,8 +2774,16 @@ def do_alias(self, arglist):
27692774 for cur_alias in self .aliases :
27702775 self .poutput ("alias {} {}" .format (cur_alias , self .aliases [cur_alias ]))
27712776
2777+ # The user is looking up an alias
2778+ elif len (arglist ) == 1 :
2779+ name = arglist [0 ]
2780+ if name in self .aliases :
2781+ self .poutput ("alias {} {}" .format (name , self .aliases [name ]))
2782+ else :
2783+ self .perror ("Alias '{}' not found" .format (name ), traceback_war = False )
2784+
27722785 # The user is creating an alias
2773- elif len ( arglist ) >= 2 :
2786+ else :
27742787 name = arglist [0 ]
27752788 value = ' ' .join (arglist [1 :])
27762789
@@ -2785,9 +2798,6 @@ def do_alias(self, arglist):
27852798 self .aliases [name ] = value
27862799 self .poutput ("Alias created" )
27872800
2788- else :
2789- self .do_help ('alias' )
2790-
27912801 def complete_alias (self , text , line , begidx , endidx ):
27922802 """ Tab completion for alias """
27932803 index_dict = \
0 commit comments