Command Line Tools
I use autojump myself and I also depend on many aliases for navigating at the command line, e.g.:
alias b='cd -'
alias c='cd ~/Dropbox/95_2014/work/code'
alias d='~/Dropbox'
alias lnk='cd ~/Dropnot/webs/rails_apps/linker'
alias n='cd ~/Dropnot'
alias play='cd ~/play/'
alias q='cd ~/Dropbox/95_2014/work/code/ruby__rails/ruby/ruby_quiz'
alias s='cd ~/Dropnot/setups'
alias w='cd ~/Dropnot/webs'
alias work='cd ~/Dropbox/95_2014/work'
I keep these and all my other aliases in a ~/.bash_aliases file and include it with
test -f ~/.bash_aliases && . $_
in my .bashrc
file.
For my autojump installation I have this line in my .bashrc
test -s ~/.autojump/etc/profile.d/autojump.sh && . $_
which maintains the portability of my .bashrc
dot file as it allows me to have that line even on a new machine without autojump installed without error.
Organization
For the actual organization, I use:
~/Dropbox # stuff for the future / elsewhere, maintained by Dropbox
~/Dropnot # stuff for git, not Dropbox, i.e. sites and apps
~/Dropbox/95_2014 # My 'year' approach to archiving old stuff every year
~/Dropbox/95_2014/work # All my work stuff which is most of it.
~/Dropbox/95_2014/life # All my non-work, personal and private stuff
I also use:
~/tmp # as a scratchpad directory for files I don't care about.
~/setups # for a cloned github repo with my dotfiles.
and the folllowing system directories
~/Downloads
~/Desktop
~/Pictures
for quick usage, e.g. screenshots, downloads, etc.
Other tools:
I've also set autocd
which allow you to type a directory name and be cd'd into it if it exists (ok in Ubuntu but in OSX I had to upgrade my bash version from 3 to 4. The line that invokes it is:
[ ${BASH_VERSINFO[0]} -ge 4 ] && shopt -s autocd
I also find it helpful to have directory info in my PS1
prompt to show me the top three (current) directories and the bottom two, plus time, name machine and git branch, as in
which I achieve by having the following in my .bashrc
git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; }
HOST='\033[02;36m\]\h'; HOST=' '$HOST
TIME='\033[01;31m\]\t \033[01;32m\]'
LOCATION=' \033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`'
BRANCH=' \033[00;33m\]$(git_branch)\[\033[00m\]\n\$ '
PS1=$TIME$USER$HOST$LOCATION$BRANCH
Note the carriage return so that the long PS1 prompt doesn't push the cursor way over to the right.
Bookmarks from Nautilus
I like these in nautilus but avoid accessing or using them at the command line. I don't want to have to deal with the syncing issue that might involve; I use OSX (as well as Ubuntu) and it wouldn't be of use there; the above strategy of aliases at the command line serves me better; I only like 6-12 bookmarks in the gui side panel anyway so that's not hard to just create on the fly (<1 minute one-time task).
However when commands are being run, a copy of their files from the hard disk is put into the RAM,
This is wrong (in general). When a program is executed (thru execve(2)...) the process (running that program) is changing its virtual address space and the kernel is reconfiguring the MMU for that purpose. Read also about virtual memory. Notice that application programs can change their virtual address space using mmap(2) & munmap
& mprotect(2), also used by the dynamic linker (see ld-linux(8)). See also madvise(2) & posix_fadvise(2) & mlock(2).
Future page faults will be processed by the kernel to load (lazily) pages from the executable file. Read also about thrashing.
The kernel maintains a large page cache. Read also about copy-on-write. See also readahead(2).
OK, so what I wonder about is if the double life of a command, one on the hard disk, the other in the RAM is also true for other kind of files, for instance those who have no logic programmed, but are simply containers for data.
For system calls like read(2) & write(2) the page cache is also used. If the data to be read is sitting in it, no disk IO will be done. If disk IO is needed, the read data would be very likely put in the page cache.
So, in practice, if you run the same command twice, it could happen that no physical I/O is done to the disk on the second time (if you have an old rotating hard disk - not an SSD - you might hear that; or observe carefully your hard disk LED).
I recommend reading a book like Operating Systems : Three Easy Pieces (freely downloadable, one PDF file per chapter) which explains all this.
See also Linux Ate My RAM and run commands like xosview
, top
, htop
or cat /proc/self/maps
or cat /proc/$$/maps
(see proc(5)).
PS. I am focusing on Linux, but other OSes also have virtual memory and page cache.
Best Answer
Put this in your
.vimrc
(usually located at~/.vimrc
):