Skip to content

command line completion for gitup command #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions GitUp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
51DB5BBB1B8456E900153587 /* gitup-completion.sh in Copy Tool */ = {isa = PBXBuildFile; fileRef = 51DB5BBA1B84568F00153587 /* gitup-completion.sh */; };
E200A3B91B02DDA100C4E39D /* GCPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = E200A3B81B02DDA100C4E39D /* GCPrivate.m */; };
E200A3BA1B02DDA100C4E39D /* GCPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = E200A3B81B02DDA100C4E39D /* GCPrivate.m */; };
E20EB08B19FC75CA0031A075 /* GCRepository+Reset.m in Sources */ = {isa = PBXBuildFile; fileRef = E20EB08A19FC75CA0031A075 /* GCRepository+Reset.m */; };
Expand Down Expand Up @@ -224,6 +225,7 @@
dstPath = "";
dstSubfolderSpec = 12;
files = (
51DB5BBB1B8456E900153587 /* gitup-completion.sh in Copy Tool */,
E21DCAF31B253919006424E8 /* gitup in Copy Tool */,
E21DCAF51B254117006424E8 /* install.sh in Copy Tool */,
);
Expand All @@ -244,6 +246,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
51DB5BBA1B84568F00153587 /* gitup-completion.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "gitup-completion.sh"; sourceTree = "<group>"; };
E200A3B81B02DDA100C4E39D /* GCPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCPrivate.m; sourceTree = "<group>"; };
E20EB08919FC75CA0031A075 /* GCRepository+Reset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GCRepository+Reset.h"; sourceTree = "<group>"; };
E20EB08A19FC75CA0031A075 /* GCRepository+Reset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GCRepository+Reset.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -580,6 +583,7 @@
E21DCAE91B253847006424E8 /* Tool */ = {
isa = PBXGroup;
children = (
51DB5BBA1B84568F00153587 /* gitup-completion.sh */,
E21DCAF41B254112006424E8 /* install.sh */,
E21DCAEA1B253847006424E8 /* main.m */,
);
Expand Down
10 changes: 10 additions & 0 deletions Tool/gitup-completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh -e
function _gitup() {
local cur opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts="help open map commit stash"
COMPREPLY=($(compgen -W "$opts" -- $cur))
return 0
}
complete -F _gitup gitup
8 changes: 8 additions & 0 deletions Tool/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ INSTALL_DIR=`dirname "$INSTALL_PATH"`
mkdir -p "$INSTALL_DIR"
ln -sf "$TOOL_PATH" "$INSTALL_PATH"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need some detailed comments explaining what exactly this does as this is some pretty advanced bash scripting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done... hopefully 😃

# Check if gitup-completion is present in /etc/bashrc ( grep -q ...),
# otherwise (grep || ...) add our completion loading script to /etc/bashrc
# more info on here documents: http://tldp.org/LDP/abs/html/here-docs.html
grep -q gitup-completion /etc/bashrc || cat << EOF >> /etc/bashrc
# load gitup-completion.sh if it exists; enables command line completion
gitup="${TOOL_PATH}-completion.sh"; [ -f "\${gitup}" ] && source "\${gitup}"
EOF

printf "OK"