Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # tivasyk <[email protected]>
- # Draw a simple screen-wide ruler
- TICK_0='┼'
- TICK_5='┴'
- TICK_1='─'
- SCREEN_WIDTH=$(tput cols)
- # Prepare the ruler
- for (( i=1; i<=SCREEN_WIDTH; i++)); do
- if [[ $(( i % 10 )) == 0 ]]; then
- RULER_STRING+=$TICK_0
- if [[ ${#i} > 1 ]]; then
- RULER_LABELS=${RULER_LABELS::(-$(( ${#i} -1 )) ) }
- fi
- RULER_LABELS+="${i}"
- elif [[ $(( i % 5 )) == 0 ]]; then
- RULER_STRING+=$TICK_5
- RULER_LABELS+=' '
- else
- RULER_STRING+=$TICK_1
- RULER_LABELS+=' '
- fi
- done
- # Print the ruler in invented colors
- tput rev
- printf "%s\n%s\n" "${RULER_LABELS}" "${RULER_STRING}"
- tput sgr0
Advertisement
Add Comment
Please, Sign In to add comment