Skip to content

Instantly share code, notes, and snippets.

@LeetCodes
Forked from jpaugh/.bashrc
Created September 7, 2021 13:48
Show Gist options
  • Save LeetCodes/009971dcfa22db0486a782931da763ab to your computer and use it in GitHub Desktop.
Save LeetCodes/009971dcfa22db0486a782931da763ab to your computer and use it in GitHub Desktop.

Revisions

  1. @jpaugh jpaugh created this gist Sep 6, 2017.
    33 changes: 33 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    if _BASHRC_WAS_RUN 2>/dev/null; then
    :;
    else # Stuff that only needs to run the first time we source .bashrc.
    # Useful to allow re-sourcing new changes, without breaking/changing things in this section
    alias _BASHRC_WAS_RUN=true
    # ... continued ...
    fi

    # Last mod time of a file or files
    get_file_timestamp () {
    ls -1 --time-style=+%s -l "$@" | cut -f6 -d" "
    }

    # Make sure our version of the .bashrc file is up-to-date, or reload it.
    chk_bashrc_timestamp () {
    if [[ "$_BASHRC_TIMESTAMP" -lt "$(get_file_timestamp "$HOME/.bashrc")" ]]; then
    echo >&2 "Reloading .bashrc..."
    . ~/.bashrc
    fi
    }
    _BASHRC_TIMESTAMP=$(date +%s)

    prompt_cmd () {
    chk_bashrc_timestamp
    }
    PROMPT_COMMAND=prompt_cmd

    # some ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'

    # ... continued ...