Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the customizable prompt across shell in Starship

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what is the customizable prompt across shell in Starship. It is very detailed and has certain reference value. If you are interested, you must read it.

Starship is an open source project written in Rust that helps you build a concise, fast, customizable shell prompt.

Whether you are using bash, fish, PowerShell on Windows, or other shell, you can use Starship to customize the look and feel.

Please note that you must know its official documentation to do advanced configuration of everything you like, but here, I will include a simple sample configuration to get off to a good start, as well as some key information about Startship.

Startship focuses on providing you with a concise, fast, and useful default shell prompt. It even records and displays the time it takes to execute a command. For example, here is a screenshot:

Not only that, it's pretty easy to customize the prompt to your liking.

Let me set it up for you. I tested it with bash shell on Ubuntu. You can refer to the steps I mentioned, or you can look at the official installation instructions for more options for installing it on your system.

The highlight of Starship

Cross platform

Cross-shell support

Ability to add custom commands

Customize the git experience

Customize the experience when using a specific programming language

Easily customize every aspect of the prompt without having a real impact on performance

Install Starship on Linux

To install Starship, download a bash script and run it with root privileges.

If you are not used to doing this, you can use snap.

Sudo snap install starship

Note: you need to install Nerd fonts to get a complete experience.

To get started, make sure you have curl installed. You can easily install it by typing the following command:

Sudo apt install curl

When you are finished, enter the following to install Starship:

Curl-fsSL https://starship.rs/install.sh | bash

This should install Starship to usr/local/bin as root. You may be prompted for a password. It looks like this:

Add Starship to bash

As shown in the screenshot, you will get the setting instructions in the terminal itself. Here, we need to add the following line to the end of the .bashrc user file:

Eval "$(starship init bash)"

To easily add, simply type:

Nano .bashrc

Then, navigate to the end of the file by scrolling down and add the line shown in the following figure at the end of the file:

When finished, you only need to restart the terminal or restart the session to see a compact prompt. It may look a little different to your shell, but it should be the same by default.

Once set up, you can continue to customize and configure the prompt. Let me show you an example of a configuration I made:

Configure the Starship prompt: basic

At first you only need to make a configuration file (TOML file) in the .config directory. If you already have this directory, navigate directly to it and create a configuration file.

The following is what you need to enter when creating directories and configuration files:

Mkdir-p ~ / .config & & touch ~ / .config/starship.toml

Please note that this is a hidden directory. So, when you try to access it from the home directory using the File Manager, be sure to enable viewing hidden files before continuing.

Next, if you want to explore something you like, you should refer to the configuration documentation.

For example, I configured a simple custom prompt that looks like this:

To achieve this goal, my configuration file looks like this:

According to their official documentation, this is a basic custom format. However, if you don't want to customize the format, but just want to customize the default prompt with a color or a different symbol, it will look like this:

Of course, this is not the best-looking prompt I can make, but I hope you understand how it is configured.

You can customize the appearance of the directory by including icons or emoticons. You can adjust variables, format strings, display git submissions, or adjust them according to your specific programming language.

Not only that, you can also create custom commands to use in your shell to make things easier or more comfortable.

You can explore more information on their official website and its GitHub page.

The above is all the content of the article "what are the customizable prompts across shell in Starship". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Original address: https://linux.cn/article-13152-1.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report