if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Friday, July 1, 2011
Fix Terminal in OSX not sourcing .bashrc
Bash in OSX looks for ~/.profile rather than ~/.bashrc so just create the former and add the following.
Sunday, March 7, 2010
Running ruby scripts as cron jobs in rvm environment
# This will fail to run properly
*/5 * * * * /usr/bin/env ruby /home/username/twitter.rb
# Need to run the script in full bash environment
*/5 * * * * bash -c 'source /home/username/.rvm/scripts/rvm && /usr/bin/env ruby /home/username/twitter.rb'
Sunday, October 18, 2009
Deleting a word backwards in Bash and Vim
# To delete one word back
CTRL + w
# To paste deleted word
CTRL + y
Friday, September 18, 2009
List of bash shortcuts
Taken from the following article
http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/
* Ctrl + a – go to the start of the command line
* Ctrl + e – go to the end of the command line
* Ctrl + k – delete from cursor to the end of the command line
* Ctrl + u – delete from cursor to the start of the command line
* Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
* Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
* Ctrl + xx – move between start of command line and current cursor position (and back again)
* Alt + b – move backward one word (or go to start of word the cursor is currently on)
* Alt + f – move forward one word (or go to end of word the cursor is currently on)
* Alt + d – delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
* Alt + c – capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
* Alt + u – make uppercase from cursor to end of word
* Alt + l – make lowercase from cursor to end of word
* Alt + t – swap current word with previous
* Ctrl + f – move forward one character
* Ctrl + b – move backward one character
* Ctrl + d – delete character under the cursor
* Ctrl + h – delete character before the cursor
* Ctrl + t – swap character under cursor with the previous one
* Ctrl + ] - search forward for character
* Ctrl + Alt + ] - search backwards for character
Command Recall Shortcuts
* Ctrl + r – search the history backwards
* Ctrl + g – escape from history searching mode
* Ctrl + p – previous command in history (i.e. walk back through the command history)
* Ctrl + n – next command in history (i.e. walk forward through the command history)
* Alt + . – use the last word of the previous command
Command Control Shortcuts
* Ctrl + l – clear the screen
* Ctrl + s – stops the output to the screen (for long running verbose command)
* Ctrl + q – allow output to the screen (if previously stopped using command above)
* Ctrl + c – terminate the command
* Ctrl + z – suspend/stop the command
Bash Bang (!) Commands
Bash also has some handy features that use the ! (bang) to allow you to do some funky stuff with bash commands.
* !! - run last command
* !blah – run the most recent command that starts with ‘blah’ (e.g. !ls)
* !blah:p – print out the command that !blah would run (also adds it as the latest command in the command history)
* !$ – the last word of the previous command (same as Alt + .)
* !$:p – print out the word that !$ would substitute
* !* – the previous command except for the last word (e.g. if you type ‘find some_file.txt /‘, then !* would give you ‘find some_file.txt‘)
* !*:p – print out what !* would substitute
http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/
* Ctrl + a – go to the start of the command line
* Ctrl + e – go to the end of the command line
* Ctrl + k – delete from cursor to the end of the command line
* Ctrl + u – delete from cursor to the start of the command line
* Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
* Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
* Ctrl + xx – move between start of command line and current cursor position (and back again)
* Alt + b – move backward one word (or go to start of word the cursor is currently on)
* Alt + f – move forward one word (or go to end of word the cursor is currently on)
* Alt + d – delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
* Alt + c – capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
* Alt + u – make uppercase from cursor to end of word
* Alt + l – make lowercase from cursor to end of word
* Alt + t – swap current word with previous
* Ctrl + f – move forward one character
* Ctrl + b – move backward one character
* Ctrl + d – delete character under the cursor
* Ctrl + h – delete character before the cursor
* Ctrl + t – swap character under cursor with the previous one
* Ctrl + ] - search forward for character
* Ctrl + Alt + ] - search backwards for character
Command Recall Shortcuts
* Ctrl + r – search the history backwards
* Ctrl + g – escape from history searching mode
* Ctrl + p – previous command in history (i.e. walk back through the command history)
* Ctrl + n – next command in history (i.e. walk forward through the command history)
* Alt + . – use the last word of the previous command
Command Control Shortcuts
* Ctrl + l – clear the screen
* Ctrl + s – stops the output to the screen (for long running verbose command)
* Ctrl + q – allow output to the screen (if previously stopped using command above)
* Ctrl + c – terminate the command
* Ctrl + z – suspend/stop the command
Bash Bang (!) Commands
Bash also has some handy features that use the ! (bang) to allow you to do some funky stuff with bash commands.
* !! - run last command
* !blah – run the most recent command that starts with ‘blah’ (e.g. !ls)
* !blah:p – print out the command that !blah would run (also adds it as the latest command in the command history)
* !$ – the last word of the previous command (same as Alt + .)
* !$:p – print out the word that !$ would substitute
* !* – the previous command except for the last word (e.g. if you type ‘find some_file.txt /‘, then !* would give you ‘find some_file.txt‘)
* !*:p – print out what !* would substitute
Wednesday, July 29, 2009
Host your configuration files on github
My .vimrc and .bashrc is pretty highly customized. As such it doesn't make sense for me to rewrite them on my various machines (laptop + netbook + pc). Even copy and pasting them ain't no fun.
The solution is to host a master copy of these files online. Github is great for that. It offers a free repository that allows you to version your files using git. So I've created a github repository for my config files.
So now that's left is to symlink the actual config files to my local repository.
So I can do git clone and symlink these config files on my other machines. Best way to synchronize my files and versioning thrown in too!
The solution is to host a master copy of these files online. Github is great for that. It offers a free repository that allows you to version your files using git. So I've created a github repository for my config files.
cd ~/apps
mkdir config-files
cd config-files
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:jasonong/config-files.git
git push origin master
cp ~/.bashrc .
cp ~/.vimrc .
git add .
git commit -m 'Added bash and vim config files'
git push origin master
So now that's left is to symlink the actual config files to my local repository.
cd ~
ln -s apps/config-files/.bashrc .bashrc
ln -s apps/config-files/.vimrc .vimrc
So I can do git clone and symlink these config files on my other machines. Best way to synchronize my files and versioning thrown in too!
Subscribe to:
Posts (Atom)