{"id":13587636,"url":"https://github.com/vegardit/bash-funk","last_synced_at":"2025-04-13T21:13:26.860Z","repository":{"id":21450652,"uuid":"92762073","full_name":"vegardit/bash-funk","owner":"vegardit","description":"bash-funk is a collection of useful commands for Bash 3.2 or higher.","archived":false,"fork":false,"pushed_at":"2024-10-21T11:42:01.000Z","size":2789,"stargazers_count":54,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-13T21:13:22.228Z","etag":null,"topics":["ansi","aws","bash","bash-alias","bash-hacks","bash-prompt","bash-script","bash-scripting","cygwin","docker","git","shell-scripts"],"latest_commit_sha":null,"homepage":"https://vegardit.github.io/bash-funk/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vegardit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-29T17:41:27.000Z","updated_at":"2025-02-14T14:53:12.000Z","dependencies_parsed_at":"2023-12-06T05:28:56.811Z","dependency_job_id":"888077f1-b1ed-4720-9d02-c6a5f8af5802","html_url":"https://github.com/vegardit/bash-funk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fbash-funk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fbash-funk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fbash-funk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fbash-funk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vegardit","download_url":"https://codeload.github.com/vegardit/bash-funk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782260,"owners_count":21160717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","aws","bash","bash-alias","bash-hacks","bash-prompt","bash-script","bash-scripting","cygwin","docker","git","shell-scripts"],"created_at":"2024-08-01T15:06:17.799Z","updated_at":"2025-04-13T21:13:26.837Z","avatar_url":"https://github.com/vegardit.png","language":"Shell","readme":"# bash-funk - Spice up your Bash! \u003ca href=\"https://github.com/vegardit/bash-funk/\" title=\"GitHub Repo\"\u003e\u003cimg height=\"30\" src=\"https://raw.githubusercontent.com/simple-icons/simple-icons/develop/icons/github.svg?sanitize=true\"\u003e\u003c/a\u003e\n\n[![Build Status](https://github.com/vegardit/bash-funk/workflows/Build/badge.svg \"GitHub Actions\")](https://github.com/vegardit/bash-funk/actions?query=workflow%3ABuild)\n[![License](https://img.shields.io/github/license/vegardit/bash-funk.svg?label=license)](#license)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\n1. [What is it?](#what-is-it)\n1. [Installation](#install)\n    1. [Using git](#install-with-git)\n    1. [Using subversion](#install-with-svn)\n    1. [Using curl](#install-with-curl)\n    1. [Using wget](#install-with-wget)\n    1. [Portable on Windows](#install-win-portable)\n1. [Usage](#usage)\n   1. [Customization](#customization)\n   1. [Directory-scoped Environment Variables and Aliases](#bash_funk_dir_rc)\n   1. [Efficiently navigating the filesystem](#efficient_fs_navigation)\n   1. [Using bash-funk modules separately](#using_modules_separately)\n1. [Updating](#update)\n1. [License](#license)\n\n\n## \u003ca name=\"what-is-it\"\u003e\u003c/a\u003eWhat is it?\n\nbash-funk is a collection of useful commands for Bash 3.2 or higher.\n\nSee the markdown files of the different [Bash modules](docs) for detailed information about the provided commands:\n  * [ansi](docs/ansi.md) - ANSI colored text output\n  * [aws](docs/aws.md) - query information about Amazon WebServices (AWS)\n  * [compression](docs/compression.md) - file compression\n  * [crypto](docs/crypto.md) - encryption and checksums\n  * [docker](docs/docker.md) - Docker and Docker Swarm management\n  * [filesystem](docs/filesystem.md) - filesystem navigation and file operations\n  * [git](docs/git.md) - working with GIT repositories\n  * [math](docs/math.md) - mathematical operations\n  * [memory](docs/memory.md) - query RAM information\n  * [misc](docs/misc.md) - useful commands that did not yet made it into a separate module\n  * [network](docs/network.md) - query network information\n  * [openssl](docs/openssl.md) - generate certificates and CAs with OpenSSL\n  * [os](docs/os.md) - query presence of commands and installed software packages\n  * [performance](docs/performance.md) - test CPU, disk and network performance\n  * [processes](docs/processes.md) - query process information or kill processes by parent PID or used TCP ports\n  * [random](docs/random.md) - generate random strings\n  * [ssh](docs/ssh.md) - SSH key management operations\n  * [strings](docs/strings.md) - String manipulations\n\nAn adaptive bash prompt is provided too:\n\n![console](docs/img/console.png)\n\nAll bash-funk commands have a descriptive online help:\n\n![function_help](docs/img/function_help.png)\n\nThe command [-help](docs/misc.md#-help) shows a list of all available commands\n\n![help](docs/img/help.png)\n\n\n## \u003ca name=\"install\"\u003e\u003c/a\u003eInstallation\n\n### \u003ca name=\"install-with-git\"\u003e\u003c/a\u003eUsing Git\n\nExecute:\n```bash\ngit clone https://github.com/vegardit/bash-funk --branch main --single-branch ~/bash-funk\n```\n\n### \u003ca name=\"install-with-svn\"\u003e\u003c/a\u003eUsing Subversion\n\nExecute:\n```bash\nsvn checkout https://github.com/vegardit/bash-funk/trunk ~/bash-funk\n```\n\n### \u003ca name=\"install-with-curl\"\u003e\u003c/a\u003eUsing Curl\n\nExecute:\n```bash\nmkdir ~/bash-funk \u0026\u0026 \\\ncd ~/bash-funk \u0026\u0026 \\\ncurl -#L https://github.com/vegardit/bash-funk/tarball/main | tar -xzv --strip-components 1\n```\n\n### \u003ca name=\"install-with-wget\"\u003e\u003c/a\u003eUsing wget\n\nExecute:\n```bash\nmkdir ~/bash-funk \u0026\u0026 \\\ncd ~/bash-funk \u0026\u0026 \\\nwget -qO- --show-progress https://github.com/vegardit/bash-funk/tarball/main | tar -xzv --strip-components 1\n```\n\n### \u003ca name=\"install-win-portable\"\u003e\u003c/a\u003ePortable on Windows\n\nFor your convenience we created a simple bootstrap Windows batch file that sets up a portable [Cygwin](http://cygwin.org) installation pre-configured with bash-funk.\n\nFor more details see https://github.com/vegardit/cygwin-portable-installer#install.\n\n\n## \u003ca name=\"usage\"\u003e\u003c/a\u003eUsage\n\nOnce bash-funk is installed, it can be used by sourcing the `bash-funk.sh` script which will then load all modules.\n\n```bash\n$ source ~/bash-funk/bash-funk.sh\n```\n\nAll bash-funk commands are prefixed with a `-` by default and support the `--help` option.\n\nBash completion for options is supported by all commands too, simply type a dash (-) and hit the [TAB] key twice.\n\n\n### \u003ca name=\"customization\"\u003e\u003c/a\u003eCustomization\n\nThe following environment variables can be set in `~/.bash_funk_rc` to customize bash-funk's behavior. This file will be sourced automatically.\n\n- `BASH_FUNK_PREFIX` - if specified, the names of all bash-funk commands will be prefixed with this value. Must only contain alphanumeric characters `a-z`, `A-Z`, `0-9`) and underscore `_`.\n- `BASH_FUNK_DIRS_COLOR` - ANSI color code to be used by the bash prompt to highlight directories, default is `94` which will be transformed to `\\e[94m`\n- `BASH_FUNK_NO_EXPORT_FUNCTIONS` - if set to any value bash-funk commands are not exported to sub-shells, thus will not be available in your own shell scripts.\n- `BASH_FUNK_NO_TWEAK_BASH` - if set to any value bash-funk will not automatically invoke the [-tweak-bash](docs/misc.md#-tweak-bash) command when loading.\n- `BASH_FUNK_NO_PROMPT` - if set to any value bash-funk will not install it's Bash prompt function.\n- `BASH_FUNK_PROMPT_PREFIX` - text that shall be shown at the beginning of the Bash prompt, e.g. a stage identifier (DEV/TEST/PROD)\n- `BASH_FUNK_PROMPT_DATE` - prompt escape sequence for the date section, default is `\\t`, which displays current time. See http://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html\n- `BASH_FUNK_PROMPT_NO_JOBS` - if set to any value the Bash prompt will not display the number of shell jobs.\n- `BASH_FUNK_PROMPT_NO_SCREENS` - if set to any value the Bash prompt will not display the number of detached screen/tmux sessions\n- `BASH_FUNK_PROMPT_NO_TTY` - if set to any value the Bash prompt will not display the current tty.\n- `BASH_FUNK_PROMPT_NO_KUBECTL` - if set to any value the Bash prompt will not display [kubectl](https://kubernetes.io/docs/reference/kubectl/)'s current context\n- `BASH_FUNK_PROMPT_NO_GIT` - if set to any value the Bash prompt will not display GIT branch and modification information.\n- `BASH_FUNK_PROMPT_NO_SVN` - if set to any value the Bash prompt will not display SVN branch and modification information.\n\n\n### \u003ca name=\"bash_funk_dir_rc\"\u003e\u003c/a\u003eDirectory-scoped Environment Variables and Aliases\n\nWhen changing into a directory, the bash-funk Bash prompt can automatically evaluate `.bash_funk_dir_rc` files found in the current directory or it's parent directories\nto set context-relevant environment variables.\n\n*This feature is disabled by default.* To enable it, define the variable `BASH_FUNK_PROMPT_DIRENV_AUTHORIZED_DIRS` in `~/.bash_funk_rc` as an Bash array containing fully qualified paths to trusted directories.\nOnly `.bash_funk_dir_rc` files found in these directories will be evaluated for security reasons. The entries in `BASH_FUNK_PROMPT_DIRENV_AUTHORIZED_DIRS` may also expressed as a variant of [glob patterns](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html),\nwhere `*` will match one directory level and `**` any directory level.\n\nThe `.bash_funk_dir_rc` are executed in a sub-shell, whose output is captured and parsed. All lines matching the pattern `export \u003cVARNAME\u003e=\u003cVALUE\u003e` or `alias \u003cVARNAME\u003e=\u003cVALUE\u003e` will then be executed via `eval` in the context of the current shell.\n\nIf multiple files named `.bash_funk_dir_rc` are found in the directory hierarchy (from the current directory up to `/`), they will be all evaluated starting with the file at the highest level (i.e. /).\n\nHere is an example setup:\n\n1. A file at `/opt/projects/.bash_funk_dir_rc` containing:\n    ```bash\n    #!/usr/bin/env bash\n    echo \"export JAVA_VERSION=1.8\"\n    echo \"export MAVEN_VERSION=3.5\"\n    ```\n1. A file at `/opt/projects/project1/.bash_funk_dir_rc` containing:\n    ```bash\n    #!/usr/bin/env bash\n\n    # override JAVA_VERSION=1.8 from /opt/projects/.bash_funk_dir_rc\n    echo \"export JAVA_VERSION=9\"\n    ```\n1. `BASH_FUNK_PROMPT_DIRENV_TRUSTED_DIRS` in `~/.bash_funk_rc`, either explicit:\n    ```bash\n    BASH_FUNK_PROMPT_DIRENV_TRUSTED_DIRS=(\n      \"/opt/projects\"\n      \"/opt/projects/project1\"\n      \"/opt/projects/project2\"\n    )\n    ```\n    or with single-level pattern matching\n    ```bash\n    BASH_FUNK_PROMPT_DIRENV_TRUSTED_DIRS=(\n      \"/opt/projects/*\"\n    )\n    ```\n    or with multi-level pattern matching\n    ```bash\n    BASH_FUNK_PROMPT_DIRENV_TRUSTED_DIRS=(\n      \"/opt/**\"\n    )\n    ```\n1. If you now `cd` into `/opt/projects/project1/` the environment variables `JAVA_VERSION=9` and `MAVEN_VERSION=3.5` are present.\n1. If you go one level up to `/opt/projects/`, `JAVA_VERSION=1.8` will be set.\n1. If you go one level up to `/opt`, the environment variables `JAVA_VERSION` and `MAVEN_VERSION` will be unset.\n1. If you comment out the first entry in `BASH_FUNK_PROMPT_DIRENV_TRUSTED_DIRS` in `~/.bash_funk_rc`:\n    ```bash\n    BASH_FUNK_PROMPT_DIRENV_TRUSTED_DIRS=(\n      #\"/opt/projects\"\n      \"/opt/projects/project1\"\n      \"/opt/projects/project2\"\n    )\n    ```\n    and again `cd` into `/opt/projects/project1/` only the environment variables `JAVA_VERSION=9` will be present\n    as the `/opt/projects/.bash_funk_dir_rc` is not evaluated anymore.\n\n\n### \u003ca name=\"efficient_fs_navigation\"\u003e\u003c/a\u003eEfficiently navigating the filesystem\n\n1. Navigating **up** the directory tree\n\n   1. Navigating to the parent directory:\n      \u003cpre\u003e\n      [me@local /opt/projects/project1/src/main/java/com/\u003cb\u003eacme\u003c/b\u003e] $ \u003cb\u003e..\u003c/b\u003e\n      [me@local /opt/projects/project1/src/main/java/com] $\n      \u003c/pre\u003e\n\n   1. Navigating to the parent's parent directory:\n      \u003cpre\u003e\n      [me@local /opt/projects/project1/src/main/java/\u003cb\u003ecom/acme\u003c/b\u003e] $ \u003cb\u003e...\u003c/b\u003e\n      [me@local /opt/projects/project1/src/main/java] $\n      \u003c/pre\u003e\n\n   1. Navigating up n-levels:\n      \u003cpre\u003e\n      [me@local /opt/projects/project1/\u003cb\u003esrc/main/java/com/acme\u003c/b\u003e] $ .. 5\n      [me@local /opt/projects/project1] $\n      \u003c/pre\u003e\n\n   1. Navigating up to a directory with a given name:\n      \u003cpre\u003e\n      [me@local /opt/projects/\u003cb\u003eproject1\u003c/b\u003e/src/main/java/com/acme] $ .. \u003cb\u003eproject1\u003c/b\u003e\n      [me@local /opt/projects/project1] $\n      \u003c/pre\u003e\n\n   **Note:** `..` is an alias for the command \u003ca href=\"docs/filesystem.md#-cd-up\"\u003e-cd-up\u003c/a\u003e which you also can use, e.g. `-cd-up 5`\n\n1. Navigating **down** the directory tree to a directory with a given name:\n\n   \u003cpre\u003e\n   [me@local /opt/projects/project1] $ ++ \u003cb\u003eacme\u003c/b\u003e\n   [me@local /opt/projects/project1/src/main/java/com/\u003cb\u003eacme\u003c/b\u003e] $\n   \u003c/pre\u003e\n\n   **Note:**  `++` is an alias for \u003ca href=\"docs/filesystem.md#-cd-up\"\u003e-cd-down\u003c/a\u003e which you also can use, e.g. `-cd-down acme`\n\n1. Navigating **back** in the directory history\n\n   1. Navigate back to the last visited directory:\n      \u003cpre\u003e\n      [me@local /var/log/project1/\u003cb\u003emod1\u003c/b\u003e] $ cd /opt/projects/project1\n      [me@local /opt/projects/project1] $ -\n      [me@local /var/log/project1/\u003cb\u003emod1\u003c/b\u003e] $\n      \u003c/pre\u003e\n\n   1. Navigate back to a directory with a given name:\n      \u003cpre\u003e\n      [me@local /var/log/project1/\u003cb\u003emod1\u003c/b\u003e] $ cd /opt/projects/project1\n      [me@local /opt/projects/project1] $ cd /opt/projects/project2\n      [me@local /opt/projects/project2] $ cd /var/log/project2/mod2\n      [me@local /var/log/project2/mod2] $ -- \u003cb\u003emod1\u003c/b\u003e\n      [me@local /var/log/project1/\u003cb\u003emod1\u003c/b\u003e] $\n      \u003c/pre\u003e\n\n   1. Navigate back to the n-last visited directory:\n      \u003cpre\u003e\n      [me@local /var/log/project1/\u003cb\u003emod1\u003c/b\u003e] $ cd /opt/projects/project1\n      [me@local /opt/projects/project1] $ cd /opt/projects/project2\n      [me@local /opt/projects/project2] $ cd /var/log/project2/mod2\n      [me@local /var/log/project2/mod2] $ -- \u003cb\u003e3\u003c/b\u003e\n      [me@local /var/log/project1/\u003cb\u003emod1\u003c/b\u003e] $\n      \u003c/pre\u003e\n\n   **Note:** `--` is an alias for \u003ca href=\"docs/filesystem.md#-cd-up\"\u003e-cd-hist\u003c/a\u003e which you also can use, e.g. `-cd-hist mod1`\n\n\n\n### \u003ca name=\"using_modules_separately\"\u003e\u003c/a\u003eUsing bash-funk modules separately\n\nAll bash-funk modules are self-containing. This means, if you are only interested in the commands provided by one module, you can also directly source that particular module located in the `modules` folder and do not use the `bash-funk.sh` loader script.\n\n\n## \u003ca name=\"update\"\u003e\u003c/a\u003eUpdating\n\nOnce loaded, you can easily update your bash-funk installation to the latest code base by using the [-update](docs/misc.md#-update) command:\n\n```bash\n-update -yr\n```\n\nor:\n\n```bash\n-update --yes --reload\n```\n\n\n## \u003ca name=\"license\"\u003e\u003c/a\u003eLicense\n\nAll files are released under the [Apache License 2.0](LICENSE.txt).\n\nIndividual files contain the following tag instead of the full license text:\n```\nSPDX-License-Identifier: Apache-2.0\n```\n\nThis enables machine processing of license information based on the SPDX License Identifiers that are available here: https://spdx.org/licenses/.","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegardit%2Fbash-funk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvegardit%2Fbash-funk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegardit%2Fbash-funk/lists"}