I've seen some shells as part of the modification of the Mac terminal environment. bash, zsh, fish ...
Especially for the last six months, I've loved Python-made Xonsh, so I'll introduce it to myself.
By the way, the reason I found the original story was the blog of Mr. Bankushi, who is famous in the machine learning area.
Summary of impressions and environment settings using Python shell xonsh for half a year
This person is too amazing What's Xonsh
It's just the title, but it's ** Shell ** made in Python. ** Made in Python, works in Python and can run Python. ** **
I don't know why the other shells are working, but anyway, this one is super sharp and cool.
Commnd and Python One of the advantages of being made with Python is that commands and Python scripts can live together.
[ ~/Desktop/tmp ]
$ ls -al
Permissions Size User Date Modified Name
drwxr-xr-x - *** 18 12 19:20 .
drwx------ - *** 18 12 19:18 ..
[ ~/Desktop/tmp ]
$ dirs = ['a', 'b', 'c']
[ ~/Desktop/tmp ]
$ for dir in dirs:
. mkdir @(dir)
.
[ ~/Desktop/tmp ]
$ ls -al
Permissions Size User Date Modified Name
drwxr-xr-x - *** 18 12 19:21 .
drwx------ - *** 18 12 19:18 ..
drwxr-xr-x - *** 18 12 19:21 a
drwxr-xr-x - *** 18 12 19:21 b
drwxr-xr-x - *** 18 12 19:21 c
Like this. Mkdir x 3 is better than putting it in a variable and turning the for statement! !! You might think, Don't you think it's really cool if you use this when the processing has increased a lot?
As a matter of course, you can even define a function.
[ ~/Desktop/tmp ]
$ def hello_xonsh():
. print('hello xonsh !!!')
.
[ ~/Desktop/tmp ]
$ hello_xonsh()
hello xonsh !!!
.xonshrc Like other shells, xonsh has an rc file. (.Xonshrc) As you can imagine, this rc file can all be written in Python.
** Personally, this is too god to use **
aliases['ls'] = 'exa -ahl --git'
aliases['la'] = 'exa -ahl --git'
aliases['ll'] = 'exa -ahl --git'
aliases['l'] = 'exa -ahl --git'
aliases['cat'] = 'bat'
aliases['tf'] = 'terraform'
aliases['do'] = 'docker'
aliases['dc'] = 'docker-compose'
A dictionary type variable called aliases is defined internally and added to it. too cool.
import os
$DEV_ROOT = os.environ.get('HOME') + '/dev'
Environment variables are defined by $ + variable name. If you import it, you can use the standard Python library as much as you want.
def _set_aws_profile(args):
$AWS_PROFILE = args[0]
$AWS_DEFAULT_PROFILE = args[0]
print('aws profile is : ', p)
aliases['awsp'] = _set_aws_profile
Complex commands can be defined by functions and put into aliases as they are. You can receive command arguments with the args argument.
By the way, only args is defined here, but it seems that stdin and stdout can also be taken. (I haven't mastered it well here)
Install If you read this far and want to use it, install is a moment.
$ brew install xonsh
Or
$ pip install xonsh
And so on, it can be installed in most other environments.
Start up is that way
$ xonsh
Use Xonsh! Xonsh has some disadvantages because it is sharp. For example, depending on the command, there were times when it wouldn't work unless the arguments were well enclosed in single quotes.
However, I use it because it is a good condition that far exceeds such a small disadvantage.
If you like Python, give it a try! !!