Git Product home page Git Product logo

bash-aux's Introduction

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

bash-aux's People

Contributors

simon-lenau avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.