This repository contains some files which are to be sourced by bash. The files contained are:
-
my_dash_functions: This file used to contain some functions which were used in some dash (POSIX) scripts I had. Currently, it simply contains some functions that are not used in most of my scripts. It is sourced by my_bash_functions.
-
my_bash_functions: This file contains some bash functions which are almost always used in my bash scripts. The important functions are:
centered_output: This outputs some text centered on the terminal. If the text is greater than the terminal width, then it simply prints the text.
run_loop: This outputs the text with a counter. The counter can go either up or down. The text should ideally be short enough to fit within the terminal width.
show_progress: This function outputs a nice progress bar to the terminal. It accepts two lines at each increment of the progress bar. The first line should be any status message, and the second line a ratio given in the form count/total.
-
my_read_files: This file provides several different interactive bash prompts which acts like a file browser or directory browser. The output file or directory will be present in the environment variable
FILEPATH
after any of these functions exit. There are several such functions available:-
read_filename: This gives a listing of files and directories starting from the current directory. It will shortlist and highlight the files and/or directories that match the typed text. It is possible to traverse directories by entering the directory name or the beginning part of the directory name and then pressing
ENTER
. This function has the following syntax:read_filename <0|1> [<suffix>]
where <0|1> must be specified to indicate whether
0
: only files are shown, or1
: both files and directories are shown. Thesuffix
is optional, and if specified, it will show only the file names with that particular suffix. If there is a file calleda.txt
and a directory calleda
then it is possible to go inside the directory by typinga/
and pressingENTER
. To go to parent directory, type..
. Screenshot for the commandread_filename 1 c
: -
read_dirname: This is a modified version of
read_filename
that provides files and directory listings only in the current directory. The names whose first part matches with the input text are highlighted. The syntax is:read_dirname [<dir>]
where the
dir
argument is optional and if not provided. Screenshot for the commandread_dirname
: -
read_dirname_short: This is a modified version of
read_dirname
that displays only the shortlisted files and directories, whereasread_dirname
displays all the files and directories and only highlights the shortlisted ones. Syntax is same asread_dirname
. Screenshot for the commandread_dirname_short
: -
read_dir_oneline: This function lists the files and directories in the specified directory and optionally displays a help text. The files and directory displays are not separated unlike the other functions
read_filename
,read_dirname
, andread_dirname_short
. This function shows everything within 4 lines in the terminal, and it will show only the shortlisted files and directories. It is very useful when one does not want the displayed terminal history to be lost. The syntax is:read_dir_oneline <dir> [<help text>]
where
dir
is the directory in which the files and directories should be displayed, andhelp text
can be optionally provided that will be shown along with the input text. Screenshot for the commandread_dir_oneline . " Example "
:
-