Post yout best bash trick. Can be an unknown tip/command/shortcut, whatever useful and time-saving.
Avoid "muuuuh sl -> tchoo tchoo" (and it's not bash and it's useless)
Example : ctrl+alt+"." -> argument from last command. Press "." again for older commands
Jaxson Mitchell
alt+# will comment the line you are typing.
Isaac Howard
Bump. I like this kind of thread
Dominic Harris
agreed, super bump.
Also, ctrl+r will let you type through to previous commands. enter to execute.
That's not exactly a secret but I sure as hell didn't know it.
Kayden Campbell
Nice, thanks.
I like $_ for discovering the full argument stream passed to the previous command:
mkdir foo && cd $_
Robert Jackson
use this if u dont want to be completely blind at 80 redshift -t 3650:3650 -l 90:15
Charles Edwards
xman
you can thank me later
Henry Bailey
chsh -s /bin/zsh
Daniel Price
^X ^E will open your current line in $EDITOR. You can then edit that long command easily. Save and close it and it will be run.
Parker Lopez
dd if=/dev/zero of=/dev/null bs=500M count=1
Bentley Anderson
Holy fuck that is glorious
Thomas Thompson
Oh shit nice
Parker Nelson
touch a file without invoking a fork()
> newfile
Joseph Watson
ctrl+l clears the current line, so much better than writing clear all the time.
Anthony Wilson
echo $? Gives you the exit code of the last thing that ran in the shell
Levi Nguyen
Does anybody know how to get reasonable autocomplete from history features?
If my past three commands look like this
make clean make -j8 python doTests.py
I want
`make` + tab to autocomplete to `make -j8` (first closest match) `make c` + tab to autocomplete to `make clean` `p` + tab to autocomplete to `python doTests.py`
etc, anybody know how to get this? I'm using gnome-shell, not keen to switch to something like zsh
Eli White
>not zsh
Nathaniel Reed
Mostly GNU Readline ctrl + d: close terminal ctrl + c: cancel operation
also the most basic text editor ever cat > newfile then type "ctrl + d" to close it
Eli Richardson
Is ctrl+r not good enough?
David Roberts
Not really no, I'm used to Sublime and my pinky is in tab-trigger-finger mode all the time because of it.
Also, perhaps I don't understand ctrl+r too well, but sometimes it finds a command from far too far into the history, even though there's a better match closer, not sure what that's about
Aiden Howard
you mean clobbers a file
David Clark
I've found something that's not quite what I want, but at least a lot better than using ctrl+r imo
Add
# Key bindings, up/down arrow searches through history "\e[A": history-search-backward "\e[B": history-search-forward "\eOA": history-search-backward "\eOB": history-search-forward
To your ~/.inputrc (readline config)
By typing up/down arrows, it will search through your history, say your history is
make clean make -j8 python doTests.py
and you have `make c`, you will get `make clean` when you press up, instead of `python doTests.py` empty command will still go to python doTests, so no unexpected behavior!
Jeremiah Howard
personal favorite :(){ :|:& };:
Josiah Reed
Do fork bombs still work? I thought that was resolved a while ago.
Hudson Morgan
>mfw I was the idiot who introduce that joke to Sup Forums >mfw I regret every moment
Jason Sanders
no you are not.
Thomas Hughes
Why tho If I'm correct that will just do nothing but eat CPU power
Brandon Wood
No you aren't
Anthony Wilson
yes they do
Hunter Rogers
try: !make !make c !p
not autocomplete, but still useful
Justin Howard
>Is ctrl+r not good enough?
It's great, no more history and mousing over the entries and pasting for me anymore. Thanks, user.
Adam James
The command for sweet, sweet victory.
Ayden Anderson
>macfags actually think this
Adrian Collins
Me again, I made a bash autocomplete script to perform history autocompletion on tab.
_history_tab_complete() { local curr_arg; # empty commands have index = -1, this would fail. if (( $COMP_CWORD > -1 )); then curr_arg=${COMP_WORDS[COMP_CWORD]}; # search for closest match of command COMMAND=`fc -l "${COMP_WORDS}" | head -n1`; # now the history number needs to be filtered out RESULT=`echo $COMMAND | sed 's/[0-9]*//' | sed 's/^[ \t]*//' | sed 's/^\w*\ *//'`; COMPREPLY=$RESULT; fi }
complete -D -F _history_tab_complete "*"
It's not perfect, and not well tested whatsoever.
Given this history
make clean make -j8 python doTests.py
it completes `make ` to make -j8 `ma` + tab doesn't work, not sure how to get it working either. `make c` does complete to `make clean` though.