Skip to content

simon-lenau/bash-aux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bash-aux

Collection of helpful functions for bash. Core functions are outlined below.

Core functions

Dependency checks

check_dependencies

check_dependencies   
   Check whether multiple shell-commands are available

   Arguments:      
      --commands <array> 
         The commands to be checked for availability
         Default: ls chmod

   Usage:      
      check_dependencies \
         --commands "ls chmod"

check_dependency

check_dependency   
   Check whether a single shell-commands is available

   Arguments:      
      --command  <str> 
         The command to be checked for availability
         Default: ls

   Usage:      
      check_dependency \
         --command  "ls"

Folders & Files

current_file

current_file   
   Determine the current file path, using 
   bash    : ${BASH_SOURCE[0]}                                         
   zsh     : ${(%):-%x}                                              

   Usage:      
      current_file

make_file_path

make_file_path   
   Create file from path, create path if it does not exist

   Arguments:      
      --file     <str> 
         The file to create the path for
         Default: ~/path/to/file

   Usage:      
      make_file_path \
         --file     "~/path/to/file"

normalize_path

normalize_path   
   Normalize a folder / file path

   Arguments:      
      --path     <str> 
         The path to normalize
         Default: ~/path/to/file

   Usage:      
      normalize_path \
         --path     "~/path/to/file"

read_from_file

read_from_file   
   Read a file.
   Like `cat`, but returns empty string if file does not exist

   Arguments:      
      --file     <str> 
         The file to read from
         Default: ~/path/to/file

   Usage:      
      read_from_file \
         --file     "~/path/to/file"

Logging

bash_aux_log   
   Create log files based on the called function's name

   Arguments:      
      --path     <str> 
         The path to create the log files in
         Default: .
      --content  <str> 
         The content to log
         Default: Hello, world!

   Usage:      
      bash_aux_log \
         --path     "." \
         --content  "Hello, world!"

Misc

read_non_blocking

read_non_blocking   
   Read input from stdin / pipe / user input, but don't wait for the input

   Usage:      
      read_non_blocking

About

Collection of helpful functions for bash.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages