You can even go meta and install a command to let you search commandlinefu [2].
[0] http://news.ycombinator.com/item?id=527486
I've been using this for a while, and trust me, its changed my command line workflow, and I wish, this should come as inbuilt for all POSIX shells!
Here is how it works -
If you use your shell to navigate and launch applications, fasd can help you do it more efficiently. With fasd, you can open files regardless of which directory you are in. Just with a few key strings, fasd can find a "frecent" file or directory and open it with command you specify. Below are some hypothetical situations, where you can type in the command on the left and fasd will "expand" your command into the right side. Pretty magic, huh?
v def conf => vim /some/awkward/path/to/type/default.conf
j abc => cd /hell/of/a/awkward/path/to/get/to/abcdef
m movie => mplayer /whatever/whatever/whatever/awesome_movie.mp4
o eng paper => xdg-open /you/dont/remember/where/english_paper.pdf
vim `f rc lo` => vim /etc/rc.local
vim `f rc conf` => vim /etc/rc.conf
Fasd offers quick access to files and directories for POSIX shells. It is inspired by tools like autojump, z and v. Fasd keeps track of files and directories you have accessed, so that you can quickly reference them in the command line.The name fasd comes from the default suggested aliases f(files), a(files/directories), s(show/search/select), d(directories).
Fasd ranks files and directories by "frecency," that is, by both "frequency" and "recency." The term "frecency" was first coined by Mozilla and used in Firefox.
Here is the Link - https://github.com/clvv/fasd
Anyway, I'm a big fan of piping things into xargs. xxd is a terminal-based hex editor. It can convert both to and from hex to binary. I also use 'pgrep -lf 'partial_program_name' a lot in place of 'ps aux | grep partial_program_name'. 'pkill -9 partial_program_name' searches for and kills all processes matching the string.
I run an iodine server for myself, you can get free Internet at quite a few loginpage WiFi routers with it in airports, cafes etc.
Could it turn your old android device into an HTTP tunnel?
You can use this within Vim to pretty-format text tables, initialization of variables, etc. Just highlight the lines in question in visual line mode (V) and type
!column -t<CR>
to pipe the lines through the column command.Does anyone know if there's a key command for clearing the scroll buffer?
Ctrl+D for quick logout too.
cls <enter> clear<enter>
lol.
I see Cmd + K on the menu now, but I guess I wasn't curious enough to poke around. Thanks a bunch.
always worth looking at these types of lists imo, whilst some of the commands mightn't really fit into your workflow or seem useful immediately, they're often exactly the snippets of information that can save hours at a later stage..
function lc() { if [[ "$#" -gt 1 ]]; then for DIR in "$@"; do echo -n "$DIR - " ; ls -AU1 $DIR | wc -l ; done ; else ls -AU1 "$@" | wc -l ; fi; }
So, "lc /dir" will count the number of files in /dir and "lc /dir/*" will count the files in subdirectories of /dir. This is useful if you're working in an environment where you may have thousands of files in a directory, and a regular "ls -l" will lock your terminal while it eats your entire scrollback buffer.
less -F
Won't page if less than one screenful. zsh users can also do: < filename
(less than character)> lc /dir" will count the number of files in /dir
find /dir -type f -maxdepth 1 | wc -l
> and "lc /dir/*" will count the files in subdirectories of /dir. find /dir -type f -mindepth 2 | wc -l grep -rs
or (more commonly for me):- grep -rsi
(The -s supresses errors about unreadable files that may clutter the output. -i for case insensitivity.)findstr /SPINC:"some random debug message" *
Will do the same. FINDSTR is no grep, but for very simple cases like this is just fine
SPINC and SPIMC are my favorite options...
1. Ctrl+p. Go to the previous line in bash history.
2. Ctrl+a. Go to the beginning of the new line.
3. Type "sudo ". While you're typing your whole commandline shifts around as well.
The latter mixes history commands, navigation commands and also modifies a previous command instead of just typing a new 7-letter command. It's also more in terms of keystrokes (though just barely).
| sort | uniq -c | sort -n -r | head
to get a nice top 10 whatevers in the whoosithttps://www.google.de/search?q=byobu+tmux&tbm=isch
It's a fancy statusbar that shows CPU speed, IP-address, hostname, ...
Screenshot: http://i.imgur.com/u6JY0.png
Config file: https://github.com/tylerkahn/dotfiles/blob/master/.tmux.conf...
Works with OSX and Linux.
: Just use it in :
: vi with your cursor in front of a badly wrapped block of text. :
: Press !}par<enter> and the text will be :
: piped to par :
: which fixes up :
: the :
: formatting and keeps aligned frame markers :
: intact magically. :
: Just use it in vi with your cursor in front of a badly wrapped :
: block of text. Press !}par<enter> and the text will be piped :
: to par which fixes up the formatting and keeps aligned frame :
: markers intact magically. :
http://www.nicemice.net/par/ (or apt-get install par) export CDPATH=.:~/projects
export PS1="$(uname -n)$ "
alias ltr='ls -ltr'
More of a procedure, always list file and edit the command before deleting it: $ ll file.txt
-rw-r--r-- 1 zera staff 0 Jan 7 20:28 file.txt
Ctrl-p, Ctrl-a, Ctrl-d, Ctrl-d, r,m
$ rm file.txt
So this is a sanity check to avoid this mistake: $ rm *.txt
*Edit, one more:Ensure you overwrite a file (or aren't):
$ cp -i ~/file.config /etc/ alias lsd="ls -ltrF | grep ^d"
Helps me quickly list only directories. Any better alternatives ? find . -type d
edit: for the same output as your command you can use: dir -l alias lsd='ls -d */'I know, it's a bad habit
slless. Overkill, but SO MUCH BETTER THAN tail -f. Seriously. You can toggle "follow mode" without losing your place in the incoming stream.
If you do this on my servers, I am going to find you, and then I am going to kill... um... your process.
less with SHIFT-F takes a whole CPU core to run on a busy log file. tail -f takes almost nothing to run. Now combine that information with the reality of a whole bunch of devs who don't know it or don't care about it. :(
tail --follow=filename
to: tail -f filename
The former will spot inode changes and reopen the filename if the file wraps (or has something else done to it to change its inode). The latter will just sit there seeing no new input in such cases.zsh's file globbing is awesome. Some simple ones:
*(.) - only files
*(/) - only dirs
*(.m0) - files modified today
*(.om[1,15]) - 15 recently modified filesThis is useful for creating a connection for receiving the input of what you get...
e.g. running
faucet 80 --in cat
and later
curl http://127.0.0.1:80
will deliver to you console :
GET / HTTP/1.1 User-Agent: curl/7.21.4 (i686-pc-linux-gnu) libcurl/7.21.4 OpenSSL/0.9.8n zlib/1.2.5 libidn/1.19 Host: 127.0.0.1:900 Accept: /
Faucet is part of "netpipes", which is available for most Unixoid operating systems. I guess it was inspiration to build "netcat". But netcat was a absolute terrible hack of a program, so "socat" (socket-cat?) was born.
http://www.dest-unreach.org/socat/
In case you need the functionality of bash's /dev/tcp [1] and you are pondering to install netcat or netpipes, do yourself a favor and just go for socat, it's insanely more powerful, read the manpage, read the examples!
http://www.dest-unreach.org/socat/doc/socat.html#EXAMPLES
--
[1] but debian and ubuntu have decided to compile without it... https://bugs.launchpad.net/ubuntu/+source/bash/+bug/215034
netcat -l -p 80alias easy_search="curl -s http://pypi.python.org/simple/ | perl -ne 'print if s/<[^>]+>//g && $.>1'|grep"
(http://www.unixhub.com/docs/hpux/hpux_boot.html)
I wish I still had that machine, but I do not.
!sudo tee %
alias unbz2='tar xvjf' alias untar='tar xvfz'
It provides a few commands, two of which I use the most:
als - list files in an archive
aunpack - exatract files from an archive
The best part is aunpack extracts files into a subdirectory (I hate polluting the current directory with files from a new archive which wasn't properly packaged to include a directory), and it does it only when necessary. Before I found it, I always used to create a temp directory, cd to it, unpack into it, and possibly move files around etc.When creating the archive, you still have to use your favorite compression method (XZ aka LZMA, activated with J is even better, but slightly slower, than bzip).
If you'd do that for / , your own system would start behaving, like a system booted from LiveCD. And, after reboot, would return to the origanal state.
Overlayfs is pretty cool actually. Allows you to overlay a lower directory with some other upper directory and mount the result somewhere. All the changes that you are making in the mounted directory would be visible to you, and would be stored in the upper directory.
In the example above, after running this command, content of your $HOME would stop changing. But you still will be able to change it, with all the changed content going into tmpHome.
ctrl-\, kills current process even xtail
xtail, tails dirs
tweaks in .inputrc to have up and down arrow do backward history search, like in ipython.
Instant favorite
$ rm -rf somedir
rm: somedir/: Permission denied
$ fucking !! $ file foo
$ ls -lh !$
$ vim !$$ find . -name \*~ -delete
This lets me cd five directories at a time, and if I want to go back, I do a "popd"