Last active
          January 12, 2018 15:33 
        
      - 
      
 - 
        
Save busterc/6e0d31169ce552b41854 to your computer and use it in GitHub Desktop.  
    countdown timer for bash #bash
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| function timer() { | |
| if [[ $1 -lt 1 ]]; then | |
| cat <<EOF | |
| Usage: timer <seconds> | |
| EOF | |
| return 1 | |
| fi | |
| local n="$1" | |
| while [[ $n -gt 0 ]]; do | |
| printf "\r\033[0K==> $n" | |
| sleep 1 | |
| ((n--)) | |
| done | |
| printf "\r\a" | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment