Replace 'command grep' with '\grep' to break out of aliases
This commit is contained in:
@@ -69,7 +69,7 @@ function git_index() {
|
|||||||
done | sort | column -t -s ':'
|
done | sort | column -t -s ':'
|
||||||
elif [ "$1" = "--count-by-host" ]; then
|
elif [ "$1" = "--count-by-host" ]; then
|
||||||
echo -e "=== Producing a report of the number of repos per host...\n"
|
echo -e "=== Producing a report of the number of repos per host...\n"
|
||||||
_git_index_batch_cmd git remote -v | command grep "origin.*(fetch)" |
|
_git_index_batch_cmd git remote -v | \grep "origin.*(fetch)" |
|
||||||
sed -e "s/origin\s*//" -e "s/(fetch)//" |
|
sed -e "s/origin\s*//" -e "s/(fetch)//" |
|
||||||
sed -e "s/\(\([^/]*\/\/\)\?\([^@]*@\)\?\([^:/]*\)\).*/\1/" |
|
sed -e "s/\(\([^/]*\/\/\)\?\([^@]*@\)\?\([^:/]*\)\).*/\1/" |
|
||||||
sort | uniq -c
|
sort | uniq -c
|
||||||
@@ -85,7 +85,7 @@ function git_index() {
|
|||||||
# Figure out which directory we need to change to.
|
# Figure out which directory we need to change to.
|
||||||
local project=$(echo $1 | cut -d "/" -f1)
|
local project=$(echo $1 | cut -d "/" -f1)
|
||||||
# Find base path of project
|
# Find base path of project
|
||||||
local base_path="$(command grep -m1 "/$project$" "$GIT_REPO_DIR/.git_index")"
|
local base_path="$(\grep -m1 "/$project$" "$GIT_REPO_DIR/.git_index")"
|
||||||
if [ -n "$base_path" ]; then
|
if [ -n "$base_path" ]; then
|
||||||
sub_path=$(echo $1 | sed "s:^$project::")
|
sub_path=$(echo $1 | sed "s:^$project::")
|
||||||
# Append subdirectories to base path
|
# Append subdirectories to base path
|
||||||
@@ -93,9 +93,9 @@ function git_index() {
|
|||||||
fi
|
fi
|
||||||
# Try partial matches
|
# Try partial matches
|
||||||
# - string at beginning of project
|
# - string at beginning of project
|
||||||
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | command grep -m1 "/$project"); fi
|
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | \grep -m1 "/$project"); fi
|
||||||
# - string anywhere in project
|
# - string anywhere in project
|
||||||
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | command grep -m1 "$project"); fi
|
if [ -z "$base_path" ]; then base_path=$(_git_index_dirs_without_home | \grep -m1 "$project"); fi
|
||||||
# --------------------
|
# --------------------
|
||||||
# Go to our base path
|
# Go to our base path
|
||||||
if [ -n "$base_path" ]; then
|
if [ -n "$base_path" ]; then
|
||||||
@@ -133,7 +133,7 @@ function _find_git_repos() {
|
|||||||
# List all submodules for a git repo, if any.
|
# List all submodules for a git repo, if any.
|
||||||
function _find_git_submodules() {
|
function _find_git_submodules() {
|
||||||
if [ -e "$1/../.gitmodules" ]; then
|
if [ -e "$1/../.gitmodules" ]; then
|
||||||
command grep "\[submodule" "$1/../.gitmodules" | sed "s%\[submodule \"%${1%/.git}/%g" | sed "s/\"]//g"
|
\grep "\[submodule" "$1/../.gitmodules" | sed "s%\[submodule \"%${1%/.git}/%g" | sed "s/\"]//g"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ function _check_git_index() {
|
|||||||
|
|
||||||
# Produces a count of repos in the tab completion index (excluding commands)
|
# Produces a count of repos in the tab completion index (excluding commands)
|
||||||
function _git_index_count() {
|
function _git_index_count() {
|
||||||
echo $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | command grep . | wc -l)
|
echo $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | \grep . | wc -l)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns the current git branch (returns nothing if not a git repository)
|
# Returns the current git branch (returns nothing if not a git repository)
|
||||||
@@ -174,7 +174,7 @@ parse_git_branch() {
|
|||||||
function _git_index_status_if_dirty() {
|
function _git_index_status_if_dirty() {
|
||||||
if ! [ `git status --porcelain | wc -l` -eq 0 ]; then
|
if ! [ `git status --porcelain | wc -l` -eq 0 ]; then
|
||||||
# Fall back to 'git status' if git status alias isn't configured
|
# Fall back to 'git status' if git status alias isn't configured
|
||||||
if type $git_status_command 2>&1 | command grep -qv "not found"; then
|
if type $git_status_command 2>&1 | \grep -qv "not found"; then
|
||||||
eval $git_status_command
|
eval $git_status_command
|
||||||
else
|
else
|
||||||
git status
|
git status
|
||||||
@@ -263,7 +263,7 @@ function _git_index_batch_cmd() {
|
|||||||
echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n"
|
echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n"
|
||||||
IFS=$' \t\n'
|
IFS=$' \t\n'
|
||||||
local base_path
|
local base_path
|
||||||
for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | command grep . | sort); do
|
for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | \grep . | sort); do
|
||||||
builtin cd "$base_path"
|
builtin cd "$base_path"
|
||||||
$@
|
$@
|
||||||
done
|
done
|
||||||
@@ -285,12 +285,12 @@ function _git_index_tab_completion() {
|
|||||||
# If the first part of $curw matches a high-level directory,
|
# If the first part of $curw matches a high-level directory,
|
||||||
# then match on sub-directories for that project
|
# then match on sub-directories for that project
|
||||||
local project=$(echo "$curw" | cut -d "/" -f1)
|
local project=$(echo "$curw" | cut -d "/" -f1)
|
||||||
local base_path=$(command grep "/$project$" "$GIT_REPO_DIR/.git_index" | sed 's/ /\\ /g')
|
local base_path=$(\grep "/$project$" "$GIT_REPO_DIR/.git_index" | sed 's/ /\\ /g')
|
||||||
|
|
||||||
# If matching project path was found and curr string contains a /, then complete project sub-directories
|
# If matching project path was found and curr string contains a /, then complete project sub-directories
|
||||||
if [[ -n "$base_path" && $curw == */* ]]; then
|
if [[ -n "$base_path" && $curw == */* ]]; then
|
||||||
local search_path=$(echo "$curw" | sed "s:^${project/\\/\\\\\\}::")
|
local search_path=$(echo "$curw" | sed "s:^${project/\\/\\\\\\}::")
|
||||||
COMPREPLY=($(compgen -d "$base_path$search_path" | command grep -v "/.git" | sed -e "s:$base_path:$project:" -e "s:$:/:" ))
|
COMPREPLY=($(compgen -d "$base_path$search_path" | \grep -v "/.git" | sed -e "s:$base_path:$project:" -e "s:$:/:" ))
|
||||||
|
|
||||||
# If curr string starts with /, tab complete top-level directories in root project dir
|
# If curr string starts with /, tab complete top-level directories in root project dir
|
||||||
elif ([ $shell = "bash" ] && [ "${curw:0:1}" = "/" ]) || \
|
elif ([ $shell = "bash" ] && [ "${curw:0:1}" = "/" ]) || \
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ git_status_shortcuts() {
|
|||||||
git status; return 1
|
git status; return 1
|
||||||
fi
|
fi
|
||||||
# Fetch list of files from last line of script output
|
# Fetch list of files from last line of script output
|
||||||
files="$(echo "$cmd_output" | command grep '@@filelist@@::' | sed 's%@@filelist@@::%%g')"
|
files="$(echo "$cmd_output" | \grep '@@filelist@@::' | sed 's%@@filelist@@::%%g')"
|
||||||
if [ "$scmbDebug" = "true" ]; then echo "filelist => $files"; fi
|
if [ "$scmbDebug" = "true" ]; then echo "filelist => $files"; fi
|
||||||
# Export numbered env variables for each file
|
# Export numbered env variables for each file
|
||||||
IFS="|"
|
IFS="|"
|
||||||
@@ -44,7 +44,7 @@ git_status_shortcuts() {
|
|||||||
|
|
||||||
if [ "$scmbDebug" = "true" ]; then echo "------------------------"; fi
|
if [ "$scmbDebug" = "true" ]; then echo "------------------------"; fi
|
||||||
# Print status
|
# Print status
|
||||||
echo "$cmd_output" | command grep -v '@@filelist@@::'
|
echo "$cmd_output" | \grep -v '@@filelist@@::'
|
||||||
zsh_reset # Reset zsh environment to default
|
zsh_reset # Reset zsh environment to default
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ git_show_affected_files(){
|
|||||||
f=0 # File count
|
f=0 # File count
|
||||||
# Show colored revision and commit message
|
# Show colored revision and commit message
|
||||||
echo -n "# "; git show --oneline --name-only $@ | head -n1; echo "# "
|
echo -n "# "; git show --oneline --name-only $@ | head -n1; echo "# "
|
||||||
for file in $(git show --pretty="format:" --name-only $@ | command grep -v '^$'); do
|
for file in $(git show --pretty="format:" --name-only $@ | \grep -v '^$'); do
|
||||||
let f++
|
let f++
|
||||||
export $git_env_char$f=$file # Export numbered variable.
|
export $git_env_char$f=$file # Export numbered variable.
|
||||||
echo -e "# \e[2;37m[\e[0m$f\e[2;37m]\e[0m $file"
|
echo -e "# \e[2;37m[\e[0m$f\e[2;37m]\e[0m $file"
|
||||||
|
|||||||
Reference in New Issue
Block a user