Return list of shell aliases to auto-define.
()
| 38 | shell_line_split = re.compile(r'^(\s*)()(\S+)(.*$)') |
| 39 | |
| 40 | def default_aliases(): |
| 41 | """Return list of shell aliases to auto-define. |
| 42 | """ |
| 43 | # Note: the aliases defined here should be safe to use on a kernel |
| 44 | # regardless of what frontend it is attached to. Frontends that use a |
| 45 | # kernel in-process can define additional aliases that will only work in |
| 46 | # their case. For example, things like 'less' or 'clear' that manipulate |
| 47 | # the terminal should NOT be declared here, as they will only work if the |
| 48 | # kernel is running inside a true terminal, and not over the network. |
| 49 | |
| 50 | if os.name == 'posix': |
| 51 | default_aliases = [('mkdir', 'mkdir'), ('rmdir', 'rmdir'), |
| 52 | ('mv', 'mv'), ('rm', 'rm'), ('cp', 'cp'), |
| 53 | ('cat', 'cat'), |
| 54 | ] |
| 55 | # Useful set of ls aliases. The GNU and BSD options are a little |
| 56 | # different, so we make aliases that provide as similar as possible |
| 57 | # behavior in ipython, by passing the right flags for each platform |
| 58 | if sys.platform.startswith('linux'): |
| 59 | ls_aliases = [('ls', 'ls -F --color'), |
| 60 | # long ls |
| 61 | ('ll', 'ls -F -o --color'), |
| 62 | # ls normal files only |
| 63 | ('lf', 'ls -F -o --color %l | grep ^-'), |
| 64 | # ls symbolic links |
| 65 | ('lk', 'ls -F -o --color %l | grep ^l'), |
| 66 | # directories or links to directories, |
| 67 | ('ldir', 'ls -F -o --color %l | grep /$'), |
| 68 | # things which are executable |
| 69 | ('lx', 'ls -F -o --color %l | grep ^-..x'), |
| 70 | ] |
| 71 | elif sys.platform.startswith('openbsd') or sys.platform.startswith('netbsd'): |
| 72 | # OpenBSD, NetBSD. The ls implementation on these platforms do not support |
| 73 | # the -G switch and lack the ability to use colorized output. |
| 74 | ls_aliases = [('ls', 'ls -F'), |
| 75 | # long ls |
| 76 | ('ll', 'ls -F -l'), |
| 77 | # ls normal files only |
| 78 | ('lf', 'ls -F -l %l | grep ^-'), |
| 79 | # ls symbolic links |
| 80 | ('lk', 'ls -F -l %l | grep ^l'), |
| 81 | # directories or links to directories, |
| 82 | ('ldir', 'ls -F -l %l | grep /$'), |
| 83 | # things which are executable |
| 84 | ('lx', 'ls -F -l %l | grep ^-..x'), |
| 85 | ] |
| 86 | else: |
| 87 | # BSD, OSX, etc. |
| 88 | ls_aliases = [('ls', 'ls -F -G'), |
| 89 | # long ls |
| 90 | ('ll', 'ls -F -l -G'), |
| 91 | # ls normal files only |
| 92 | ('lf', 'ls -F -l -G %l | grep ^-'), |
| 93 | # ls symbolic links |
| 94 | ('lk', 'ls -F -l -G %l | grep ^l'), |
| 95 | # directories or links to directories, |
| 96 | ('ldir', 'ls -F -G -l %l | grep /$'), |
| 97 | # things which are executable |