Skip to content

Instantly share code, notes, and snippets.

@killshot13
Last active August 14, 2022 13:32
Show Gist options
  • Save killshot13/cb5b8fd883cf0a63303012911d2617b2 to your computer and use it in GitHub Desktop.
Save killshot13/cb5b8fd883cf0a63303012911d2617b2 to your computer and use it in GitHub Desktop.
bash_scripts

common.md

Documents scripts that a developer might have need to run frequently. Includes all functions from ~/.bash_functions, along with any related aliases.

Table of Contents

  1. cl() — Combines the cd and ls commands into one; adds a trailing slash to directories making them easier to identify in no-color terminals.


cl()

# !/usr/bin/env bash
function cl() {
    DIR="$*"
    # if no DIR given, go home
    if [ $# -lt 1 ]; then
        DIR=$HOME
    fi
    builtin cd "${DIR}" &&
        # use your preferred ls command
        ls -F --color=auto
}

Infrequent.md

These scripts ought to be those that a developer might not use quite as often, perhaps only rarely, but still wishes to retain their convenience.

Table of Contents

  • 1. Tests the local environment for all supported programming languages and returns a list of each that is found.

  • 2.

  • 3.

  • 4.

  • 5.

  • 6.

  • 7.

  • 8.

  • 9.

  • 10.

1.

#!/usr/bin/env bash

identifiers="node npm express php perl mysql python3 c c++ ruby git docker docker-compose gh heroku"

usrbin="ls /usr/bin" \
    localbin="ls /usr/local/bin" \
    pkgbin="ls /home/linuxbrew/.linuxbrew/bin"

for i in $identifiers; do
    echo 'EXISTS?' $i
    for j in $($usrbin); do
        if [[ $i == $j ]]; then
            echo APT-GET: YES!
            echo ""
            echo BIN: $i @"$HOME/usr/bin"
        fi
    done
    for k in $($localbin); do
        if [[ $i == $k ]]; then
            echo APT-LOCAL: YES!
            echo ""
            echo BIN: $i @"$HOME/usr/local/bin"
        fi
    done
    for l in $($pkgbin); do
        if [[ $i == $l ]]; then
            echo Linuxbrew: YES!
            echo ""
            echo BIN: $i @"$HOME/linuxbrew/.linuxbrew/bin"
        fi
    done
    echo ""
    echo PATH: "$(which $i)"
    echo VERSION: "$($i --version)"
    echo ""
    echo END $i
    echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment