-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Doc magic alias #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Doc magic alias #221
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2456,19 +2456,15 @@ def magic_alias(self, parameter_s = ''): | |
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> | ||
whole line when the alias is called. | ||
|
||
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 | ||
In [2]: parts A B | ||
first A second B | ||
In [3]: %parts A | ||
In [3]: parts A | ||
Incorrect number of arguments: 2 expected. | ||
parts is an alias to: 'echo first %s second %s' | ||
|
||
|
@@ -2488,6 +2484,44 @@ def magic_alias(self, parameter_s = ''): | |
A Python string | ||
In [9]: show $$PATH | ||
/usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | ||
example: | ||
------- | ||
explanation:: | ||
|
||
here in this example we are aliasing the command ls with lst | ||
so that if we want to list the directories we can use the command lst. | ||
|
||
|
||
In [1]: alias lst ls | ||
In [2]: lst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't the best example - you can already use ls directly in IPython. |
||
COPYING.txt ipython.egg-info/ README.txt setupbase.pyc setup.py* | ||
docs/ ipython.py* scripts/ setupegg.py* tools/ | ||
IPython/ MANIFEST.in setupbase.py setupext/ | ||
|
||
In [1]: alias manual mkdir | ||
In [2]: manual | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you try running this, it doesn't actually do this. |
||
MKDIR(1) User Commands MKDIR(1) | ||
|
||
NAME | ||
mkdir - make directories | ||
|
||
SYNOPSIS | ||
mkdir [OPTION]... DIRECTORY... | ||
|
||
DESCRIPTION | ||
Create the DIRECTORY(ies), if they do not already exist. | ||
|
||
Mandatory arguments to long options are mandatory for short options | ||
too. | ||
|
||
-m, --mode=MODE | ||
set file mode (as in chmod), not a=rwx - umask | ||
|
||
-p, --parents | ||
no error if existing, make parent directories as needed | ||
|
||
-v, --verbose | ||
print a message for each created directory | ||
|
||
You can use the alias facility to acess all of $PATH. See the %rehash | ||
and %rehashx functions, which automatically create aliases for the | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this example been removed? It's a helpful addition to the bit above it.