"\C-gs": "git status -sb "
Then, for example, after pressing Ctrl-g, s "git status -sb " will appear in your prompt. Much more readable than lots of two or three letter aliases. You can see the complete list of my shortcuts on my GitHub - https://github.com/grn/dotfiles/blob/master/inputrcLevel Up Your Shell Game
41–50 of 50 posts
Re: Level Up Your Shell Game
#42When you execute a command that takes a long time to run and you want to send it to the background you can do: ctrl + z then, to send it to the background: bg and, to get it back from the background: fg Also, I really like to use "for", like: // get the size of each file or directory in the current directory for i in `ls -1`; do du -hs $i; done;
Re: Level Up Your Shell Game
#43I didn't see Ctrl-r, but I've found that to be the most insanely useful shortcut. Ctrl-r = reverse history search. Type a partial command after Ctrl-r and it'll find the most recent executed command with that substring in it. Press Ctrl-r again, jump to the next oldest command containing your substring. Did you accidentally press too many Ctrl-r? Press backspace to move forward in history.
Backspace normally just deletes the last character in your incremental search string.
And be sure that C-s / C-q aren't set up for terminal flow control with something like:
stty start undef stop undefRe: Level Up Your Shell Game
#44IMO the aliases for git should be in ~/.gitconfig instead. I have a bunch of these, like: [alias] br = branch co = checkout ci = commit -v sci = svn dcommit --interactive cp = cherry-pick l = log --pretty=oneline --abbrev-commit l3 = log --pretty=oneline --abbrev-commit -n3 lm = log --pretty=oneline --abbrev-commit master.. rc = rebase --continue st = status -sb squash = !git rebase -i --autosquash $(git merge-base m…
Write a script called git-mycommand, and you can invoke it with 'git mycommand'. Tab completion works too, at least for bash + bash_completion.
Re: Level Up Your Shell Game
#45I prefer to use inputrc instead of aliases. Put the following into your .inputrc "\C-gs": "git status -sb " Then, for example, after pressing Ctrl-g, s "git status -sb " will appear in your prompt. Much more readable than lots of two or three letter aliases. You can see the complete list of my shortcuts on my GitHub - https://github.com/grn/dotfiles/blob/master/inputrc
Re: Level Up Your Shell Game
#46I prefer to use inputrc instead of aliases. Put the following into your .inputrc "\C-gs": "git status -sb " Then, for example, after pressing Ctrl-g, s "git status -sb " will appear in your prompt. Much more readable than lots of two or three letter aliases. You can see the complete list of my shortcuts on my GitHub - https://github.com/grn/dotfiles/blob/master/inputrc
I don't like rebinding C-g, as that's the 'cancel' key for things like incremental search (in emacs bindings).
Re: Level Up Your Shell Game
#47IMO the aliases for git should be in ~/.gitconfig instead. I have a bunch of these, like: [alias] br = branch co = checkout ci = commit -v sci = svn dcommit --interactive cp = cherry-pick l = log --pretty=oneline --abbrev-commit l3 = log --pretty=oneline --abbrev-commit -n3 lm = log --pretty=oneline --abbrev-commit master.. rc = rebase --continue st = status -sb squash = !git rebase -i --autosquash $(git merge-base m…
Did you know you can make your own git commands, and I don't mean just aliases? Write a script called git-mycommand, and you can invoke it with 'git mycommand'. Tab completion works too, at least for bash + bash_completion.
if [ -d $HOME/bin ]
then
PATH=$PATH:$HOME/bin
fiRe: Level Up Your Shell Game
#48I didn't see Ctrl-r, but I've found that to be the most insanely useful shortcut. Ctrl-r = reverse history search. Type a partial command after Ctrl-r and it'll find the most recent executed command with that substring in it. Press Ctrl-r again, jump to the next oldest command containing your substring. Did you accidentally press too many Ctrl-r? Press backspace to move forward in history.
A complementary tip for Ctr+R is to tag long reusable commands with a comment in the end, e.g., find . -name "*.png" -print0 | xargs -0 -P8 pngquant --ext .png --force 256 #optimizepng (if you’re using zsh, you have to enable INTERACTIVE_COMMENTS option first; just run set -k)
Adding a comment there is a neat trick. It also works with bang searches (!?), almost like creating a temporary ad-hoc alias:
find . -name "*.png" -print0 | xargs -0 -P8 pngquant --ext .png --force 256 #optimizepng
... many other commands, time passes ...
!?optimizepngRe: Level Up Your Shell Game
#49When you execute a command that takes a long time to run and you want to send it to the background you can do: ctrl + z then, to send it to the background: bg and, to get it back from the background: fg Also, I really like to use "for", like: // get the size of each file or directory in the current directory for i in `ls -1`; do du -hs $i; done;
I don't understand your last line. How is it different to "for i in *; blah"? Or even just "du -hs ."?
instead of "ls -1" you could use any other command that returns a list
The "du -hs ." will only return the size of the current directory, but that was also an example. You could use any other command that you wanted to perform over each item in the list returned by the first command.
Not sure if this is clear enough, please let me know.
Re: Level Up Your Shell Game
#50Here is a rule for how to level up your shell/editing game. If you ever touch your arrow keys, you are doing something wrong. > ctrl + left arrow Moves the cursor to the left by one word > ctrl + right arrow Moves the cursor to the right by one word Alt + b and Alt + f are also aliases for the same action.
uhh.... So what's wrong with doing the exact same thing with arrow keys? isn't that more natural and convenient?