Câu hỏi thường gặp
Cấu hình sử dụng trong demo GIF là gì?
- Terminal Emulator: iTerm2
- Theme: Minimal
- Color Scheme: Snazzy
- Font: FiraCode Nerd Font
- Shell: Fish Shell
- Cấu hình: matchai's Dotfiles
- Prompt: Starship
Làm thế nào tôi có được hoàn thiện câu lệnh như được hiển thị trong demo GIF?
Hỗ trợ hoàn thiện, hoặc tự động hoàn thiện, được cung cấp bởi shell của bạn lựa chọn. In the case of the demo, the demo was done with Fish Shell, which provides completions by default. If you use Z Shell (zsh), I'd suggest taking a look at zsh-autosuggestions.
Có phải level trên cùng format và <module>.disable thực hiện cùng một thứ giống nhau?
Vâng, chúng có thể cùng được sử dụng để vô hiệu hoá các module trong prompt. If all you plan to do is disable modules, <module>.disabled is the preferred way to do so for these reasons:
- Các module vô hiệu là ro ràng hơn sót chúng từ level trên cùng
format - Những module mới tạo sẽ được thêm bào prompt khi Starship được cập nhật
Các tài liệu nói Starship là cross-shell. Tại sao shell ưa thích của tôi không được hỗ trợ?
Cách Starship được xây dựng, nó nên khả thi để thêm hỗ trợ với bất kì shell ảo nào. Starship nhị phân là phi trạng thái và bất khả tri của shell, vì vậy, miễn là shell của bạn hỗ trợ tùy chỉnh nhanh chóng và mở rộng shell, thì Starship có thể được sử dụng.
Đây là một ví dụ nhỏ để Starship là việc với bash:
# Lấy mã trạng thái từ câu lệnh cuối đã được thực thi
STATUS=$?
# Lấy số lượng job đang chạy.
NUM_JOBS=$(jobs -p | wc -l)
# Thiết lập prompt thành đầu ra của `starship prompt`
PS1="$(starship prompt --status=$STATUS --jobs=$NUM_JOBS)"
Bản cài đặt Bash xây dựng bên trong Starship phực tạp hơn một chút để cho phép thực hiện các tính năng nâng cao hơn một chứt như Command Duration module và chắc chắn rằng Starship là tương thích với cấu hình Bash đã cài đặt trước đó.
Với một danh sách tất cả các cờ đã được chấp nhận bởi starship prompt, sử dụng lệnh sau:
starship prompt --help
Prompt sẽ sử dụng nhiều ngữ cảnh được cung câos, nhưng không có cờ nào là "yêu cầu".
Làm thế nào để tôi chạy Starship trên các bản phân phối Linux với các phiên bản cũ của glibc?
Nếu bạn nhận được một lỗi giống như "version 'GLIBC_2.18' not found (required by starship)" khi sử dụng prebuilt binary (ví dụ trên CentOS 6 hoặc 7), bạn có thể sử dụng tập tin đã được dịch với musl thay vì glibc:
curl -sS https://starship.rs/install.sh | sh -s -- --platform unknown-linux-musl
Why do I see Executing command "..." timed out. warnings?
Starship executes different commands to get information to display in the
prompt, for example the version of a program or the current git status. To make
sure starship doesn't hang while trying to execute these commands we set a time
limit, if a command takes longer than this limit starship will stop the
execution of the command and output the above warning, this is expected
behaviour. This time limit is configurable using the command_timeoutkey so if you want you can increase the time limit. You can
also follow the debugging steps below to see which command is being slow and
see if you can optimise it. Finally you can set the STARSHIP_LOG env var to
error to hide these warnings.
Tôi thấy các biểu tượng tôi không hiểu hoặc không mong muốn, chúng có nghĩa là gì?
Nếu bạn thấy các biểu tượng bạn không biết, bạn có thể sử dụng starship explain để giải thích các mô đun hiện tại đang hiển thị.
Starship is doing something unexpected, how can I debug it?
You can enable the debug logs by using the STARSHIP_LOG env var. These logs
can be very verbose so it is often useful to use the module command if you are
trying to debug a particular module, for example, if you are trying to debug
the rust module you could run the following command to get the trace
logs and output from the module.
env STARSHIP_LOG=trace starship module rust
If starship is being slow you can try using the timings command to see if there is a particular module or command that is to blame.
env STARSHIP_LOG=trace starship timings
This will output the trace log and a breakdown of all modules that either took more than 1ms to execute or produced some output.
Finally if you find a bug you can use the bug-report command to create a GitHub issue.
starship bug-report
Tại sao tôi không thấy một biểu tượng glyph trong dấu nhắc lệnh của tôi?
Đa số lí do phổ biến là do cái này mất cấu hình hệ thống. Một số bản phân phối Linux cụ thể không đi kèm việ hõ trợ font out-of-the-box. Bạn cần chắc chắn rằng:
- Your locale is set to a UTF-8 value, like
de_DE.UTF-8orja_JP.UTF-8. IfLC_ALLis not a UTF-8 value, you will need to change it. - Bạn đã cài đặt phông chữ biểu tượng cảm xúc. Most systems come with an emoji font by default, but some (notably Arch Linux) do not. You can usually install one through your system's package manager--noto emoji is a popular choice.
- Bạn đang sử dụng một Nerd Font.
Để kiểm tra hệ thống của bạn, chạy các câu lệnh bên dưới trong terminal:
echo -e "\xf0\x9f\x90\x8d"
echo -e "\xee\x82\xa0"
Dòng đầu tiên nên sinh ra một snake emoji, trong khi dòng thứ hai nên sinh ra một powerline branch symbol (e0a0).
Nếu biểu tượng không hiển thị đúng, hệ thống của bạn vẫn cấu hình sai. Thật không may, lấy cấu hình font đúng đôi khi khó khăn. Người dùng trên Discord có thể có giúp đỡ được. If both symbols display correctly, but you still don't see them in starship, file a bug report!
Là thế nào để tôi gỡ cài đặt Starship?
Starship thì dễ dàng gỡ cài đặt như cài đặt ngay từ đầu.
- Gỡ mọi tập tin trong cấu hình shell của bạn (e.g.
~/.bashrc) đã sử dụng để khởi tạo Starship. - Xoá tập tin Starship nhị phân.
Nếu Starship đã được cài đặt bằng việc sử dụng một trình quản lí gói, vui lòng tham khảo tài liệu của chúng để gỡ cài đặt.
If Starship was installed using the install script, the following command will delete the binary:
# Locate and delete the starship binary
sh -c 'rm "$(command -v 'starship')"'
How do I install Starship without sudo?
The shell install script (https://starship.rs/install.sh) only attempts to use sudo if the target installation directory is not writable by the current user. The default installation directory is the value of the $BIN_DIR environment variable or /usr/local/bin if $BIN_DIR is not set. If you instead set the installation directory to one that is writable by your user, you should be able to install starship without sudo. For example, curl -sS https://starship.rs/install.sh | sh -s -- -b ~/.local/bin uses the -b command line option of the install script to set the installation directory to ~/.local/bin.
For a non-interactive installation of Starship, don't forget to add the -y option to skip the confirmation. Check the source of the installation script for a list of all supported installation options.
When using a package manager, see the documentation for your package manager about installing with or without sudo.