Giter Site home page Giter Site logo

xjtools's Introduction

xjtools

Collection of small tools and scripts used daily, along with a small framework for quickly creating new tools, and editing current ones.

Installation

  1. Clone this repository with $ git clone https://github.com/xander-jones/xjtools.git
  2. Add the following function to ~/.zshrc, or ~/.bashrc depending on zsh or bash terminal use
  3. Modify the PYTHON_INTERPRETER value if you'd like to use a different Python version.
  4. Modify the INSTALL_DIR to the directory where the repository has been cloned to.
  5. Refresh your zsh/bash environment with $ source ~/.zshrc or $ source ~/.bashrc
# xjtools
tools() {
  # xjtools - Configuration start
  PYTHON_INTERPRETER=venv/bin/python
  INSTALL_DIR=~/Git/xljones/xjtools
  APP_DIR=app
  TOOLS_DIR=tools
  # xjtools - Configuration end

  # If no arguments given, jump straight to the tools folder
  if [ -z "$1" ]; then
    cd $INSTALL_DIR

  # if arguments are given, check if it's a lib command
  else
    if [[ "$1" == "help" ]] then
      (cd $INSTALL_DIR && $PYTHON_INTERPRETER -m $APP_DIR -h)
    elif [[ "$1" == "new"       ||
            "$1" == "list"      ||
            "$1" == "edit"      ||
            "$1" == "delete"    ||
            "$1" == "rename"    ||
            "$1" == "duplicate" ]] then
      if test -d "$INSTALL_DIR/$APP_DIR"; then
        (cd $INSTALL_DIR && $PYTHON_INTERPRETER -m $APP_DIR ${@:1})
      else
        echo "[xjtools] Error: module not found at $INSTALL_DIR/$APP_DIR"
      fi
    else
      FILE=$TOOLS_DIR/$1.py
      if test -f "$FILE"; then
        (cd $INSTALL_DIR && $PYTHON_INTERPRETER $FILE ${@:2})
      else
        echo "[xjtools] Error: tool '$1' not found, try \`tools list\` to find the tool."
      fi
    fi
  fi
}

Usage

The following command can be run from anywhere on your computer if you have installed the alias in the installation instructions.

List the tools

$ tools list

produces the following output

$ tools list
[xjtools] Listing tools found in /Users/xanderjones/GitHub/my-tools/tools
+---+-------------+---------+-----------------------------------------------------+
| # | Tool        | Version | Description                                         |
+---+-------------+---------+-----------------------------------------------------+
| 1 | upper       | 1.0.0   | Convert any following arguments to upper case       |
| 2 | minlink     | 1.0.1   | Convert a Bugsnag long link into useful information |
+---+-------------+---------+-----------------------------------------------------+

Call a tool for use

$ tools TOOL_NAME [arguments] arguments

Create a new tool

$ tools new TOOL_NAME

Edit a tool

By default this opens in VSCode. You can modify the value _EDIT_TOOL in ./lib/xjconst.py if you'd like to use another editor.

tools edit TOOL_NAME

Rename a tool

Renaming a tool will also update the internals to reflect the changes, and up the change date to today

tools rename TOOL_NAME NEW_NAME

Duplicate a tool

Duplicating a tool is similar to renaming, but won't remove the old script you've copied from.

tools duplicate TOOL_NAME DUPLICATE_NAME

Delete a tool

This moves the tool into a sub hidden folder called .deleted, and appends an index value to the file if there are more than 1 of the same name.

tools delete TOOL_NAME

xjtools's People

Contributors

xljones avatar

Stargazers

 avatar

Watchers

 avatar

xjtools's Issues

Add rename option

Include an option to rename scripts, including a full parse through the script itself to update names

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.