How do I avoid typing “git” at the begining of every Git command?How do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to resolve merge conflicts in GitHow do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?
King or Queen-Which piece is which?
What preparations would Hubble have needed to return in a Shuttle?
Mapping with iterating uint as identifier - multiple transactions in the same block
"What is the maximum that Player 1 can win?"
Are there examples of rowers who also fought?
My student in one course asks for paid tutoring in another course. Appropriate?
What is this airplane that sits in front of Barringer High School in Newark, NJ?
Densest sphere packing
Is there a polite way to ask about one's ethnicity?
Need help understanding the double sharp turn in Chopin's prelude in e minor
No shading in ContourPlot3D
How can I ping multiple IP addresses at the same time?
Why isn't my calculation that we should be able to see the sun well beyond the observable universe valid?
Are intrusions within a foreign embassy considered an act of war?
Scaling an object to change its key
Predict the product from the reaction
How do I find which software is doing an SSH connection?
Is there any possible way to get these hearts as Adult Link?
How "fast" do astronomical events occur?
Is declining an undergraduate award which causes me discomfort appropriate?
Boundaries and Buddhism
What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?
Umlaut character order when sorting
Unable to import binding 'SforceServiceBinding' with the Summer 19 Tooling API WSDL
How do I avoid typing “git” at the begining of every Git command?
How do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to resolve merge conflicts in GitHow do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm wondering if there's a way to avoid having to type the word git
at the beginning of every Git command.
It would be nice if there was a way to use the git
command only once in the beginning after opening a command prompt to get into "Git mode".
For example:
git>
After which every command we type is by default interpreted as a Git command.
In a way similar to how we use the MySQL shell to write database commands:
mysql>
This will save me from typing 'git' hundreds of time every day.
NOTE: I'm using git-bash
, on Windows.
git version-control command-line-interface git-bash
|
show 4 more comments
I'm wondering if there's a way to avoid having to type the word git
at the beginning of every Git command.
It would be nice if there was a way to use the git
command only once in the beginning after opening a command prompt to get into "Git mode".
For example:
git>
After which every command we type is by default interpreted as a Git command.
In a way similar to how we use the MySQL shell to write database commands:
mysql>
This will save me from typing 'git' hundreds of time every day.
NOTE: I'm using git-bash
, on Windows.
git version-control command-line-interface git-bash
73
To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.
– JBentley
Jun 10 at 15:24
3
Why are you typing "git" so much? Your IDE should have powerful vcs integrations available at a keypress. Do you rather type "git pull" 50 times a day, or ctrl-t... stop being a command line warrior when you dont need to be ;)
– vikingsteve
Jun 11 at 8:55
5
@vikingsteve Practically all git help and wisdom is given in terms of command-line.
– Ed Randall
Jun 11 at 17:08
6
@vikingsteve I'm typing it so much because it's faster. I type ~100wpm, more if I'm intimately familiar with the keypresses like I am with Git; compared to clicking on GUIs, it's just easier. Your favorite IDE may have keyboard shortcuts. That's nice for you. Why would I waste time learning them when <M-Tab>git blah<CR> is already in my muscle memory?
– Nic Hartley
Jun 11 at 17:08
2
There should be a "this question should be closed because the user is asking a question that doesn't make sense" - like I get what you're asking but how is the shell going to know you want to enter a "non starting with git command" if there was indeed a way to do this.
– user3728501
Jun 11 at 22:21
|
show 4 more comments
I'm wondering if there's a way to avoid having to type the word git
at the beginning of every Git command.
It would be nice if there was a way to use the git
command only once in the beginning after opening a command prompt to get into "Git mode".
For example:
git>
After which every command we type is by default interpreted as a Git command.
In a way similar to how we use the MySQL shell to write database commands:
mysql>
This will save me from typing 'git' hundreds of time every day.
NOTE: I'm using git-bash
, on Windows.
git version-control command-line-interface git-bash
I'm wondering if there's a way to avoid having to type the word git
at the beginning of every Git command.
It would be nice if there was a way to use the git
command only once in the beginning after opening a command prompt to get into "Git mode".
For example:
git>
After which every command we type is by default interpreted as a Git command.
In a way similar to how we use the MySQL shell to write database commands:
mysql>
This will save me from typing 'git' hundreds of time every day.
NOTE: I'm using git-bash
, on Windows.
git version-control command-line-interface git-bash
git version-control command-line-interface git-bash
edited Jun 11 at 0:45
LogicalBranch
2,1891840
2,1891840
asked Jun 8 at 9:11
NocturnalNocturnal
7422312
7422312
73
To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.
– JBentley
Jun 10 at 15:24
3
Why are you typing "git" so much? Your IDE should have powerful vcs integrations available at a keypress. Do you rather type "git pull" 50 times a day, or ctrl-t... stop being a command line warrior when you dont need to be ;)
– vikingsteve
Jun 11 at 8:55
5
@vikingsteve Practically all git help and wisdom is given in terms of command-line.
– Ed Randall
Jun 11 at 17:08
6
@vikingsteve I'm typing it so much because it's faster. I type ~100wpm, more if I'm intimately familiar with the keypresses like I am with Git; compared to clicking on GUIs, it's just easier. Your favorite IDE may have keyboard shortcuts. That's nice for you. Why would I waste time learning them when <M-Tab>git blah<CR> is already in my muscle memory?
– Nic Hartley
Jun 11 at 17:08
2
There should be a "this question should be closed because the user is asking a question that doesn't make sense" - like I get what you're asking but how is the shell going to know you want to enter a "non starting with git command" if there was indeed a way to do this.
– user3728501
Jun 11 at 22:21
|
show 4 more comments
73
To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.
– JBentley
Jun 10 at 15:24
3
Why are you typing "git" so much? Your IDE should have powerful vcs integrations available at a keypress. Do you rather type "git pull" 50 times a day, or ctrl-t... stop being a command line warrior when you dont need to be ;)
– vikingsteve
Jun 11 at 8:55
5
@vikingsteve Practically all git help and wisdom is given in terms of command-line.
– Ed Randall
Jun 11 at 17:08
6
@vikingsteve I'm typing it so much because it's faster. I type ~100wpm, more if I'm intimately familiar with the keypresses like I am with Git; compared to clicking on GUIs, it's just easier. Your favorite IDE may have keyboard shortcuts. That's nice for you. Why would I waste time learning them when <M-Tab>git blah<CR> is already in my muscle memory?
– Nic Hartley
Jun 11 at 17:08
2
There should be a "this question should be closed because the user is asking a question that doesn't make sense" - like I get what you're asking but how is the shell going to know you want to enter a "non starting with git command" if there was indeed a way to do this.
– user3728501
Jun 11 at 22:21
73
73
To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.
– JBentley
Jun 10 at 15:24
To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.
– JBentley
Jun 10 at 15:24
3
3
Why are you typing "git" so much? Your IDE should have powerful vcs integrations available at a keypress. Do you rather type "git pull" 50 times a day, or ctrl-t... stop being a command line warrior when you dont need to be ;)
– vikingsteve
Jun 11 at 8:55
Why are you typing "git" so much? Your IDE should have powerful vcs integrations available at a keypress. Do you rather type "git pull" 50 times a day, or ctrl-t... stop being a command line warrior when you dont need to be ;)
– vikingsteve
Jun 11 at 8:55
5
5
@vikingsteve Practically all git help and wisdom is given in terms of command-line.
– Ed Randall
Jun 11 at 17:08
@vikingsteve Practically all git help and wisdom is given in terms of command-line.
– Ed Randall
Jun 11 at 17:08
6
6
@vikingsteve I'm typing it so much because it's faster. I type ~100wpm, more if I'm intimately familiar with the keypresses like I am with Git; compared to clicking on GUIs, it's just easier. Your favorite IDE may have keyboard shortcuts. That's nice for you. Why would I waste time learning them when <M-Tab>git blah<CR> is already in my muscle memory?
– Nic Hartley
Jun 11 at 17:08
@vikingsteve I'm typing it so much because it's faster. I type ~100wpm, more if I'm intimately familiar with the keypresses like I am with Git; compared to clicking on GUIs, it's just easier. Your favorite IDE may have keyboard shortcuts. That's nice for you. Why would I waste time learning them when <M-Tab>git blah<CR> is already in my muscle memory?
– Nic Hartley
Jun 11 at 17:08
2
2
There should be a "this question should be closed because the user is asking a question that doesn't make sense" - like I get what you're asking but how is the shell going to know you want to enter a "non starting with git command" if there was indeed a way to do this.
– user3728501
Jun 11 at 22:21
There should be a "this question should be closed because the user is asking a question that doesn't make sense" - like I get what you're asking but how is the shell going to know you want to enter a "non starting with git command" if there was indeed a way to do this.
– user3728501
Jun 11 at 22:21
|
show 4 more comments
11 Answers
11
active
oldest
votes
You might want to try gitsh. From their readme:
The
gitsh
program is an interactive shell for git. From withingitsh
you can issue any git command, even using your local aliases and configuration.
- Git commands tend to come in groups. Avoid typing
git
over and over and over by running them in a dedicated git shell:
sh$ gitsh
gitsh% status
gitsh% add .
gitsh% commit -m "Ship it!"
gitsh% push
gitsh% ctrl-d
sh$
Or have a look at the other projects linked there:
git-sh - A customised bash shell with a Git prompt, aliases, and completion.
gitsh - A simple Git shell written in Perl.
repl - Wraps any program with subcommands in a REPL.
Note: Haven't used this myself.
19
grumble...repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.
– Kevin
Jun 9 at 2:38
10
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
1
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over thefork()
/exec()
), sorepl(1)
isn't even doing that.
– Kevin
Jun 10 at 19:29
5
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also acceptIO
actions, and execute them including side-effects such as printing to the terminal-connected screen.
– leftaroundabout
Jun 11 at 8:25
1
@Kevinrepl
isn't a standalone REPL; it's a means of creating a REPL system in whichrepl
is only the interactive component. Is that fair?
– Kyle Strand
Jun 11 at 17:12
|
show 4 more comments
A Perl one-liner which will do this:
perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'
This will execute whatever you type, prefixed with git
. And it will keep doing that until you hit ^D
.
5
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
2
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
1
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s-ne
flags).
– Konrad Rudolph
Jun 10 at 13:23
10
@KonradRudolphperl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
add a comment |
This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc
for the Git commands you use most frequently:
alias commit='git commit'
alias checkout='git checkout'
...
Also note that you can create aliases within Git itself:
git config --global alias.ci commit
git config --global alias.co checkout
...
This lets you type git ci
instead of git commit
, and so on.
5
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
21
Only for the most frequently used. I mean, how often do you usegit hash-object
orgit interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.
– Thomas
Jun 8 at 9:42
14
In addition toci
forcommit
I also use a shell aliasg
forgit
, this reduces most of the typing and lets me stay in my preferred shell.
– rkta
Jun 8 at 18:26
add a comment |
I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:
# git
alias gw='git whatchanged'
alias gg='git grep -n -C8'
alias ggi='git grep -i -n -C8'
alias gb='git branch'
alias gbd='git branch -D'
alias gba='git branch -a'
alias gc='git checkout'
alias gcp='git cherry-pick'
alias gfo='git fetch origin'
alias s='git status'
alias gmom='git merge origin/master'
alias grom='git rebase origin/master'
alias gpom='git pull origin master'
alias pplog='git log --oneline --graph --decorate'
1
where's commit :P
– qwr
Jun 10 at 15:55
11
I don't includecommit
orpush
since I want a few extra seconds (while typing) to be sure that I'm not destroying something
– JacobIRR
Jun 10 at 17:19
2
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
add a comment |
A friend of mine made a small bash script that accomplishes this. It's called Replify.
$ replify git
Initialized REPL for [git]
git> init
Initialized empty Git repository in /your/directory/here/.git/
git> remote add origin https://your-url/repo.git
git> checkout -b new-branch
Switched to a new branch 'new-branch'
git> push
4
OK, I've already mentioned that on Umur's answer, but the use ofeval
in the original script source isn't the best idea. Tell your friend to usewhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead
– Sergiy Kolodyazhnyy
Jun 10 at 23:34
add a comment |
Use your editor.
Type the command like commit
from your favorite editor like vs code and be more efficient with git:
Or type git
to get all the commands:
11
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
3
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
3
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
|
show 3 more comments
Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc
:
complete -E -W git
Now pressing Tab at an empty Bash prompt will type out "git ".
4
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in~/zshrc
, for tcsh, you'll put it in~/tcshrc
, etc.
– TheOnlyMrCat
Jun 10 at 6:17
add a comment |
I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.
I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git
command, so instead I wrote a python script called NoGit to solve this problem:
#!/usr/bin/env python
import sys, os, signal, atexit, readline, subprocess
commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")
def run_commands():
stop = True
for cmd in commands:
command = ["git" if not cmd.startswith("git ") else ""]
command = [cmd] if command[0] == "" else [command[0], cmd]
subprocess.Popen(command).communicate()
commands = []
def signal_handler(sig, frame):
run_commands()
sys.exit(0)
try:
readline.read_history_file(history_file)
signal.signal(signal.SIGINT, signal_handler)
while True:
if stop == True:
break
command = input("git> ")
if command == "%undo":
commands.pop()
elif command == "%run":
run_commands()
elif command == "%exit":
sys.exit(0)
else:
commands += [cmd.strip() for cmd in command.split(";")]
signal.pause()
readline.set_history_length(-1)
except IOError:
pass
atexit.register(readline.write_history_file, history_file)
NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.
Documentation:
- the
%undo
command removes the last command from the stack - the
%run
command runs the commands in the stack and clears the stack - the
%exit
command closes the CLI without doing anything - pressing
ctr+c
is the same as running%run; %exit
- the script saves commands that were executed to a file called
git.history
in the same folder as the script - you can add multiple commands in one line using a semi-colon
- you can use the keyword
git
in the beginning of the command and the script won't duplicate it (E.G:git init
doesn't becomegit git init
)
Example commands:
init
add .
stage .
commit -m "inital commit"
%run; %exit
Additional information (for Linux users):
If you want you can remove the .py
extension and convert it into an executable using:
mv ./git.py ./git
chmod +x ./git
Then instead of calling the script like this:
python3 git.py
You'd run this instead:
./git
Additional information (for lazy people):
If you're lazy and don't want to type out a ./
then you could move this script to your /bin/
folder and create an alias for it.
If you're really, really lazy, use the following commands:
sudo cp ./git /bin/nogit
sudo chmod +x /bin/nogit
alias nogit='/bin/nogit'
If you're really, really, really lazy, copy and paste the following one-liner:
sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'
If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:
sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'
Good luck.
add a comment |
In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
while(true)
std::cout << "git> ";
std::cout.flush();
std::string command;
std::getline(std::cin, command);
if(command == "exit") break;
std::system("git " + command);
return 0;
Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
8
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
1
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
2
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
add a comment |
Another approach that will work with any commands: use Ctrl+R (reverse-i-search).
The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.
You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.
git commit --amend
:<Ctrl+R>am
git pull
:<Ctrl+R>pu
git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header
:<Ctrl+R>blu
git rebase --abort
:<Ctrl-R>ab
git rebase --continue
:<Ctrl-R>con
docker-compose stop && git pull && make && docker-compose up -d
:<Ctrl-R>up
- etc
Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.
add a comment |
For basic stuff, you can do:
function ggit() while true; do printf 'git> '; read; eval git $REPLY; done
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: yarn.lock
no changes added to commit (use "git add" and/or "git commit -a")
git> add .
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: yarn.lock
git>
Exit with ctrl+c
1
Decent idea, however there's two problems. One, the;
after do leads tobash: syntax error near unexpected token
;'` Second, theeval
part is prone to vulnerabilities. For example, consider what happens if I typestatus;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that intowhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better
– Sergiy Kolodyazhnyy
Jun 10 at 23:22
2
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you typegit status; cat /etc/passwd
at the shell prompt!
– Abigail
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not withoutsystem
or!
at the beginning at least. Where the assumption might be that this "repl" executesgit
commands only, it in fact allows more than that.
– Sergiy Kolodyazhnyy
2 days ago
2
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prependsmysql
to the commands. If you are afraid the promptgit >
looks too much like themysql >
prompt, you can always change it togit $
orthis is not mysql, don't type anything you would not type in the shell >
.
– Abigail
2 days ago
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -eval
isn't the best idea for running commands, especially when user-controlled input is involved.
– Sergiy Kolodyazhnyy
yesterday
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56505000%2fhow-do-i-avoid-typing-git-at-the-begining-of-every-git-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
You might want to try gitsh. From their readme:
The
gitsh
program is an interactive shell for git. From withingitsh
you can issue any git command, even using your local aliases and configuration.
- Git commands tend to come in groups. Avoid typing
git
over and over and over by running them in a dedicated git shell:
sh$ gitsh
gitsh% status
gitsh% add .
gitsh% commit -m "Ship it!"
gitsh% push
gitsh% ctrl-d
sh$
Or have a look at the other projects linked there:
git-sh - A customised bash shell with a Git prompt, aliases, and completion.
gitsh - A simple Git shell written in Perl.
repl - Wraps any program with subcommands in a REPL.
Note: Haven't used this myself.
19
grumble...repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.
– Kevin
Jun 9 at 2:38
10
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
1
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over thefork()
/exec()
), sorepl(1)
isn't even doing that.
– Kevin
Jun 10 at 19:29
5
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also acceptIO
actions, and execute them including side-effects such as printing to the terminal-connected screen.
– leftaroundabout
Jun 11 at 8:25
1
@Kevinrepl
isn't a standalone REPL; it's a means of creating a REPL system in whichrepl
is only the interactive component. Is that fair?
– Kyle Strand
Jun 11 at 17:12
|
show 4 more comments
You might want to try gitsh. From their readme:
The
gitsh
program is an interactive shell for git. From withingitsh
you can issue any git command, even using your local aliases and configuration.
- Git commands tend to come in groups. Avoid typing
git
over and over and over by running them in a dedicated git shell:
sh$ gitsh
gitsh% status
gitsh% add .
gitsh% commit -m "Ship it!"
gitsh% push
gitsh% ctrl-d
sh$
Or have a look at the other projects linked there:
git-sh - A customised bash shell with a Git prompt, aliases, and completion.
gitsh - A simple Git shell written in Perl.
repl - Wraps any program with subcommands in a REPL.
Note: Haven't used this myself.
19
grumble...repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.
– Kevin
Jun 9 at 2:38
10
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
1
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over thefork()
/exec()
), sorepl(1)
isn't even doing that.
– Kevin
Jun 10 at 19:29
5
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also acceptIO
actions, and execute them including side-effects such as printing to the terminal-connected screen.
– leftaroundabout
Jun 11 at 8:25
1
@Kevinrepl
isn't a standalone REPL; it's a means of creating a REPL system in whichrepl
is only the interactive component. Is that fair?
– Kyle Strand
Jun 11 at 17:12
|
show 4 more comments
You might want to try gitsh. From their readme:
The
gitsh
program is an interactive shell for git. From withingitsh
you can issue any git command, even using your local aliases and configuration.
- Git commands tend to come in groups. Avoid typing
git
over and over and over by running them in a dedicated git shell:
sh$ gitsh
gitsh% status
gitsh% add .
gitsh% commit -m "Ship it!"
gitsh% push
gitsh% ctrl-d
sh$
Or have a look at the other projects linked there:
git-sh - A customised bash shell with a Git prompt, aliases, and completion.
gitsh - A simple Git shell written in Perl.
repl - Wraps any program with subcommands in a REPL.
Note: Haven't used this myself.
You might want to try gitsh. From their readme:
The
gitsh
program is an interactive shell for git. From withingitsh
you can issue any git command, even using your local aliases and configuration.
- Git commands tend to come in groups. Avoid typing
git
over and over and over by running them in a dedicated git shell:
sh$ gitsh
gitsh% status
gitsh% add .
gitsh% commit -m "Ship it!"
gitsh% push
gitsh% ctrl-d
sh$
Or have a look at the other projects linked there:
git-sh - A customised bash shell with a Git prompt, aliases, and completion.
gitsh - A simple Git shell written in Perl.
repl - Wraps any program with subcommands in a REPL.
Note: Haven't used this myself.
edited Jun 8 at 10:36
answered Jun 8 at 10:29
alfunxalfunx
2,2281619
2,2281619
19
grumble...repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.
– Kevin
Jun 9 at 2:38
10
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
1
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over thefork()
/exec()
), sorepl(1)
isn't even doing that.
– Kevin
Jun 10 at 19:29
5
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also acceptIO
actions, and execute them including side-effects such as printing to the terminal-connected screen.
– leftaroundabout
Jun 11 at 8:25
1
@Kevinrepl
isn't a standalone REPL; it's a means of creating a REPL system in whichrepl
is only the interactive component. Is that fair?
– Kyle Strand
Jun 11 at 17:12
|
show 4 more comments
19
grumble...repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.
– Kevin
Jun 9 at 2:38
10
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
1
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over thefork()
/exec()
), sorepl(1)
isn't even doing that.
– Kevin
Jun 10 at 19:29
5
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also acceptIO
actions, and execute them including side-effects such as printing to the terminal-connected screen.
– leftaroundabout
Jun 11 at 8:25
1
@Kevinrepl
isn't a standalone REPL; it's a means of creating a REPL system in whichrepl
is only the interactive component. Is that fair?
– Kyle Strand
Jun 11 at 17:12
19
19
grumble...
repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.– Kevin
Jun 9 at 2:38
grumble...
repl(1)
is not a REPL. It doesn't eval or print anything. It runs programs.– Kevin
Jun 9 at 2:38
10
10
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
@Kevin It reads in user requests, evaluate the user request (by running a program), and prints the output of the program. This is also what shells do.
– Yakk - Adam Nevraumont
Jun 10 at 19:26
1
1
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the
fork()
/exec()
), so repl(1)
isn't even doing that.– Kevin
Jun 10 at 19:29
@Yakk-AdamNevraumont: No, it most certainly does not "print the output of the program." It hooks the program's stdout up to the terminal, and then the program prints its own output - except the program's stdout is already hooked up to the terminal (inherited automatically over the
fork()
/exec()
), so repl(1)
isn't even doing that.– Kevin
Jun 10 at 19:29
5
5
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also accept
IO
actions, and execute them including side-effects such as printing to the terminal-connected screen.– leftaroundabout
Jun 11 at 8:25
@Kevin I understand your sentiment, however the strict definition of a REPL would exclude most interpreter “REPL”s in various languages. Only in pure functional languages could you ensure that the evaluation has no side-effects, but even in Haskell the “REPL” GHCi will by default also accept
IO
actions, and execute them including side-effects such as printing to the terminal-connected screen.– leftaroundabout
Jun 11 at 8:25
1
1
@Kevin
repl
isn't a standalone REPL; it's a means of creating a REPL system in which repl
is only the interactive component. Is that fair?– Kyle Strand
Jun 11 at 17:12
@Kevin
repl
isn't a standalone REPL; it's a means of creating a REPL system in which repl
is only the interactive component. Is that fair?– Kyle Strand
Jun 11 at 17:12
|
show 4 more comments
A Perl one-liner which will do this:
perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'
This will execute whatever you type, prefixed with git
. And it will keep doing that until you hit ^D
.
5
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
2
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
1
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s-ne
flags).
– Konrad Rudolph
Jun 10 at 13:23
10
@KonradRudolphperl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
add a comment |
A Perl one-liner which will do this:
perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'
This will execute whatever you type, prefixed with git
. And it will keep doing that until you hit ^D
.
5
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
2
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
1
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s-ne
flags).
– Konrad Rudolph
Jun 10 at 13:23
10
@KonradRudolphperl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
add a comment |
A Perl one-liner which will do this:
perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'
This will execute whatever you type, prefixed with git
. And it will keep doing that until you hit ^D
.
A Perl one-liner which will do this:
perl -nE 'BEGIN print "git > " system "git $_"; print "git > "'
This will execute whatever you type, prefixed with git
. And it will keep doing that until you hit ^D
.
answered Jun 8 at 20:50
AbigailAbigail
1,09829
1,09829
5
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
2
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
1
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s-ne
flags).
– Konrad Rudolph
Jun 10 at 13:23
10
@KonradRudolphperl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
add a comment |
5
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
2
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
1
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s-ne
flags).
– Konrad Rudolph
Jun 10 at 13:23
10
@KonradRudolphperl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
5
5
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
This really is most similar to what OP is asking for, and in a very lightweight package!
– ruohola
Jun 10 at 7:02
2
2
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
This is probably the best answer and it is very easy to modify it for other, similar, use cases.
– Cedric H.
Jun 10 at 12:01
1
1
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s
-ne
flags).– Konrad Rudolph
Jun 10 at 13:23
This would be perfect if it worked with readline but unfortunately it doesn’t (not surprisingly since this is strictly a hack around Perl’s
-ne
flags).– Konrad Rudolph
Jun 10 at 13:23
10
10
@KonradRudolph
perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
@KonradRudolph
perl -MTerm::ReadLine -E '$n = Term::ReadLine -> new ("git"); while ($_ = $n -> readline ("git > ")) system "git $_"'
– Abigail
Jun 10 at 17:35
add a comment |
This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc
for the Git commands you use most frequently:
alias commit='git commit'
alias checkout='git checkout'
...
Also note that you can create aliases within Git itself:
git config --global alias.ci commit
git config --global alias.co checkout
...
This lets you type git ci
instead of git commit
, and so on.
5
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
21
Only for the most frequently used. I mean, how often do you usegit hash-object
orgit interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.
– Thomas
Jun 8 at 9:42
14
In addition toci
forcommit
I also use a shell aliasg
forgit
, this reduces most of the typing and lets me stay in my preferred shell.
– rkta
Jun 8 at 18:26
add a comment |
This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc
for the Git commands you use most frequently:
alias commit='git commit'
alias checkout='git checkout'
...
Also note that you can create aliases within Git itself:
git config --global alias.ci commit
git config --global alias.co checkout
...
This lets you type git ci
instead of git commit
, and so on.
5
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
21
Only for the most frequently used. I mean, how often do you usegit hash-object
orgit interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.
– Thomas
Jun 8 at 9:42
14
In addition toci
forcommit
I also use a shell aliasg
forgit
, this reduces most of the typing and lets me stay in my preferred shell.
– rkta
Jun 8 at 18:26
add a comment |
This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc
for the Git commands you use most frequently:
alias commit='git commit'
alias checkout='git checkout'
...
Also note that you can create aliases within Git itself:
git config --global alias.ci commit
git config --global alias.co checkout
...
This lets you type git ci
instead of git commit
, and so on.
This is not exactly what you're asking for, but you could set up some shell aliases in your ~/.bashrc
for the Git commands you use most frequently:
alias commit='git commit'
alias checkout='git checkout'
...
Also note that you can create aliases within Git itself:
git config --global alias.ci commit
git config --global alias.co checkout
...
This lets you type git ci
instead of git commit
, and so on.
edited Jun 9 at 10:39
answered Jun 8 at 9:36
ThomasThomas
118k35257369
118k35257369
5
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
21
Only for the most frequently used. I mean, how often do you usegit hash-object
orgit interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.
– Thomas
Jun 8 at 9:42
14
In addition toci
forcommit
I also use a shell aliasg
forgit
, this reduces most of the typing and lets me stay in my preferred shell.
– rkta
Jun 8 at 18:26
add a comment |
5
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
21
Only for the most frequently used. I mean, how often do you usegit hash-object
orgit interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.
– Thomas
Jun 8 at 9:42
14
In addition toci
forcommit
I also use a shell aliasg
forgit
, this reduces most of the typing and lets me stay in my preferred shell.
– rkta
Jun 8 at 18:26
5
5
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
The drawback of this approach is that a separate alias would need to be created for every Git command.
– Tim Biegeleisen
Jun 8 at 9:39
21
21
Only for the most frequently used. I mean, how often do you use
git hash-object
or git interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.– Thomas
Jun 8 at 9:42
Only for the most frequently used. I mean, how often do you use
git hash-object
or git interpret-trailers
? I'm just offering this as an alternative because as far as I know, what the question is asking for doesn't really exist.– Thomas
Jun 8 at 9:42
14
14
In addition to
ci
for commit
I also use a shell alias g
for git
, this reduces most of the typing and lets me stay in my preferred shell.– rkta
Jun 8 at 18:26
In addition to
ci
for commit
I also use a shell alias g
for git
, this reduces most of the typing and lets me stay in my preferred shell.– rkta
Jun 8 at 18:26
add a comment |
I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:
# git
alias gw='git whatchanged'
alias gg='git grep -n -C8'
alias ggi='git grep -i -n -C8'
alias gb='git branch'
alias gbd='git branch -D'
alias gba='git branch -a'
alias gc='git checkout'
alias gcp='git cherry-pick'
alias gfo='git fetch origin'
alias s='git status'
alias gmom='git merge origin/master'
alias grom='git rebase origin/master'
alias gpom='git pull origin master'
alias pplog='git log --oneline --graph --decorate'
1
where's commit :P
– qwr
Jun 10 at 15:55
11
I don't includecommit
orpush
since I want a few extra seconds (while typing) to be sure that I'm not destroying something
– JacobIRR
Jun 10 at 17:19
2
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
add a comment |
I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:
# git
alias gw='git whatchanged'
alias gg='git grep -n -C8'
alias ggi='git grep -i -n -C8'
alias gb='git branch'
alias gbd='git branch -D'
alias gba='git branch -a'
alias gc='git checkout'
alias gcp='git cherry-pick'
alias gfo='git fetch origin'
alias s='git status'
alias gmom='git merge origin/master'
alias grom='git rebase origin/master'
alias gpom='git pull origin master'
alias pplog='git log --oneline --graph --decorate'
1
where's commit :P
– qwr
Jun 10 at 15:55
11
I don't includecommit
orpush
since I want a few extra seconds (while typing) to be sure that I'm not destroying something
– JacobIRR
Jun 10 at 17:19
2
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
add a comment |
I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:
# git
alias gw='git whatchanged'
alias gg='git grep -n -C8'
alias ggi='git grep -i -n -C8'
alias gb='git branch'
alias gbd='git branch -D'
alias gba='git branch -a'
alias gc='git checkout'
alias gcp='git cherry-pick'
alias gfo='git fetch origin'
alias s='git status'
alias gmom='git merge origin/master'
alias grom='git rebase origin/master'
alias gpom='git pull origin master'
alias pplog='git log --oneline --graph --decorate'
I'm a big fan of using aliases in ~/.bash_profile for my GitBash. If you go with this approach, here are some of my favorites:
# git
alias gw='git whatchanged'
alias gg='git grep -n -C8'
alias ggi='git grep -i -n -C8'
alias gb='git branch'
alias gbd='git branch -D'
alias gba='git branch -a'
alias gc='git checkout'
alias gcp='git cherry-pick'
alias gfo='git fetch origin'
alias s='git status'
alias gmom='git merge origin/master'
alias grom='git rebase origin/master'
alias gpom='git pull origin master'
alias pplog='git log --oneline --graph --decorate'
answered Jun 10 at 1:46
JacobIRRJacobIRR
4,02331433
4,02331433
1
where's commit :P
– qwr
Jun 10 at 15:55
11
I don't includecommit
orpush
since I want a few extra seconds (while typing) to be sure that I'm not destroying something
– JacobIRR
Jun 10 at 17:19
2
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
add a comment |
1
where's commit :P
– qwr
Jun 10 at 15:55
11
I don't includecommit
orpush
since I want a few extra seconds (while typing) to be sure that I'm not destroying something
– JacobIRR
Jun 10 at 17:19
2
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
1
1
where's commit :P
– qwr
Jun 10 at 15:55
where's commit :P
– qwr
Jun 10 at 15:55
11
11
I don't include
commit
or push
since I want a few extra seconds (while typing) to be sure that I'm not destroying something– JacobIRR
Jun 10 at 17:19
I don't include
commit
or push
since I want a few extra seconds (while typing) to be sure that I'm not destroying something– JacobIRR
Jun 10 at 17:19
2
2
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
Commit and push shouldn't be able to destroy anything unless you use force push. But I try to use git status beforehand.
– qwr
Jun 10 at 18:21
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
this is what I've done as well, +1. Although I'm tempted to try gitsh as other answers have mentioned
– CoffeeTableEspresso
Jun 10 at 23:50
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
@CoffeeTableEspresso I respect the fact that you acknowledge that a few keystrokes is the difference between saving updates and destroying a project.
– LogicalBranch
Jun 11 at 10:53
add a comment |
A friend of mine made a small bash script that accomplishes this. It's called Replify.
$ replify git
Initialized REPL for [git]
git> init
Initialized empty Git repository in /your/directory/here/.git/
git> remote add origin https://your-url/repo.git
git> checkout -b new-branch
Switched to a new branch 'new-branch'
git> push
4
OK, I've already mentioned that on Umur's answer, but the use ofeval
in the original script source isn't the best idea. Tell your friend to usewhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead
– Sergiy Kolodyazhnyy
Jun 10 at 23:34
add a comment |
A friend of mine made a small bash script that accomplishes this. It's called Replify.
$ replify git
Initialized REPL for [git]
git> init
Initialized empty Git repository in /your/directory/here/.git/
git> remote add origin https://your-url/repo.git
git> checkout -b new-branch
Switched to a new branch 'new-branch'
git> push
4
OK, I've already mentioned that on Umur's answer, but the use ofeval
in the original script source isn't the best idea. Tell your friend to usewhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead
– Sergiy Kolodyazhnyy
Jun 10 at 23:34
add a comment |
A friend of mine made a small bash script that accomplishes this. It's called Replify.
$ replify git
Initialized REPL for [git]
git> init
Initialized empty Git repository in /your/directory/here/.git/
git> remote add origin https://your-url/repo.git
git> checkout -b new-branch
Switched to a new branch 'new-branch'
git> push
A friend of mine made a small bash script that accomplishes this. It's called Replify.
$ replify git
Initialized REPL for [git]
git> init
Initialized empty Git repository in /your/directory/here/.git/
git> remote add origin https://your-url/repo.git
git> checkout -b new-branch
Switched to a new branch 'new-branch'
git> push
edited Jun 10 at 14:06
wjandrea
2,2431433
2,2431433
answered Jun 10 at 7:11
Sam WeaverSam Weaver
594617
594617
4
OK, I've already mentioned that on Umur's answer, but the use ofeval
in the original script source isn't the best idea. Tell your friend to usewhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead
– Sergiy Kolodyazhnyy
Jun 10 at 23:34
add a comment |
4
OK, I've already mentioned that on Umur's answer, but the use ofeval
in the original script source isn't the best idea. Tell your friend to usewhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead
– Sergiy Kolodyazhnyy
Jun 10 at 23:34
4
4
OK, I've already mentioned that on Umur's answer, but the use of
eval
in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead– Sergiy Kolodyazhnyy
Jun 10 at 23:34
OK, I've already mentioned that on Umur's answer, but the use of
eval
in the original script source isn't the best idea. Tell your friend to use while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
instead– Sergiy Kolodyazhnyy
Jun 10 at 23:34
add a comment |
Use your editor.
Type the command like commit
from your favorite editor like vs code and be more efficient with git:
Or type git
to get all the commands:
11
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
3
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
3
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
|
show 3 more comments
Use your editor.
Type the command like commit
from your favorite editor like vs code and be more efficient with git:
Or type git
to get all the commands:
11
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
3
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
3
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
|
show 3 more comments
Use your editor.
Type the command like commit
from your favorite editor like vs code and be more efficient with git:
Or type git
to get all the commands:
Use your editor.
Type the command like commit
from your favorite editor like vs code and be more efficient with git:
Or type git
to get all the commands:
edited Jun 10 at 16:28
answered Jun 10 at 16:08
prostiprosti
8,24113244
8,24113244
11
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
3
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
3
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
|
show 3 more comments
11
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
3
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
3
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
11
11
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
I'm surprised by all these down votes. This isn't a terrible answer for people who use IDEs that support these features.
– Glen Pierce
Jun 10 at 18:16
3
3
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
I think people have down-voted because not everyone uses/likes VS-Code. Either way, I think it's a decent solution so +1 from me.
– LogicalBranch
Jun 10 at 18:45
3
3
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
@LogicalBranch, people are generally using the git from command line, and I am aware of that, but the git support inside some editors exists and it is worth trying.
– prosti
Jun 10 at 19:19
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
I don't like this answer because not everyone uses VS code (I personally don't like it), but won't downvote because this is a nice solution for ppl that do use it.
– CoffeeTableEspresso
Jun 10 at 23:48
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
@CoffeeTableEspresso, if you are using sublime there is a plugin called gitsavvy, and so on... Almost every editor nowadays has some kind of support for git. This was the point of the answer, as you can read "Use your editor".
– prosti
Jun 11 at 4:43
|
show 3 more comments
Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc
:
complete -E -W git
Now pressing Tab at an empty Bash prompt will type out "git ".
4
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in~/zshrc
, for tcsh, you'll put it in~/tcshrc
, etc.
– TheOnlyMrCat
Jun 10 at 6:17
add a comment |
Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc
:
complete -E -W git
Now pressing Tab at an empty Bash prompt will type out "git ".
4
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in~/zshrc
, for tcsh, you'll put it in~/tcshrc
, etc.
– TheOnlyMrCat
Jun 10 at 6:17
add a comment |
Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc
:
complete -E -W git
Now pressing Tab at an empty Bash prompt will type out "git ".
Here is another way. It's also not quite what was asked, but I've been using it for some time and it is pretty nice. Add the following line to your ~/.bashrc
:
complete -E -W git
Now pressing Tab at an empty Bash prompt will type out "git ".
answered Jun 9 at 14:06
nomadictypenomadictype
570210
570210
4
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in~/zshrc
, for tcsh, you'll put it in~/tcshrc
, etc.
– TheOnlyMrCat
Jun 10 at 6:17
add a comment |
4
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in~/zshrc
, for tcsh, you'll put it in~/tcshrc
, etc.
– TheOnlyMrCat
Jun 10 at 6:17
4
4
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in
~/zshrc
, for tcsh, you'll put it in ~/tcshrc
, etc.– TheOnlyMrCat
Jun 10 at 6:17
Note that if you're using another shell, you'll have to put it in the appropriate file. For example, for zsh, you'll put it in
~/zshrc
, for tcsh, you'll put it in ~/tcshrc
, etc.– TheOnlyMrCat
Jun 10 at 6:17
add a comment |
I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.
I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git
command, so instead I wrote a python script called NoGit to solve this problem:
#!/usr/bin/env python
import sys, os, signal, atexit, readline, subprocess
commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")
def run_commands():
stop = True
for cmd in commands:
command = ["git" if not cmd.startswith("git ") else ""]
command = [cmd] if command[0] == "" else [command[0], cmd]
subprocess.Popen(command).communicate()
commands = []
def signal_handler(sig, frame):
run_commands()
sys.exit(0)
try:
readline.read_history_file(history_file)
signal.signal(signal.SIGINT, signal_handler)
while True:
if stop == True:
break
command = input("git> ")
if command == "%undo":
commands.pop()
elif command == "%run":
run_commands()
elif command == "%exit":
sys.exit(0)
else:
commands += [cmd.strip() for cmd in command.split(";")]
signal.pause()
readline.set_history_length(-1)
except IOError:
pass
atexit.register(readline.write_history_file, history_file)
NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.
Documentation:
- the
%undo
command removes the last command from the stack - the
%run
command runs the commands in the stack and clears the stack - the
%exit
command closes the CLI without doing anything - pressing
ctr+c
is the same as running%run; %exit
- the script saves commands that were executed to a file called
git.history
in the same folder as the script - you can add multiple commands in one line using a semi-colon
- you can use the keyword
git
in the beginning of the command and the script won't duplicate it (E.G:git init
doesn't becomegit git init
)
Example commands:
init
add .
stage .
commit -m "inital commit"
%run; %exit
Additional information (for Linux users):
If you want you can remove the .py
extension and convert it into an executable using:
mv ./git.py ./git
chmod +x ./git
Then instead of calling the script like this:
python3 git.py
You'd run this instead:
./git
Additional information (for lazy people):
If you're lazy and don't want to type out a ./
then you could move this script to your /bin/
folder and create an alias for it.
If you're really, really lazy, use the following commands:
sudo cp ./git /bin/nogit
sudo chmod +x /bin/nogit
alias nogit='/bin/nogit'
If you're really, really, really lazy, copy and paste the following one-liner:
sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'
If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:
sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'
Good luck.
add a comment |
I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.
I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git
command, so instead I wrote a python script called NoGit to solve this problem:
#!/usr/bin/env python
import sys, os, signal, atexit, readline, subprocess
commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")
def run_commands():
stop = True
for cmd in commands:
command = ["git" if not cmd.startswith("git ") else ""]
command = [cmd] if command[0] == "" else [command[0], cmd]
subprocess.Popen(command).communicate()
commands = []
def signal_handler(sig, frame):
run_commands()
sys.exit(0)
try:
readline.read_history_file(history_file)
signal.signal(signal.SIGINT, signal_handler)
while True:
if stop == True:
break
command = input("git> ")
if command == "%undo":
commands.pop()
elif command == "%run":
run_commands()
elif command == "%exit":
sys.exit(0)
else:
commands += [cmd.strip() for cmd in command.split(";")]
signal.pause()
readline.set_history_length(-1)
except IOError:
pass
atexit.register(readline.write_history_file, history_file)
NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.
Documentation:
- the
%undo
command removes the last command from the stack - the
%run
command runs the commands in the stack and clears the stack - the
%exit
command closes the CLI without doing anything - pressing
ctr+c
is the same as running%run; %exit
- the script saves commands that were executed to a file called
git.history
in the same folder as the script - you can add multiple commands in one line using a semi-colon
- you can use the keyword
git
in the beginning of the command and the script won't duplicate it (E.G:git init
doesn't becomegit git init
)
Example commands:
init
add .
stage .
commit -m "inital commit"
%run; %exit
Additional information (for Linux users):
If you want you can remove the .py
extension and convert it into an executable using:
mv ./git.py ./git
chmod +x ./git
Then instead of calling the script like this:
python3 git.py
You'd run this instead:
./git
Additional information (for lazy people):
If you're lazy and don't want to type out a ./
then you could move this script to your /bin/
folder and create an alias for it.
If you're really, really lazy, use the following commands:
sudo cp ./git /bin/nogit
sudo chmod +x /bin/nogit
alias nogit='/bin/nogit'
If you're really, really, really lazy, copy and paste the following one-liner:
sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'
If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:
sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'
Good luck.
add a comment |
I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.
I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git
command, so instead I wrote a python script called NoGit to solve this problem:
#!/usr/bin/env python
import sys, os, signal, atexit, readline, subprocess
commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")
def run_commands():
stop = True
for cmd in commands:
command = ["git" if not cmd.startswith("git ") else ""]
command = [cmd] if command[0] == "" else [command[0], cmd]
subprocess.Popen(command).communicate()
commands = []
def signal_handler(sig, frame):
run_commands()
sys.exit(0)
try:
readline.read_history_file(history_file)
signal.signal(signal.SIGINT, signal_handler)
while True:
if stop == True:
break
command = input("git> ")
if command == "%undo":
commands.pop()
elif command == "%run":
run_commands()
elif command == "%exit":
sys.exit(0)
else:
commands += [cmd.strip() for cmd in command.split(";")]
signal.pause()
readline.set_history_length(-1)
except IOError:
pass
atexit.register(readline.write_history_file, history_file)
NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.
Documentation:
- the
%undo
command removes the last command from the stack - the
%run
command runs the commands in the stack and clears the stack - the
%exit
command closes the CLI without doing anything - pressing
ctr+c
is the same as running%run; %exit
- the script saves commands that were executed to a file called
git.history
in the same folder as the script - you can add multiple commands in one line using a semi-colon
- you can use the keyword
git
in the beginning of the command and the script won't duplicate it (E.G:git init
doesn't becomegit git init
)
Example commands:
init
add .
stage .
commit -m "inital commit"
%run; %exit
Additional information (for Linux users):
If you want you can remove the .py
extension and convert it into an executable using:
mv ./git.py ./git
chmod +x ./git
Then instead of calling the script like this:
python3 git.py
You'd run this instead:
./git
Additional information (for lazy people):
If you're lazy and don't want to type out a ./
then you could move this script to your /bin/
folder and create an alias for it.
If you're really, really lazy, use the following commands:
sudo cp ./git /bin/nogit
sudo chmod +x /bin/nogit
alias nogit='/bin/nogit'
If you're really, really, really lazy, copy and paste the following one-liner:
sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'
If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:
sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'
Good luck.
I know this is a very late answer but this question really struck a note with me because I've been dealing with suffering from this kind of repetition for quite a while now.
I'm not sure about you but I honestly don't (I repeat DON'T) want to create aliases for every git
command, so instead I wrote a python script called NoGit to solve this problem:
#!/usr/bin/env python
import sys, os, signal, atexit, readline, subprocess
commands, stop, history_file = [], False, os.path.join(os.getcwd(), "git.history")
def run_commands():
stop = True
for cmd in commands:
command = ["git" if not cmd.startswith("git ") else ""]
command = [cmd] if command[0] == "" else [command[0], cmd]
subprocess.Popen(command).communicate()
commands = []
def signal_handler(sig, frame):
run_commands()
sys.exit(0)
try:
readline.read_history_file(history_file)
signal.signal(signal.SIGINT, signal_handler)
while True:
if stop == True:
break
command = input("git> ")
if command == "%undo":
commands.pop()
elif command == "%run":
run_commands()
elif command == "%exit":
sys.exit(0)
else:
commands += [cmd.strip() for cmd in command.split(";")]
signal.pause()
readline.set_history_length(-1)
except IOError:
pass
atexit.register(readline.write_history_file, history_file)
NoGit is a simple python script to prevent the unnecessary repetition of the "git" keyword.
Documentation:
- the
%undo
command removes the last command from the stack - the
%run
command runs the commands in the stack and clears the stack - the
%exit
command closes the CLI without doing anything - pressing
ctr+c
is the same as running%run; %exit
- the script saves commands that were executed to a file called
git.history
in the same folder as the script - you can add multiple commands in one line using a semi-colon
- you can use the keyword
git
in the beginning of the command and the script won't duplicate it (E.G:git init
doesn't becomegit git init
)
Example commands:
init
add .
stage .
commit -m "inital commit"
%run; %exit
Additional information (for Linux users):
If you want you can remove the .py
extension and convert it into an executable using:
mv ./git.py ./git
chmod +x ./git
Then instead of calling the script like this:
python3 git.py
You'd run this instead:
./git
Additional information (for lazy people):
If you're lazy and don't want to type out a ./
then you could move this script to your /bin/
folder and create an alias for it.
If you're really, really lazy, use the following commands:
sudo cp ./git /bin/nogit
sudo chmod +x /bin/nogit
alias nogit='/bin/nogit'
If you're really, really, really lazy, copy and paste the following one-liner:
sudo cp ./git /bin/nogit && sudo chmod +x /bin/nogit && alias nogit='/bin/nogit'
If your laziness has reached levels previously unknown to humanity, here is a more compact version of the same one-liner:
sudo cp ./git /bin/nogit;sudo chmod +x /bin/nogit;alias nogit='/bin/nogit'
Good luck.
edited Jun 10 at 20:23
answered Jun 10 at 15:00
LogicalBranchLogicalBranch
2,1891840
2,1891840
add a comment |
add a comment |
In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
while(true)
std::cout << "git> ";
std::cout.flush();
std::string command;
std::getline(std::cin, command);
if(command == "exit") break;
std::system("git " + command);
return 0;
Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
8
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
1
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
2
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
add a comment |
In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
while(true)
std::cout << "git> ";
std::cout.flush();
std::string command;
std::getline(std::cin, command);
if(command == "exit") break;
std::system("git " + command);
return 0;
Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
8
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
1
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
2
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
add a comment |
In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
while(true)
std::cout << "git> ";
std::cout.flush();
std::string command;
std::getline(std::cin, command);
if(command == "exit") break;
std::system("git " + command);
return 0;
Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.
In your example, you compare it to a MySql prompt. The way that works is that a MySql process starts, and you give your commands to that process. As such, why not write something similar in your language of choice? Here's a simple example in C++:
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
while(true)
std::cout << "git> ";
std::cout.flush();
std::string command;
std::getline(std::cin, command);
if(command == "exit") break;
std::system("git " + command);
return 0;
Please note that I just wrote that from memory and that I didn't check it with a compiler. There may be trivial syntax errors.
answered Jun 9 at 17:06
john01davjohn01dav
839521
839521
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
8
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
1
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
2
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
add a comment |
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
8
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
1
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
2
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
Just my thought. Anyone on Stack Overflow should be able to code such a program himself. The programming language does not really matter.
– Thomas Weller
Jun 9 at 18:23
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
@ThomasWeller I definitely agree. I posted the program to precisely show what I was talking about, not because it is a difficult program to write.
– john01dav
Jun 9 at 21:24
8
8
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
You're going to invest a lot of time with this approach if you want the program to be bug-free and have a decent amount of features. For example, after fixing the initial build failure (std::system() wants const char*) you'll notice that there is an infinite loop on EOF. You might want history/readline support, tab completion, some builtins to change directory / set env vars / shell out / ..., etc. If there is existing software (like gitsh in this case), why not use it?
– nomadictype
Jun 9 at 22:51
1
1
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
@nomadictype That's a valid criticism, but learning other software is also a time commitment. The advantages with this approach are that only a few minutes are needed to get it working, and thst it will do exactly what you expect or want (with changes).
– john01dav
Jun 9 at 22:57
2
2
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
The loss of readline, line editing, history support, being able to run simple commands like ls, etc is going to cost you a lot more than the four keystrokes or so you saved with this.
– Lie Ryan
Jun 11 at 1:20
add a comment |
Another approach that will work with any commands: use Ctrl+R (reverse-i-search).
The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.
You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.
git commit --amend
:<Ctrl+R>am
git pull
:<Ctrl+R>pu
git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header
:<Ctrl+R>blu
git rebase --abort
:<Ctrl-R>ab
git rebase --continue
:<Ctrl-R>con
docker-compose stop && git pull && make && docker-compose up -d
:<Ctrl-R>up
- etc
Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.
add a comment |
Another approach that will work with any commands: use Ctrl+R (reverse-i-search).
The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.
You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.
git commit --amend
:<Ctrl+R>am
git pull
:<Ctrl+R>pu
git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header
:<Ctrl+R>blu
git rebase --abort
:<Ctrl-R>ab
git rebase --continue
:<Ctrl-R>con
docker-compose stop && git pull && make && docker-compose up -d
:<Ctrl-R>up
- etc
Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.
add a comment |
Another approach that will work with any commands: use Ctrl+R (reverse-i-search).
The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.
You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.
git commit --amend
:<Ctrl+R>am
git pull
:<Ctrl+R>pu
git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header
:<Ctrl+R>blu
git rebase --abort
:<Ctrl-R>ab
git rebase --continue
:<Ctrl-R>con
docker-compose stop && git pull && make && docker-compose up -d
:<Ctrl-R>up
- etc
Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.
Another approach that will work with any commands: use Ctrl+R (reverse-i-search).
The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.
You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.
git commit --amend
:<Ctrl+R>am
git pull
:<Ctrl+R>pu
git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header
:<Ctrl+R>blu
git rebase --abort
:<Ctrl-R>ab
git rebase --continue
:<Ctrl-R>con
docker-compose stop && git pull && make && docker-compose up -d
:<Ctrl-R>up
- etc
Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.
answered Jun 10 at 2:02
Lie RyanLie Ryan
46.8k1075126
46.8k1075126
add a comment |
add a comment |
For basic stuff, you can do:
function ggit() while true; do printf 'git> '; read; eval git $REPLY; done
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: yarn.lock
no changes added to commit (use "git add" and/or "git commit -a")
git> add .
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: yarn.lock
git>
Exit with ctrl+c
1
Decent idea, however there's two problems. One, the;
after do leads tobash: syntax error near unexpected token
;'` Second, theeval
part is prone to vulnerabilities. For example, consider what happens if I typestatus;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that intowhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better
– Sergiy Kolodyazhnyy
Jun 10 at 23:22
2
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you typegit status; cat /etc/passwd
at the shell prompt!
– Abigail
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not withoutsystem
or!
at the beginning at least. Where the assumption might be that this "repl" executesgit
commands only, it in fact allows more than that.
– Sergiy Kolodyazhnyy
2 days ago
2
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prependsmysql
to the commands. If you are afraid the promptgit >
looks too much like themysql >
prompt, you can always change it togit $
orthis is not mysql, don't type anything you would not type in the shell >
.
– Abigail
2 days ago
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -eval
isn't the best idea for running commands, especially when user-controlled input is involved.
– Sergiy Kolodyazhnyy
yesterday
|
show 1 more comment
For basic stuff, you can do:
function ggit() while true; do printf 'git> '; read; eval git $REPLY; done
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: yarn.lock
no changes added to commit (use "git add" and/or "git commit -a")
git> add .
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: yarn.lock
git>
Exit with ctrl+c
1
Decent idea, however there's two problems. One, the;
after do leads tobash: syntax error near unexpected token
;'` Second, theeval
part is prone to vulnerabilities. For example, consider what happens if I typestatus;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that intowhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better
– Sergiy Kolodyazhnyy
Jun 10 at 23:22
2
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you typegit status; cat /etc/passwd
at the shell prompt!
– Abigail
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not withoutsystem
or!
at the beginning at least. Where the assumption might be that this "repl" executesgit
commands only, it in fact allows more than that.
– Sergiy Kolodyazhnyy
2 days ago
2
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prependsmysql
to the commands. If you are afraid the promptgit >
looks too much like themysql >
prompt, you can always change it togit $
orthis is not mysql, don't type anything you would not type in the shell >
.
– Abigail
2 days ago
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -eval
isn't the best idea for running commands, especially when user-controlled input is involved.
– Sergiy Kolodyazhnyy
yesterday
|
show 1 more comment
For basic stuff, you can do:
function ggit() while true; do printf 'git> '; read; eval git $REPLY; done
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: yarn.lock
no changes added to commit (use "git add" and/or "git commit -a")
git> add .
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: yarn.lock
git>
Exit with ctrl+c
For basic stuff, you can do:
function ggit() while true; do printf 'git> '; read; eval git $REPLY; done
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: yarn.lock
no changes added to commit (use "git add" and/or "git commit -a")
git> add .
git> status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: yarn.lock
git>
Exit with ctrl+c
edited 1 hour ago
answered Jun 10 at 19:54
Umur KontacıUmur Kontacı
33.3k56390
33.3k56390
1
Decent idea, however there's two problems. One, the;
after do leads tobash: syntax error near unexpected token
;'` Second, theeval
part is prone to vulnerabilities. For example, consider what happens if I typestatus;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that intowhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better
– Sergiy Kolodyazhnyy
Jun 10 at 23:22
2
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you typegit status; cat /etc/passwd
at the shell prompt!
– Abigail
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not withoutsystem
or!
at the beginning at least. Where the assumption might be that this "repl" executesgit
commands only, it in fact allows more than that.
– Sergiy Kolodyazhnyy
2 days ago
2
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prependsmysql
to the commands. If you are afraid the promptgit >
looks too much like themysql >
prompt, you can always change it togit $
orthis is not mysql, don't type anything you would not type in the shell >
.
– Abigail
2 days ago
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -eval
isn't the best idea for running commands, especially when user-controlled input is involved.
– Sergiy Kolodyazhnyy
yesterday
|
show 1 more comment
1
Decent idea, however there's two problems. One, the;
after do leads tobash: syntax error near unexpected token
;'` Second, theeval
part is prone to vulnerabilities. For example, consider what happens if I typestatus;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that intowhile IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better
– Sergiy Kolodyazhnyy
Jun 10 at 23:22
2
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you typegit status; cat /etc/passwd
at the shell prompt!
– Abigail
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not withoutsystem
or!
at the beginning at least. Where the assumption might be that this "repl" executesgit
commands only, it in fact allows more than that.
– Sergiy Kolodyazhnyy
2 days ago
2
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prependsmysql
to the commands. If you are afraid the promptgit >
looks too much like themysql >
prompt, you can always change it togit $
orthis is not mysql, don't type anything you would not type in the shell >
.
– Abigail
2 days ago
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -eval
isn't the best idea for running commands, especially when user-controlled input is involved.
– Sergiy Kolodyazhnyy
yesterday
1
1
Decent idea, however there's two problems. One, the
;
after do leads to bash: syntax error near unexpected token
;'` Second, the eval
part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better– Sergiy Kolodyazhnyy
Jun 10 at 23:22
Decent idea, however there's two problems. One, the
;
after do leads to bash: syntax error near unexpected token
;'` Second, the eval
part is prone to vulnerabilities. For example, consider what happens if I type status;cat /etc/passwd
into this small shell. Harmless example, but you get the idea what can happen .You can simplify that into while IFS= read -r -p "git> " gitcmd; do [ "x$gitcmd" != "x" ] && git "$gitcmd";done
This of course is not bullet proof, but 1 - it is simpler and 2 - avoids non-git command execution (by virtue of double quotes ). Not ideal, just a little better– Sergiy Kolodyazhnyy
Jun 10 at 23:22
2
2
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you type
git status; cat /etc/passwd
at the shell prompt!– Abigail
2 days ago
@SergiyKolodyazhnyy By that logic, the shell itself is prone to vulnerabilities. Consider what happens if you type
git status; cat /etc/passwd
at the shell prompt!– Abigail
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not without
system
or !
at the beginning at least. Where the assumption might be that this "repl" executes git
commands only, it in fact allows more than that.– Sergiy Kolodyazhnyy
2 days ago
@Abigail Funny :) Why yes, shell itself isn't the most secure application. Even catting a file can be a problem. However, the point I was originally making is that we don't see mysql interpreter executing shell commands, not without
system
or !
at the beginning at least. Where the assumption might be that this "repl" executes git
commands only, it in fact allows more than that.– Sergiy Kolodyazhnyy
2 days ago
2
2
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prepends
mysql
to the commands. If you are afraid the prompt git >
looks too much like the mysql >
prompt, you can always change it to git $
or this is not mysql, don't type anything you would not type in the shell >
.– Abigail
2 days ago
@SergiyKolodyazhnyy Sure, but the mysql interperter isn't just a program which prepends
mysql
to the commands. If you are afraid the prompt git >
looks too much like the mysql >
prompt, you can always change it to git $
or this is not mysql, don't type anything you would not type in the shell >
.– Abigail
2 days ago
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -
eval
isn't the best idea for running commands, especially when user-controlled input is involved.– Sergiy Kolodyazhnyy
yesterday
@Abigail I am not afraid, because I know what this does. Others who don't - may end up breaking something they shouldn't. And again -
eval
isn't the best idea for running commands, especially when user-controlled input is involved.– Sergiy Kolodyazhnyy
yesterday
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56505000%2fhow-do-i-avoid-typing-git-at-the-begining-of-every-git-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
73
To those who have voted to close on the basis of it being off-topic, please read the text you are clicking on: "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming.". Git is a tool used by programmers. As evidenced by the fact that it has its own tag on this site.
– JBentley
Jun 10 at 15:24
3
Why are you typing "git" so much? Your IDE should have powerful vcs integrations available at a keypress. Do you rather type "git pull" 50 times a day, or ctrl-t... stop being a command line warrior when you dont need to be ;)
– vikingsteve
Jun 11 at 8:55
5
@vikingsteve Practically all git help and wisdom is given in terms of command-line.
– Ed Randall
Jun 11 at 17:08
6
@vikingsteve I'm typing it so much because it's faster. I type ~100wpm, more if I'm intimately familiar with the keypresses like I am with Git; compared to clicking on GUIs, it's just easier. Your favorite IDE may have keyboard shortcuts. That's nice for you. Why would I waste time learning them when <M-Tab>git blah<CR> is already in my muscle memory?
– Nic Hartley
Jun 11 at 17:08
2
There should be a "this question should be closed because the user is asking a question that doesn't make sense" - like I get what you're asking but how is the shell going to know you want to enter a "non starting with git command" if there was indeed a way to do this.
– user3728501
Jun 11 at 22:21