An open API service indexing awesome lists of open source software.

https://github.com/onlyuser/sh

sh is a collection of handy shell scripts
https://github.com/onlyuser/sh

bash-script

Last synced: 4 months ago
JSON representation

sh is a collection of handy shell scripts

Awesome Lists containing this project

README

          

sh
==

Copyright (C) 2011-2017

About:
------

sh is a collection of handy shell scripts.

**Currently, it includes the following:**

* xgrep -- a grep wrapper that screens filenames before grepping
* xrefact -- a script for refactoring code
* xform -- a script for applying my coding conventions
* diff.py -- a meld wrapper for better git diff experience

xgrep:
------


Synopsis:

xgrep <FILENAME> [SEARCH_STR]

Description:

Searches for SEARCH_STR in files matched by FILENAME.

If SEARCH_STR not given, simply lists files matched by FILENAME.

**Parameters:**

* FILENAME -- regex describing which files to apply action
* SEARCH_STR -- grepped regex to apply to files matched

xrefact:
--------


Synopsis:

xrefact <FILENAME> <SEARCH_STR> <REPLACE_STR> [IGNORE_COLLISION={1/0}]

Description:

Replaces SEARCH_STR with REPLACE_STR for files matched by FILENAME.

If IGNORE_COLLISION is 0, skips replaces that produce new occurrences of SEARCH_STR.

Replaces files named SEARCH_STR to REPLACE_STR as well.

IGNORE_COLLISION also applies to file renaming, with analogous functionality.

**Parameters:**

* FILENAME -- regex describing which files to apply action
* SEARCH_STR -- grepped regex to apply to files matched
* REPLACE_STR -- string to replace SEARCH_STR
* IGNORE_COLLISION -- 1 for force replace, 0 for skipping collision case

xform:
------


Synopsis:

xform <FILENAME>

Description:

Applies formatting rules to files matched by FILENAME.

**Parameters:**

* FILENAME -- regex describing which files to apply action

**Format rules:**

* unify indent
* trim trailing space
* unify empty brace spacing
* unify control-statement spacing
* unify spacing after "#include" and "namespace"
* STL headers (remove file extension + replace quotes with angle braces)
* C++ headers (remove file extension + replace quotes with angle braces)
* C headers (replace quotes with angle braces)

Requirements:
-------------

Add these lines to your .bashrc to gain PATH access (to my scripts):

export PATH=sh:$PATH
export PATH=sh/xargs:$PATH

Add these lines to your .bashrc to use diff.py:

#git config --global diff.external meld
git config --global diff.external sh/diff.py

Keywords:
---------

shell scripting, bash, git, meld