Skip to content

alex-crouch/zsh-diskfree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

zsh-disk🆓

Oh My Zsh plugin that displays the free space available on your disk right in your terminal prompt.

Examples

Features

  • 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

Installation

  1. 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
  1. Add the plugin to your .zshrc file:
plugins=(... zsh-diskfree)
  1. 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-theme

For example with the robbyrussell theme:

PROMPT='%(?:%{$fg_bold[green]%}%1{➜%} :%{$fg_bold[red]%}%1{➜%} ) $(diskfree_prompt_info) %{$fg[cyan]%}%c%{$reset_color%}'
  1. Reload
omz reload

Configuration

You can configure the plugin by editing the config file:

nano ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-diskfree/zsh-diskfree.conf

or 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.

Auto-Updating Prompt (Optional)

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
}

About

Oh My Zsh plugin that displays the free space available on your disk right in your terminal prompt.

Topics

Resources

License

Stars

Watchers

Forks

Languages