Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oh-my-xonsh/xontrib-default-command
Run a default command when you press return on an empty command line
https://github.com/oh-my-xonsh/xontrib-default-command
extension python shell xonsh xontrib
Last synced: about 1 month ago
JSON representation
Run a default command when you press return on an empty command line
- Host: GitHub
- URL: https://github.com/oh-my-xonsh/xontrib-default-command
- Owner: oh-my-xonsh
- License: mit
- Archived: true
- Created: 2021-11-13T15:25:37.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-15T19:43:28.000Z (over 2 years ago)
- Last Synced: 2024-09-17T20:18:31.057Z (3 months ago)
- Topics: extension, python, shell, xonsh, xontrib
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xontribs - default-command - Run a default command when you press return on an empty command line. (Plugins / Prompt tweaks)
README
# xontrib-default-command
This [Oh-My-Xonsh][omx] plugin for the [xonsh] shell runs a default command when you
press return on an empty command line.By default, this command will run `ls`. If `$PWD` is a git project, it will also
run a short git status with `git status -s`.## Customizing
You can redefine the `defaultcmd` function in your [rc.xsh] to do whatever you want.
For example, if you want a detailed `ls` and `git status`, you could do this instead:
```python
def defaultcmd():
"""Run a detailed ls and git status when no other command given"""
newcmd = "ls -laFG"
if p'$PWD/.git'.exists():
newcmd += " && git status"
return newcmd
```## Installation
Install from PyPI via `xpip`:
```shell
xpip install xontrib-default-command
# or: xpip install -U git+https://github.com/oh-my-xonsh/xontrib-default-command
```Then, add this to your [rc.xsh]:
```shell
xontrib load default_command
```## Similar projects
- Oh-My-Zsh has a [magic-enter plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/magic-enter)
- Zsh has another one called [auto-ls](https://github.com/desyncr/auto-ls)[xonsh]: https://xon.sh
[omx]: https://github.com/oh-my-xonsh
[rc.xsh]: https://xon.sh/xonshrc.html