Segments are the parts that make up the prompt. They can be added and removed in any order. They are executed asynchronously so they cannot be dependent on other segments.
You can create your own segments by placing a file in:
${HOME}/.config/sbp/segments/${your_segment_name}.bash
This script should contain at least a function called
segments::${your_segment_name}
and it will have the following variables
available upon execution:
- COMMAND_EXIT_CODE, the exit code of the privous shell command
- COMMAND_DURATION, the duration of the shell command
- SBP_TMP, a tmp folder which is local to your shell PID and cleaned upon exit
- SBP_CACHE, a cache folder which is global to all SBP processes
- SBP_PATH, the path to the SBP diectory
- SEGMENTS_MAX_LENGTH tells your segment how much space it should use. This is
not a hard limit, but a suggestion for when to start trimming/compacting the
segment.
When you have defined the parts you want to use in your segment you need to theme the parts by issuing the following command:
print_themed_segment 'normal/higlight' "${segment_pars[@]}"
All segments should adhere to the SEGMENTS_MAX_LENGTH variable, but you can set SEGMENTS_${SEGMENT}_MAX_LENGTH to a specific value or -1 to disable truncation/compacting for that specific segment.
Shows the current active aws profile
shows the time spent on the last command, and turns red if it failed
shows the value of the last exitcode
shows the git branch and current status, set ´SEGMENTS_GIT_BRANCH_ONLY=true´ to speed up execution on large repos. The default value is ´false´.
shows the ${USER} and ${HOSTNAME} if you are logged in through ssh
shows the current user/cluster/project Setting ´SEGMENTS_K8S_DEFAULT_USER´ will hide the user if it's the default user Setting ´SEGMENTS_K8S_HIDE_CLUSTER´ to 1 will hide the cluster name. The default values are '' and 0 respectively.
shows the average load of the machine
shows wether you are in a nix-shell or not
shows the current path
shows a lock if current path is read only
Shows a simple character before the end of the prompt
shows the virtual env settings for current folder
Shows Productivity score and logged time for the day. Requires ´RESCUETIME_API_KEY´ to be set in the environment
Shows the Terraform version in directories with Terraform files. Supports version managers 'tfenv' and 'asdf'.
Directories to be scanned can be configured with array SEGMENTS_TF_SCANNED_DIRS
(default: $PWD),
file extension to look for with TF_FILE_EXTENSION
(default: tf).
Nerdfont icon will be used when setting SEGMENTS_USE_NERDFONTS
to 1. Overriding the default icon is possible with SEGMENTS_TF_ICON
.
shows a timestamp generated by date formatted by ´SEGMENTS_TIMESTAMP_FORMAT´, the default value is '%H:%M:%S' and the output is generated by the unix ´date´ command.
Shows the weather based on ´SEGMENTS_WTTR_LOCATION´ and ´SEGMENTS_WTTR_FORMAT´, the default values are ´Oslo´ and ´%p;%t;%w´ respectively.