Skip to content

Contains useful function for bash, like sort flatpak list

License

Notifications You must be signed in to change notification settings

gioisco/.bash_functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.bash_functions

A small Bash toolbox for everyday shell tasks.

The repository is organized in two parts:

  • Bash function files, loaded automatically in your shell.
  • Standalone scripts in Scripts/, exposed as normal commands through PATH.

Installation

Clone the repository into your home directory:

git clone <your-repo-url> ~/.bash_functions

Add this block to ~/.bashrc:

# Import ~/.bash_functions recursively
functions_directory="$HOME/.bash_functions"

_import_recursively() {
  local path="$1"
  local ignore_files=(
    "README.md"
    "LICENSE"
    "Scripts"
  )

  local name
  name="$(basename "$path")"

  local ignored
  for ignored in "${ignore_files[@]}"; do
    [[ "$name" == "$ignored" ]] && return 0
  done

  if [[ -d "$path" ]]; then
    local item
    for item in "$path"/*; do
      [[ -e "$item" ]] || continue
      _import_recursively "$item"
    done
  elif [[ -f "$path" ]]; then
    # shellcheck source=/dev/null
    source "$path"
  fi
}

if [[ -d "$functions_directory" ]]; then
  _import_recursively "$functions_directory"
  PATH="$PATH:$functions_directory/Scripts"
fi

Reload your shell:

source ~/.bashrc

Available Functions

flatpak-list

Wrapper around flatpak list --app with custom columns and sorting.

Examples:

flatpak-list
flatpak-list --sort=size
flatpak-list --columns=name,application,version,size
flatpak-list --help

lower_and_dash

Converts text to lowercase and replaces spaces with dashes.

Example:

lower_and_dash "My New Note"
# my-new-note

Available Scripts (Scripts/)

monitor-changes [INTERVAL_SECONDS]

Watches files in the current directory and prints changed paths.

Example:

monitor-changes
monitor-changes 1

Defaults to 2 seconds. Common heavy directories are excluded (.git, node_modules, dist, build, .next, .cache).

preview-numbered-renames.sh <directory>

Prints a numbered rename preview for files in chronological order.

Example:

preview-numbered-renames.sh ./photos

Notes

  • Function files are sourced in your current shell process.
  • Files inside Scripts/ are not sourced; they are executed as commands.
  • Keep executable scripts with chmod +x.

About

Contains useful function for bash, like sort flatpak list

Resources

License

Stars

Watchers

Forks

Languages