commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
Here is the full function (got trunctated), which is much better and works for multiple queries.
function cmdfu () {
local t=~/cmdfu;
until [[ -z $1 ]]; do
echo -e "\n# $1 {{{1" >> $t;
curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext" | sed '1,2d;s/^#.*/& {{{2/g' | tee -a $t > $t.c;
sed -i "s/^# $1 {/# $1 - `grep -c '^#' $t.c` {/" $t;
shift;
done;
vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t;
rm $t $t.c
}
Searches commandlinefu for single/multiple queries and displays syntax-highlighted, folded, and numbered results in vim.
Multi-argument version, but with VIM loveliness :D
you should choose proper color to make comments invisible.
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) )
This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
Open a CLI file explorer by splitting up your screen inside your vim session.
Besides, you probably are never going to forget this one.
Calls sudo tee like all the other lines, but also automatically reloads the file.
Optionally you can add
command Wq :execute ':W' | :q
and
command WQ :Wq
to make quitting easier
probably just like 1204, but uses tee as a filter (+ I actually understand how this one works)
1. Get name of task by task=$(basename "$(pwd)")
2. Check whether "$task.c" exists as a file
3. open "$task.c", "$task.in", "task.out" in vim with such layout.
-------------------------------
| | $task.in |
| | |
|$task.c |-----------------|
| | $task.out |
| | |
-------------------------------
In this case, we'll be editing every PHP file from the current location down the tree.
You can show all the files in the vim buffer with :buffers which outputs something like,
:buffers
1 %a "./config/config.php" line 1
2 "./lib/ws-php-library.php" line 0
3 "./lib/css.php" line 0
4 "./lib/mysqldb.class.php" line 0
5 "./lib/config.class.php" line 0
6 "./lib/actions.php" line 0
Press ENTER or type command to continue
If you'd like to edit ./lib/mysqldb.class.php for example, enter :b4 anytime you're editing a file. You can switch back and forth.
The sample command searches for PHP files replacing tabs with spaces.
-u NONE # don't use vimrc
Instead of
retab!
one may pass
retab! 4
for instance.
Look at this http://susepaste.org/69028693 also
This will skip all initializations. Especially useful when your ~/.vimrc has something wrong.
in command mode, navigate your cursor to the line where you want the command output to appear, and hit "!!". No need to enter edit mode or even type a ":" (colon).
I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.
usage:
:[rang]ret[!][tabstop value]
python is indent sensitive, after command
:set list
you may see your codes are mixed with tab and space
ret can help you to convert space to tab or tab to space