Posts Tagged Bash
Changing Directories More Easily
Here is something I have in my Bash config that I have found useful these days. It defines a command called up that lets me move up a given number of directories. For example, up 2 is the same as cd ../.., and up 4 is cd ../../../.., and so on. function up() { cd $(perl -e 'print join("/" => ("..") x shift)' $1) } I found this somewhere online, so I am not taking credit for it. The way this works is we use Perl to create the string ../../.., or however many dots and slashes we need to reach the right parent directory. We can create that string to go up three directories by using the code ("..") x 3 to create the list (".." ".." "..") We then use join to insert a slash between each set of dots. This gives us code very close ...
Easy Documentation for Git, MySQL, PHP, et cetera
This is what I do on my box to quickly find documentation, which you guys may find helpful. Especially those of you on Linux---although you could do this on Windows too. Most package managers make available '-doc' packages, like php-doc, mysql-doc, and so on. Install these for all the major software you use. Next, install 'screen'. Now put this is your Bash config: # Displays various types of documentation. function doc() { case "$1" in 'llvm') screen -t 'LLVM Documentation' w3m /usr/share/doc/llvm-doc/html/index.html ;; 'erlang') screen -t 'Erlang Documentation' firefox /usr/share/doc/erlang-doc-html/html/doc/index.html ;; 'python') screen -t 'Python Documentation' w3m /usr/share/doc/python3-doc/html/index.html ;; 'php') screen -t 'PHP Documentation' w3m /usr/share/doc/php-doc/html/index.html ;; 'ghc') firefox /usr/share/doc/ghc6-doc/index.html & ;; 'postgresql') screen -t 'PostgreSQL Documentation' w3m /usr/share/doc/postgresql-doc-8.4/html/index.html ;; 'mysql') screen -t 'MySQL Documentation' w3m /usr/share/doc/mysql-doc-5.0/refman-5.0-en.html-chapter/index.html ;; 'apache') screen -t 'Apache Documentation' w3m /usr/share/doc/apache2-doc/manual/index.html ;; 'j') screen -t 'J Documentation' w3m ~/Software/j602/help/index.htm ;; 'lua') screen -t 'Lua Documentation' w3m /usr/share/doc/lua5.1-doc/doc/index.html ;; 'git') ...
