Giter Site home page Giter Site logo

scripts's Introduction

scripts

Bash scripts that I use on multiple environments. You may find some of them useful!

Installation

Clone the repository:

git clone [email protected]:shane-smith/scripts.git scripts

Then add the scripts directory to your path, by adding something like the following to your .bashrc or .bash_profile:

PATH=$PATH:$HOME/scripts/bin

The above line assumes that you checked out this repository into your home directory.

Contributions

Feel free to fork and add your own scripts, then submit a pull request!

See CONTRIBUTING.md for further details.

Available Scripts

Git

commit

This script was designed to match the preferred commit comment format for my workplace. We use a project management tool with the initials "LP", which has 8-digit task IDs. The preferred commit comment format is as follows:

lp #22446688 - Comment goes here

Our feature branches are labelled with 'lp' and the task ID: e.g. lp22446688

With that in mind, the bash script is designed to enforce this structure, and also make it extremely easy to commit from the terminal. All I need to run is commit Adding stuff and it'll automatically commit in the format that I want.

In addition, it should be noted that we use the Gitflow model. Therefore, in most cases I do not want to commit directly to the 'master' or 'develop' branches - instead, I want to commit to a feature or hotfix branch, and then merge those branches into the two core branches. Due to this, the script has in-built protection to prevent accidental committing to those branches.

undocommit

If you have not pushed to the remote repository, and the most recent commit in your Git history was a simple one (i.e. not a merge), you will likely find this shortcut helpful.

Essentially, it just reverts back to your second-to-last commit, removing the most recent one from the log and returning your files back to you with the edits in place.

I often use this command in lieu of a git commit --amend.

logs

I love running git log -n 10 --oneline so much, that I wrote an alias for it: logs. This alias has been converted into a dedicated script, so that I could add it to this repository as a separate file.

Feel free to make improvements to this if you wish! It would be a good beginner task, for anyone hoping to make a small contribution.

Database

Some of the database scripts are designed to work with a mysql alias (e.g. alias mysql='mysql -uroot -p'), so you will not see any references to the username or password prompts in these helpers, and will instead see a reference to the mysql alias instead.

Room for improvement:

  • Most of these scripts do not do any error checking (i.e. does the database exist?). They could be expanded to do this in the future.
  • The dbexport and dbimport scripts could be updated to optionally save to a gzipped file rather than as uncompressed SQL.

dbcreate

Parameters:

  1. Database name

Creates a database with the specified name.

dbexport

Parameters:

  1. Database name
  2. Filename

Uses mysqldump to generate a SQL file with the structure and data of the given database. Saves it to a file with the provided filename.

dbimport

Parameters:

  1. Database name
  2. Filename

Restores the output of the dbexport script into a database with the specified name. This can be used in conjunction with dbexport to dump a copy of one database, and create another with the same content, effectively duplicating it.

Other

findreport

This is a simple wrapper around the find command, which searches in a specific directory.

We use Jasper reports at work, which are written as .jrxml files and compile down to .jasper files. Generally, I use this command to search for a .jrxml file with a specific filename, because it's usually nested within one of many sub-directories. I'd rather not have to guess and jump from one directory to another to find the one I want.

And quite often... we have multiple with the same file name - the base report, and then a customised version that specific customers are using. This script will pull up all instances, and it makes it easy to find the one I'm looking for.

Configuration Files

.screenrc

I've added the super-simple .screenrc file that I use on almost all environments that I connect to.

It's only a few lines - but it adds visible labels for each of the windows that you have open, making it super-easy to navigate between them and see which one you have active at a glance.

scripts's People

Contributors

shane-smith avatar

Stargazers

 avatar  avatar

Watchers

 avatar

scripts's Issues

undocommit could be extended to support more scenarios

Currently, it's quite basic.

It could be easily extended to:

  • Firstly, detect scenarios that it doesn't want to undo (e.g. everything pushed)
  • Alternatively, handle some of those scenarios ... e.g. for stuff that has been pushed, generate a new commit that reverts the previous change.

Add support for gzipped database export

Changes:

  • The dbexport script could be modified to export to a gzipped file, as an optional feature.
  • The dbimport script should support importing from this file format.

Add error checking to database helpers

We could:

  • Confirm that the database exists before exporting / importing from it.
  • Confirm that the file doesn't already exist, before writing SQL to it in dbexport.

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.