Git git git git git(caiustheory.com) |
Git git git git git(caiustheory.com) |
(get get get get)
to be equivalent to this one:
get
as in:
((get get get get) {:a 1} :a)
I was very excited about an article on this topic.
I take a minute, clear out distractions and then come back to what I'm working on.
printf("Hello, world!\n");
(printf)("Hello, world!\n");
(*printf)("Hello, world!\n");
(**printf)("Hello, world!\n");
(***printf)("Hello, world!\n");I suppose this is a problem with any alias.
$ \gstatus
gstatus: command not found
vs $ gstatus
git status stuff
The backslash just disables alias expansion. This works on all shells I'm aware of. It won't help with other portability concerns like actual missing commands though, of course.(is this really a thing?)
Does anyone else actually do this besides OP. I've never heard of this problem until now.
Finally I've written a small shell function that corrects "gi tpull" to "git pull", because that happens at least once a day.
(me earlier this month: https://twitter.com/sailoremo/status/908390247548911617)
I think any command where you might start to type something out, but then need to refer to another window or session to figure out what else you want to type, is vulnerable to this kind of mistake.
This process should happen behind the scenes. And then train a RNN for translating it to the following command, which returns a success code. Perhaps, we need to add a few checks that successful command has the same intent as the one which returned 127 error code to the shell.
why type 8 characters 100 times a day, when you can type 1?
Not hatin. Just wondering if I'm alone.
I don't think that can be solved here though.
`alias :q="echo NOT IN VIM!!!"`
https://github.com/jez/dotfiles/blob/master/util/aliases.sh#...
I also have clera, lcear, and lcera -> clear, and :tabe -> vim.
Guilty as charged. I'll commonly start typing git, think about something else, switch to my editor, browser or an other terminal tab, then come back and type "git <command>" in full.
Unsurprisingly…
> rg 'git =' ~/.gitconfig
7: git = ! gitSo, I need to more firmly hit the keys in my actual driver (MS Ergo Keyboard) and now building my own mech...
P.D: ie: Maybe one of the different mech switches are more suited to the way YOU type:
http://www.wasdkeyboards.com/mechanical-keyboard-guide
---
P.D 2: This is a reply to all the ones that state that type wrong some commands.
Also, and maybe more common, is just bad typing. I was far worse before the use of the MS Ergo Keyboard (it DEMAND to use both hands.) So, if the performance change by keyboards (happend to me) maybe is a indication that are the tools at fault here..
As a related issue, it bothers me a lot when I type some command that I want to read the output, and then I proceed to run `ls` right in the sequence and move the output out of the screen.
So... I really fail to see why this article is of any relevance at all, really. Or at least a more global solution would have been better, but I think it's not really an annoyance. For me, it's the same as wanting to fix a UI so that I wouldn't re-double-click a software that I've already started (well, some prevent it, and generally when they do, it means there are sessions, and it annoys me).
Everyone is different. I know an electrical engineer who grew up with dyslexia. So everyone finds their own solutions.
Personally I very rarely spell things wrong in cli.
Then I get distracted on HN ...
gs = git status
ga = git add
gc = git commit
gp = git push
gl = git pull
gt = git tag
- gs is ghostscript
- gc is a component of graphviz
...and all of a sudden your text editor can't generate PDFs anymore when started from the shell.
Instead, I use four-letter aliases which work fine:
- gits = git status
- gitd = git diff
- gitc = git commit
..etc
This is because I want to be the sole controller of what command is actually issued. Call me an old curmudgeon but I just don't trust the auto fix solutions.
Edit: had no idea about Fish. Thank you, all.
Fish-like autosuggestions for zsh: https://github.com/zsh-users/zsh-autosuggestions
I didn't want to ruin my chances by correcting him that side-effects and idempotence refer to different qualities.
I passed the interview, but I've never forgotten that. The guy also seemed to have washed into the interview off his surf board.
Oh well. It was a very major company, so I let it all go.
One notable example: Stripe's "idempotency keys": https://stripe.com/blog/idempotency
On a side note, the founders of Google once tried to explain recursion and idempotence to Terry Gross on NPR. It's pretty amusing. It starts at 13:45 into the interview here:
http://www.npr.org/2003/10/14/167643282/google-founders-larr...
> git git pull
git: 'git' is not a git command. See 'git --help'.
The most similar command is
init
> fuck
git pull [enter/↑/↓/ctrl+c]https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffal...
$ gi tstatus
To fix this, I've added the following to my .bashrc: gi() {
args=("$@")
args[0]=${args[0]/t/}
git "${args[@]}"
}
It also works if you drop the "t" altogether.gi() { ARG=$(echo $1 | sed s/^t//); shift; git "$ARG" "$@"; }
Is the exec really required?
git config --global alias.git '!git'
Will also work. Am I missing something?EDIT: From git doc, "If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command"
So exec is not required then.
Also, I found one caveat from the same docs:
> Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory. GIT_PREFIX is set as returned by running git rev-parse --show-prefix from the original current directory.
So, if I have a modified file `bar` in subdirectory `foo` under project root, and I am currently in `foo`, git status will show:
modified: bar
but git git status will show: modified: foo/bar
To fix this, we should use cd first: git config --global alias.git '!cd "$GIT_PREFIX" && git'Seriously though, I don't understand why people want to hide obvious errors like this - I'd much rather have the tool fail to execute than potentially perform some action I wasn't expecting.
git config --global help.autocorrect 1
It will run the correct misspelled command after 100ms. For example git stauts will be corrected automatically to git status http://schacon.github.io/git/git-config.html
http://durdn.com/blog/2012/11/22/must-have-git-aliases-advan...
My version that works for my setup is `"!f() { git \"$@\"; }; f"`.
Hope this helps anyone who ran into the same issue, although I'm not 100% confident about the quoting.
EDIT: fixed the quoting, as per cryptonector's suggestion
EDIT2: need to quote the quotes for gitconfig to use it correctly
decorator = decorator(decorator)(decorator)
https://github.com/darius/sketchbook/blob/master/misc/decora...There was a subtle bug when leaving out the last (decorator). I know, it's very silly.
I also find "thefuck" is interesting but I love to control my fate :) (https://github.com/nvbn/thefuck)
alias gits='git status' git config --global alias.bomb '!git bomb & git bomb'
to make a fork bomb.Since then, I've found that these aliases have been the best workflow improvement I've ever made.
(It's especially pleasing to watch the system calls it generates via strace or dtrace!)
Works fine, but when I press quit (q), it says `error: exec git died of signal 13`
for a in $(git var -l | sed -nE 's/^alias\.([^=]*)=.*/\1/p') ; do
if ! command -v g$a >/dev/null 2>&1 ; then
alias g$a="git $a"
fi
done
Which creates a shell alias prefixed with `g` for each of my configured git aliases if there is no conflict. So I get not only the `gst` command you mentioned and ones like `gco` (because I have Subversion-equivalent aliases for common commands), but more complex ones like `gstpup` (stash, pull upstream, stash pop). Combined with `alias g=git`, I seldom type "git" and the setup is pretty convenient. I've thought of making the above alias unconditionally, or report conflicts, as it can be jarring when an alias is missing. I've also considered expanding it to all git commands because sometimes my custom ones live as `git-$command` scripts and not aliases.My newer philosophy toward git aliases is the one described here: http://gggritso.com/human-git-aliases. After reading this I totally overhauled my .gitconfig and replaced it with the one described here and I’m a lot happier.
I can usually get away with typing the first letter of each word. So `gd` for git diff.
I also have a variety of git aliases like:
## git log aliases
#
# p -> --patch
# o -> --oneline
# r -> --reverse
# s -> --stat
# 1 -> -n1
# m -> master..
# om -> origin/master..
dom = diff origin/master..
doom = diff origin/master..
rbiom = rebase -i origin/master
lp = log -p
lo = log --oneline
lo1 = log --oneline -n1
lr = log --reverse
lm = log master..
lrm = log --reverse master..
lor = log --oneline --reverse
lorm = log --oneline --reverse master..
lorom = log --oneline --reverse origin/master..
lom = log --oneline master..
loom = log --oneline origin/master..
l1 = log -n1
...Somewhat more seriously, I haven't had to worry about typing 'git git' because I haven't typed 'git' on a daily basis in years. I think I've probably typed it once in the last month.
[0] https://github.com/mtoyoda/sl [1] http://r-wos.org/hacks/gti
Can you disable that feature somewhere ? The suggestion is good, but automatically doing the corrected query is not!
alias g='git status -sb'
alias ga='git add'
alias gac='git commit --amend'
alias gb='git branch'
alias gbb='git checkout -b'
alias gbm='git branch --merged'
alias gbn='git branch --no-merged'
alias gc='git commit -m'
alias gcp='git cherry-pick'
alias gco='git checkout'
alias gd='git diff'
alias gdc='git diff --cached'
alias gg='git status'
alias gl='git log --graph --pretty=format:"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
alias gla='git log --all --graph --pretty=format:"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
alias ggpublish='git push && git push --tags && npm publish'
alias gp='git pull --rebase && git push'
alias gpp='git push && git push --tags'
alias gpl='git pull --rebase --prune'
alias gpt='git pull --rebase && git push --tags'
alias grb='git rebase'
alias grc='git rebase --continue'
alias gsp='git stash ; gp ; git stash pop'
alias unfuckgitremote='git branch --set-upstream-to=origin/`git rev-parse --abbrev-ref HEAD` `git rev-parse --abbrev-ref HEAD`'
I have to admit I use `unfuckgitremote` more often than you'd hope.https://github.com/robbyrussell/oh-my-zsh/blob/master/plugin...
That danger doesn't apply when things are copied from the browser chrome (address bar) or other locations. So why would pasting then still be dangerous?
I think blindly passing on advices "because $SECURITY" can actually detrimental to security because you may end up with half a dozen esoteric practices without actually knowing what they defend against. (I know the parent was half-joking, I think that's a more general problem)
<p>un paragraphe <span style="font-size: 0;">pas si </span>innocent</p>
So disabling JS won't protect you from those. echo hello
This is side-effectful, but idempotent: echo hello >world
This is side-effectful and not idempotent: echo hello >>worldIn the hello world example, I guess we are considering 'echo' as the function. If then if we consider stdout and echo's args to be the same, echo will be idempotent.
However, stdout and command args are pretty different things on any system I know. If we care about things like command line history, then clearly 'echo hello world' is not idempotent.
About the only side effect free operation at a blank line terminal prompt is _probably_ hitting enter or ctrl c. Or ‘#something<Enter>’
But your idempotency examples are spot on.
Basically, idempotency is a very useful concept. Side effect free isn’t.
I posit that you understand perfectly well what i was getting at! If it helps, imagine that you are spawning a fresh shell to execute each command line, through system(3) or some such.
(I suspect you meant “safe” in a different sense, but I couldn't resist.)
My friends have gotten used to see me part the channel and rejoin shortly after, cursing my fingers.
[1] https://addons.mozilla.org/en-US/firefox/addon/lazarus-form-...
Then regular old Cmd + v.
You're welcome.
My wife drafts a lot of legal documents, and has a problem with "doe snot". Which unfortunately the spelling checker is perfectly happy with.
(That said, if it were me, I’m not sure if I would give up typing doe snot every once in a while.)
EDIT: as mentioned below, it is called 'sl'
Besides on my FreeBSD system /usr/bin/vi is around 400kB while on my Debian machine /usr/bin/vim.basic is 2.4MB. It's not much these days but on embedded platform it could still make a significant difference.
Definitely not. 'Safe' means too many things in different contexts to make sweeping statements like that.
Here's one i came across recently. You are interacting with a stock exchange. You have sent an order to buy 100 shares of Twitter stock at some price, and it is now resting on the order book, waiting for orders to sell at that price. You see that the character limit on tweets is being increased, and decide that you don't want to buy 100 shares, but only 90, so you send a message to modify your order. At the same time, two other people, who have also seen the news, decide to dump their holdings of 90 shares each by sending sell orders at the price you are bidding. Their messages arrive just before and after yours. What happens?
If the message to reduce your order is a nasty non-idempotent one which says "reduce my order by 10", then:
1. First seller's order to sell 90 matches your order to buy 100; you buy 90, and your order is reduced to one to buy 10
2. Your modify message reduces your order of 10 to 0
3. Second seller's order to sell 90 arrives, but has nothing to match with
You have successfully bought 90 shares, well done.
If the message to reduce your order is a nice safe idempotent one which says "change my order to 90", then:
1. First seller's order to sell 90 matches your order to buy 100; you buy 90, and your order is reduced to one to buy 10
2. Your modify message increases your order of 10 to 90
3. Second seller's order to sell 90 matches your order to buy 90; you buy 90, and your order is reduced to 0
You have bought 180 shares. Oh dear.
This is not hypothetical. More than one new exchange has launched with a protocol where orders are modified to a target amount, rather than by a target delta, and changed it some time later, after their users got themselves in a pickle.
You can do a bit better by making the modify message a compare-and-set, so it only changes the quantity to 90 if it is currently 100. In that situation, the modify will fail, and the second order will sell you 10 shares. That's still not as good as the non-idempotent message.
> (I suspect you meant “safe” in a different sense, but I couldn't resist.)
The moral of this story is that computer scientists should not be allowed to use the word "safe"!
> Definitely not. 'Safe' means too many things in different contexts to make sweeping statements like that.
The intended reference (which I hoped would be recognized generally in this audience) was to he definition of “safe” and “idempotent” in HTTP (see section 4.2 of RFC 7231.)
(In your example, neither operation is “safe” in the HTTP sense; all state-modifying operations are unsafe.)
It would take different data structures and a different API to translate the user's intent correctly, and then the idempotence of the operation may be important. For example, if the order had a "total" and "current balance", you could be sending a message to set the total to 90(which would internally reduce the current balance), and since that message is idempotent, it's safe to send it multiple times.
Only if you can be sure the non-idempotent message arrived. It's not safe to re-send the delta message.
Keyword: Backups.
This is similar to how busybox binary implements a bunch of the tools from coreutils etc.