class_docstr: Magics to interact with the underlying OS (shell-type functionality).
      
class_docstr_tok: ["Magics","to","interact","with","the","underlying","OS","(","shell-type","functionality",")","."]
docstr: Define an alias for a system command.
  
  '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
  
  Then, typing 'alias_name params' will execute the system command 'cmd
  params' (from your underlying operating system).
  
  Aliases have lower precedence than magic functions and Python normal
  variables, so if 'foo' is both a Python variable and an alias, the
  alias can not be executed until 'del foo' removes the Python variable.
  
  You can use the %l specifier in an alias definition to represent the
  whole line when the alias is called.  For example::
  
    In [2]: alias bracket echo "Input in brackets: <%l>"
    In [3]: bracket hello world
    Input in brackets: <hello world>
  
  You can also define aliases with parameters using %s specifiers (one
  per parameter)::
  
    In [1]: alias parts echo first %s second %s
    In [2]: %parts A B
    first A second B
    In [3]: %parts A
    Incorrect number of arguments: 2 expected.
    parts is an alias to: 'echo first %s second %s'
  
  Note that %l and %s are mutually exclusive.  You can only use one or
  the other in your aliases.
  
  Aliases expand Python variables just like system calls using ! or !!
  do: all expressions prefixed with '$' get expanded.  For details of
  the semantic rules, see PEP-215:
  https://peps.python.org/pep-0215/.  This is the library used by
  IPython for variable expansion.  If you want to access a true shell
  variable, an extra $ is necessary to prevent its expansion by
  IPython::
  
    In [6]: alias show echo
    In [7]: PATH='A Python string'
    In [8]: show $PATH
    A Python string
    In [9]: show $$PATH
    /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
  
  You can use the alias facility to access all of $PATH.  See the %rehashx
  function, which automatically creates aliases for the contents of your
  $PATH.
  
  If called with no parameters, %alias prints the current alias table
  for your system.  For posix systems, the default aliases are 'cat',
  'cp', 'mv', 'rm', 'rmdir', and 'mkdir', and other platform-specific
  aliases are added.  For windows-based systems, the default aliases are
  'copy', 'ddir', 'echo', 'ls', 'ldir', 'mkdir', 'ren', and 'rmdir'.
  
  You can see the definition of alias by adding a question mark in the
  end::
  
    In [1]: cat?
    Repr: <alias cat for 'cat'>
docstr_tok: ["Define","an","alias","for","a","system","command",".","'","%","alias","alias_name","cmd","'","defines","'alias_name","'","as","an","alias","for","'cmd'","Then",",","typing","'alias_name","params","'","will","execute","the","system","command","'cmd","params","'","(","from","your","underlying","operating","system",")",".","Aliases","have","lower","precedence","than","magic","functions","and","Python","normal","variables",",","so","if","'foo","'","is","both","a","Python","variable","and","an","alias",",","the","alias","can","not","be","executed","until","'del","foo","'","removes","the","Python","variable",".","You","can","use","the","%","l","specifier","in","an","alias","definition","to","represent","the","whole","line","when","the","alias","is","called",".","For","example",":",":","In","[","2","]",":","alias","bracket","echo","``","Input","in","brackets",":","<","%","l",">","''","In","[","3","]",":","bracket","hello","world","Input","in","brackets",":","<","hello","world",">","You","can","also","define","aliases","with","parameters","using","%","s","specifiers","(","one","per","parameter",")",":",":","In","[","1","]",":","alias","parts","echo","first","%","s","second","%","s","In","[","2","]",":","%","parts","A","B","first","A","second","B","In","[","3","]",":","%","parts","A","Incorrect","number","of","arguments",":","2","expected",".","parts","is","an","alias","to",":","'echo","first","%","s","second","%","s'","Note","that","%","l","and","%","s","are","mutually","exclusive",".","You","can","only","use","one","or","the","other","in","your","aliases",".","Aliases","expand","Python","variables","just","like","system","calls","using","!","or","!","!","do",":","all","expressions","prefixed","with","'","$","'","get","expanded",".","For","details","of","the","semantic","rules",",","see","PEP-215",":","https",":","\/\/peps.python.org\/pep-0215\/",".","This","is","the","library","used","by","IPython","for","variable","expansion",".","If","you","want","to","access","a","true","shell","variable",",","an","extra","$","is","necessary","to","prevent","its","expansion","by","IPython",":",":","In","[","6","]",":","alias","show","echo","In","[","7","]",":","PATH=","'","A","Python","string'","In","[","8","]",":","show","$","PATH","A","Python","string","In","[","9","]",":","show","$","$","PATH","\/usr\/local\/lf9560\/bin",":","\/usr\/local\/intel\/compiler70\/ia32\/bin",":","...","You","can","use","the","alias","facility","to","access","all","of","$","PATH",".","See","the","%","rehashx","function",",","which","automatically","creates","aliases","for","the","contents","of","your","$","PATH",".","If","called","with","no","parameters",",","%","alias","prints","the","current","alias","table","for","your","system",".","For","posix","systems",",","the","default","aliases","are","'cat","'",",","'cp","'",",","'mv","'",",","'rm","'",",","'rmdir","'",",","and","'mkdir","'",",","and","other","platform-specific","aliases","are","added",".","For","windows-based","systems",",","the","default","aliases","are","'copy","'",",","'ddir","'",",","'echo","'",",","'ls","'",",","'ldir","'",",","'mkdir","'",",","'ren","'",",","and","'rmdir","'",".","You","can","see","the","definition","of","alias","by","adding","a","question","mark","in","the","end",":",":","In","[","1","]",":","cat","?","Repr",":","<","alias","cat","for","'cat","'",">"]
code: def alias(self, parameter_s=""):
      """Define an alias for a system command.
  
      '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
  
      Then, typing 'alias_name params' will execute the system command 'cmd
      params' (from your underlying operating system).
  
      Aliases have lower precedence than magic functions and Python normal
      variables, so if 'foo' is both a Python variable and an alias, the
      alias can not be executed until 'del foo' removes the Python variable.
  
      You can use the %l specifier in an alias definition to represent the
      whole line when the alias is called.  For example::
  
        In [2]: alias bracket echo "Input in brackets: <%l>"
        In [3]: bracket hello world
        Input in brackets: <hello world>
  
      You can also define aliases with parameters using %s specifiers (one
      per parameter)::
  
        In [1]: alias parts echo first %s second %s
        In [2]: %parts A B
        first A second B
        In [3]: %parts A
        Incorrect number of arguments: 2 expected.
        parts is an alias to: 'echo first %s second %s'
  
      Note that %l and %s are mutually exclusive.  You can only use one or
      the other in your aliases.
  
      Aliases expand Python variables just like system calls using ! or !!
      do: all expressions prefixed with '$' get expanded.  For details of
      the semantic rules, see PEP-215:
      https://peps.python.org/pep-0215/.  This is the library used by
      IPython for variable expansion.  If you want to access a true shell
      variable, an extra $ is necessary to prevent its expansion by
      IPython::
  
        In [6]: alias show echo
        In [7]: PATH='A Python string'
        In [8]: show $PATH
        A Python string
        In [9]: show $$PATH
        /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
  
      You can use the alias facility to access all of $PATH.  See the %rehashx
      function, which automatically creates aliases for the contents of your
      $PATH.
  
      If called with no parameters, %alias prints the current alias table
      for your system.  For posix systems, the default aliases are 'cat',
      'cp', 'mv', 'rm', 'rmdir', and 'mkdir', and other platform-specific
      aliases are added.  For windows-based systems, the default aliases are
      'copy', 'ddir', 'echo', 'ls', 'ldir', 'mkdir', 'ren', and 'rmdir'.
  
      You can see the definition of alias by adding a question mark in the
      end::
  
        In [1]: cat?
        Repr: <alias cat for 'cat'>"""
  
      par = parameter_s.strip()
      if not par:
          aliases = sorted(self.shell.alias_manager.aliases)
          # stored = self.shell.db.get('stored_aliases', {} )
          # for k, v in stored:
          #     atab.append(k, v[0])
  
          print("Total number of aliases:", len(aliases))
          sys.stdout.flush()
          return aliases
  
      # Now try to define a new one
      try:
          alias, cmd = par.split(None, 1)
      except TypeError:
          print(oinspect.getdoc(self.alias))
          return
  
      try:
          self.shell.alias_manager.define_alias(alias, cmd)
      except AliasError as e:
          print(e)
  
imports: import io
  import os
  import pathlib
  import re
  import sys
  from pprint import pformat
  from IPython.core import magic_arguments
  from IPython.core import oinspect
  from IPython.core import page
  from IPython.core.alias import AliasError, Alias
  from IPython.core.error import UsageError
  from IPython.core.magic import Magics, compress_dhist, magics_class, line_magic, cell_magic, line_cell_magic
  from IPython.testing.skipdoctest import skip_doctest
  from IPython.utils.openpy import source_to_unicode
  from IPython.utils.process import abbrev_cwd
  from IPython.utils.terminal import set_term_title
  from traitlets import Bool
  from warnings import warn
label_desc: Use image node_id 5 for calling the OSMagics obj's underlying member method code with example usage: obj.alias(parameter_s) and returns: aliases