Skip to content

Commit

Permalink
Merge pull request #12 from mperry2/master
Browse files Browse the repository at this point in the history
improved sh code convention and standardize use of companion commands
  • Loading branch information
paoloantinori committed Jan 17, 2016
2 parents 03b73a7 + 51fee22 commit af2b9e7
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions h.sh
Expand Up @@ -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() {
Expand All @@ -32,7 +39,7 @@ h() {
local _OPTS

# detect pipe or tty
if test -t 0; then
if [[ -t 0 ]]; then
_usage
return
fi
Expand Down Expand Up @@ -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.

Copy link
@vdun

vdun Feb 1, 2016

Not compatible with zsh.

This comment has been minimized.

Copy link
@paoloantinori

paoloantinori Feb 10, 2016

Author Owner

I should have fixed it in the latest version. Could you try it?

This comment has been minimized.

Copy link
@vdun

vdun Feb 11, 2016

Works. Thanks


# build the filtering command
for keyword in "$@"
Expand Down

0 comments on commit af2b9e7

Please sign in to comment.