fish
Overview
fish (Friendly Interactive Shell) is a user-friendly, intelligent command line shell. The x-cmd toolkit integrates with fish to add more enjoyment and efficiency to your command line journey.
Installing x-cmd
- One-Line Installation
Install using curl or wget:
bashcurl https://get.x-cmd.com | shor
bashwget -O- https://get.x-cmd.com | sh - Auto-Load at Startup
Configure fish to automatically load x-cmd at startup:
bash~/.x-cmd.root/bin/x-cmd fish --setupIf x command is already available in the current shell (such as bash), you can use:
bashx fish --setup
Tips
- Don't have fish installed?
x fishwill download and launch the latest stable version for you x fishprefers using the system-installed fish; if not found, it downloads automatically
Theme Customization
While x-cmd's theme module only supports POSIX shells, you can use ohmyposh and starship themes through x-cmd:
x starshipx ohmyposhx-cmd provides dedicated starship and ohmyposh modules with automatic installation, configuration, and theme preview features.
Important Notes
- After setting a theme, fish will automatically load it when starting up with x-cmd, no manual configuration needed
- ohmyposh has limited support for fish versions below 3.3. Upgrading to 3.3 or higher is recommended, or use starship instead
Smart Completions
After starting x-cmd, fish's command completion features are automatically activated.
How x fish --setup Works
fish loads the $HOME/.config/fish/config.fish file by default. x fish --setup adds this at the beginning:
test ! -e "$HOME/.x-cmd.root/local/data/fish/rc.fish" || source "$HOME/.x-cmd.root/local/data/fish/rc.fish" # boot up x-cmd.It also initializes the $HOME/.x-cmd.root/local/data/fish/rc.fish file. The source code is available in the x-cmd repository.
x fish: Running Fish Scripts
Even without fish pre-installed, you can use x fish to download and run fish scripts:
x fish # Interactive fish shell
x hi.fish # Run hi.fish in current directory
x fish hi.fish # Equivalent command
x ljh:hi.fish # Run script shared by author ljh on x-cmd hub
x fish ljh:hi.fish # Equivalent commandFor more information about the x-cmd hub service, see the hub module documentation.
Using x-cmd in Fish Scripts
x-cmd Already Installed
If x-cmd is already installed in the environment, use x fish to run scripts:
# v0.5.10 and above supported
source $HOME/.x-cmd.root/boot/rc.fish
# Now you can use x commands in the scriptNotes:
- Unlike other shells, fish loads
config.fishby default when executing scripts (non-interactive mode) - Use
--no-configor-Nflag to prevent loading
Installing x-cmd On-Demand
Install x-cmd on-demand in fish scripts (ensure curl or wget is installed):
test -f "$HOME/.x-cmd.root/X" || ! command -v curl || curl https://get.x-cmd.com | sh
test -f "$HOME/.x-cmd.root/X" || ! command -v wget || wget -O- https://get.x-cmd.com | sh
# v0.5.10 and above supported
source $HOME/.x-cmd.root/boot/rc.fish
# Now you can use x commands in the scriptIf you have any questions, feel free to provide feedback at the x-cmd source repository.
Help us make these docs great!
All X-CMD docs are generated from command help and multiple data sources. See something that's wrong or unclear? Feel free to let us know through any of these ways~