Oh My Zsh plugin that displays the free space available on your disk right in your terminal prompt.
- Shows available free disk space in your prompt with customisable units
- Automatically updates as you run commands
- Option to show free space for all disks or just the current disk
- Clone this repository to your Oh My Zsh custom plugins directory:
git clone https://github.com/alex-crouch/zsh-diskfree.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-diskfree- Add the plugin to your
.zshrcfile:
plugins=(... zsh-diskfree)- Integrate with your theme
To diplay the disk info on your prompt just edit your theme file and put the prompt call $(diskfree_prompt_info) into the prompt variable.
nano ${ZSH:-~/.oh-my-zsh}/themes/$ZSH_THEME.zsh-themeFor example with the robbyrussell theme:
PROMPT='%(?:%{$fg_bold[green]%}%1{➜%} :%{$fg_bold[red]%}%1{➜%} ) $(diskfree_prompt_info) %{$fg[cyan]%}%c%{$reset_color%}'- Reload
omz reloadYou can configure the plugin by editing the config file:
nano ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-diskfree/zsh-diskfree.confor by adding environment variables to .zshrc eg. export ZSH_DISKFREE_UNIT_GAP=1. The variable names can be found in the configuration file and just need the ZSH_DISKFREE_ prefix.
To make your prompt automatically update when idle at a prompt, add these lines to the top of your theme file, the TMOUT value is the refresh rate in seconds:
TMOUT=1
TRAPALRM() {
# Don't reset prompt unless idle
if [[ "$KEYMAP" == "main" && -z "$BUFFER" &&
"$WIDGET" != "up-line-or-history" &&
"$WIDGET" != "down-line-or-history" &&
"$WIDGET" != "history-beginning-search-backward" &&
"$WIDGET" != "history-beginning-search-forward" &&
-z "$PREBUFFER" && -z "$LBUFFER" && -z "$RBUFFER" &&
-z "$PREDISPLAY" && -z "$POSTDISPLAY" ]]; then
zle reset-prompt
fi
}