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
>>55175096
alt+# will comment the line you are typing.
>>55175096
Bump. I like this kind of thread
>>55175287
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.
>>55175204
Nice, thanks.
I like $_ for discovering the full argument stream passed to the previous command:mkdir foo && cd $_
use this if u dont want to be completely blind at 80
redshift -t 3650:3650 -l 90:15
xman
you can thank me later
>>55175096chsh -s /bin/zsh
^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.
>>55175096dd if=/dev/zero of=/dev/null bs=500M count=1
>>55175758
Holy fuck that is glorious
>>55175758
Oh shit nice
touch a file without invoking a fork()> newfile
ctrl+l clears the current line, so much better than writing clear all the time.
echo $?
Gives you the exit code of the last thing that ran in the shell
Does anybody know how to get reasonable autocomplete from history features?
If my past three commands look like thismake 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
>not zsh
Mostly GNU Readline
ctrl + d: close terminal
ctrl + c: cancel operation
also the most basic text editor evercat > newfile
then type "ctrl + d" to close it
>>55177126
Is ctrl+r not good enough?
>>55177164
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
>>55177075
you mean clobbers a file
>>55177188
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 ismake 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!
>>55175096
personal favorite:(){ :|:& };:
>>55177708
Do fork bombs still work? I thought that was resolved a while ago.
>>55177708
>mfw I was the idiot who introduce that joke to /g/
>mfw I regret every moment
>>55177762
no you are not.
>>55176833
Why tho
If I'm correct that will just do nothing but eat CPU power
>>55177762
No you aren't
>>55177760
yes they do
>>55177126
try:
!make
!make c
!p
not autocomplete, but still useful
>>55177164
>Is ctrl+r not good enough?
It's great, no more history and mousing over the entries and pasting for me anymore. Thanks, anon.
>>55175757
The command for sweet, sweet victory.
>>55178158
>macfags actually think this
>>55177438
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 historymake 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.
Progress!