Comment

Comment by lowry

Truncate the $PWD to ¼ of the terminal width and put the result into the command prompt:

    # truncate the $PWD
    function cut_pwd
    {
      newPWD="${PWD/#$HOME/\~}"
      local pwdmaxlen=$((${COLUMNS:-80}/4))
      if [ ${#newPWD} -gt $pwdmaxlen ]
      then
         newPWD=".+${newPWD: -$pwdmaxlen}"
      fi
    }

    PROMPT_COMMAND=cut_pwd
    PS1="\h:\${newPWD} \\$ "
parent lowry 7 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton