Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
git-tips
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Chris Bills
git-tips
Commits
ef20e17a
Commit
ef20e17a
authored
Sep 03, 2015
by
Chris Bills
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial bash-functions example
parent
c3eda733
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
bash-functions
bash-functions
+29
-0
No files found.
bash-functions
0 → 100644
View file @
ef20e17a
gits() {
local status count
count=5
if [[ "$1" =~ ^[0-9]+$ ]]; then
count="$1"
fi
if ! type -P git &>/dev/null; then
echo "git is not installed"
return 1
fi
status=$(git status 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo "not in a git repository"
return 2
fi
# Since the following is simply a nice-to-have, it doesn't matter if an
# unrelated running 'git fetch' prevents the fetch I want.
# I use 'gits' a lot, so eventually it will run (for me).
if ! pgrep -f 'git fetch' &>/dev/null; then
# Fetch latest refs and send to background if not already fetching
(git fetch --all --prune &) &>/dev/null
fi
if [[ -n "$status" ]]; then
# Call git status again, because we want it colored properly.
git status -s 2>/dev/null
echo
fi
git log --oneline -${count} --no-color | sed -re 's/\s+/ /'
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment