Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from mperry2/master
improved sh code convention and standardize use of companion commands
- Loading branch information
Showing
1 changed file
with
13 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,13 @@ | |
# GITHUB | ||
# * https://github.com/paoloantinori/hhighlighter | ||
|
||
# Check for the ack command | ||
if [[ -z $(type -p ack-grep || type -p ack) ]]; then | ||
echo "ERROR: Could not find the ack or ack-grep commands" | ||
return 1 | ||
fi | ||
|
||
|
||
h() { | ||
|
||
_usage() { | ||
|
@@ -32,7 +39,7 @@ h() { | |
local _OPTS | ||
|
||
# detect pipe or tty | ||
if test -t 0; then | ||
if [[ -t 0 ]]; then | ||
_usage | ||
return | ||
fi | ||
|
@@ -98,29 +105,21 @@ h() { | |
) | ||
fi | ||
|
||
if [ -z $n_flag ]; then | ||
if [[ -z $n_flag ]]; then | ||
#inverted-colors-last scheme | ||
_COLORS=("${_COLORS_FG[@]}" "${_COLORS_BG[@]}") | ||
else | ||
#inverted-colors-first scheme | ||
_COLORS=("${_COLORS_BG[@]}" "${_COLORS_FG[@]}") | ||
fi | ||
|
||
if [ "$#" -gt ${#_COLORS[@]} ]; then | ||
echo "You have passed to hhighlighter more keyords to search than the number of configured colors. | ||
if [[ "$#" -gt ${#_COLORS[@]} ]]; then | ||
echo "You have passed to hhighlighter more keywords to search than the number of configured colors. | ||
Check the content of your H_COLORS_FG and H_COLORS_BG environment variables or unset them to use default 12 defined colors." | ||
return -1 | ||
return 1 | ||
fi | ||
|
||
|
||
local ACK=ack | ||
if ! which $ACK >/dev/null 2>&1; then | ||
ACK=ack-grep | ||
if ! which $ACK >/dev/null 2>&1; then | ||
echo "Could not find ack or ack-grep" | ||
return -1 | ||
fi | ||
fi | ||
local ACK=$(type -p ack-grep || type -p ack) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
paoloantinori
Author
Owner
|
||
|
||
# build the filtering command | ||
for keyword in "$@" | ||
|
Not compatible with
zsh
.