Thursday, February 20, 2014

Z Shell on Mac OS X


I'm a fairly recent newcomer to Mac OS X. Before this, I used a mix of Windows and Linux, but what attracted me to Mac OS X was the combination of a stable and well supported platform with a solid Unix foundation. I spend a lot of time working in the terminal, and having a Unix-like shell is very important to me.

I'm always looking for ways to make my time in the terminal more efficient, and that's why I've recently switched from the default Bash shell to the optional Z Shell. Making the switch is fairly straight forward. Open the System Preferences, and go into Users & Groups. You need to unlock the padlock, and then you can right click on your User (in the left column) and select Advanced Options...

On the Login Shell dropdown list, which should currently say "/bin/bash", select "/bin/zsh". Click OK and close the Preferences dialog box. Now, when you open a terminal window, it's be a Z Shell rather than a Bash shell.

If you have a custom ".bash_profile" file in your home directory, you should open it in your usual text editor and save it as ".zprofile". The syntax is almost identical; the only change I had to make was to my customised PS1 value, which configures how the terminal prompt looks.

Z Shell offers a number of improvements over Bash, such as tab completion, but I want to focus on a project called oh-my-zsh. This is a "community driven framework for managing your zsh configuration." Installing oh-my-zsh is easy, just paste this command into your terminal.

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

Once this is installed, you should close your terminal window.

oh-my-zsh creates a new file in your home directory called .zshrc for configuring the shell theme (colours, mostly) and for specifying which oh-my-zsh plugins to load. Open ~/.zshrc in your usual text editor. Reading the comments, you'll see a few configuration options, such as ZSH_THEME (I use a theme called "jtriley").

At the bottom of the file, you'll see that oh-my-zsh has copied the PATH value from Bash at the time it was installed. If you've created a custom .zprofile file, then you don't need this last line and you should delete or comment it out with a # character.

The really interesting line is the one that looks like this:

plugins=(git)

At the very least, you should add the plugin "osx", and if you use macports, there's a "macports" plugin too, so your plugins comfiguration would look like this:

plugins=(git osx macports)

Save the file and reopen terminal.

The main point of the plugins is that they provide useful short cuts for us in the terminal. For example, the macports plugin has a shortcut "pup" that runs "sudo port selfupdate" followed by "sudo port upgrade outdated". This means that simply typing the command "pup" updates the macports software and all the ports you have installed.

The osx plugin adds a few interesting integrations between the terminal and Finder. It starts with the command "pfd". Assuming you have a Finder window open somewhere, the command returns the path that is open in that window. While this isn't very useful on it's own, a number of other commands are built on top of it. For example, "cdf" (short for ch finder) will change the terminal to the directory open in the Finder window.

Another variant on this is "pushdf", which is built on the standard unix command "pushd". "pushd" and "popd" are used to maintain a stack of directories, so that you can quickly change between them without having to type the paths into a cd command or use more than one tab. "pushdf" pushes the Finder window's directory onto the "pushd" stack.

Lastly, have you ever been using the terminal and wanted to remove a file or directory but send it to the Trash Can rather than delete it completely? Now you can, without having to go into Finder. Simply enter the command "trash <file_or_directory>" and the offending file will be sent to the trash.

There's a wiki article on the github site listing some of the commands in the plugins, but it's actually really easy to read the source code in the github project and work out what new commands the plugins add. Each alias or function usually creates a new command, and they're all included in Z Shell's tab completion.

for git reference 
  https://github.com/robbyrussell/oh-my-zsh

Wednesday, February 5, 2014

Reset gitignore file

follow steps one by one


  
This removes everything from the index, then just run
git rm -r --cached . 

git add .
 
 
To untrack a file that has already been added/initialized to your 
repository, ie stop tracking the file but not delete it from your system
 use: git rm --cached filename 



Instead of .gitignore, you can update local git repository by running following command:
 
git update-index --assume-unchanged <file>
 
 
Put a / at the end of the directory name in your .gitignore file, i.e.
tmp/
If have tracked files inside that directory, you need to tell git to forget about them first (before you add the dir to the ignore list). Assuming you have nothing vital in there (i.e. that you can scratch it):
git rm -rf ./tmp/
git commit -m "untrack tmp dir"
mkdir tmp
echo tmp/ >> .gitignore
git add .gitignore ; git commit -m "add tmp/ to ignore list"
New files in that directory will not be tracked.
The --cached option to git rm only works on the index (pending changes more or less). It has no effect on the working tree or the status of what has been tracked or not.
 
 
git commit -m ".gitignore is now working"  

Tuesday, February 4, 2014

Un-install RVM, Ruby, Ruby gem and rails in Ubuntu 12.04

rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
 
 OR
 
 
You can use rm -rf ~/.rvm to remove RVM. 
If there is a separate version of ruby installed you'll need to 
sudo apt-get remove ruby1.x.x depending on the version 

Wednesday, January 22, 2014

Could not find rake-10.1.0 in any of the sources

If you are getting following error 
/home/username/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)

use following url
\curl -sSL https://get.rvm.io | bash
apt-get update
apt-get upgrade
apt-get install build-essential

rvm install ruby-1.9.3-p484
rvm ruby-1.9.3-p484@global --default --create
 
or just change your ruby version 
 

for mysql2 gem error on ubuntu 

sudo apt-get install zlib1g zlib1g-dbg zlib1g-dev sqlite3 libsqlite3-dev build-essential openssl libreadline6 libreadline6-dev curl git-core libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion g++ openjdk-6-jdk git nodejs 
sudo apt-get install libmysql-ruby libmysqlclient-dev

Tuesday, May 21, 2013

Install Ruby On Rails, MySql, GitHub, Nginx with Passenger

Install Ruby On Rails, MySql, GitHub, Nginx with Passenger

  • sudo apt-get install zlib1g zlib1g-dbg zlib1g-dev sqlite3 libsqlite3-dev build-essential openssl libreadline6 libreadline6-dev curl git-core libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion g++ openjdk-6-jdk git nodejs
  • curl -L https://get.rvm.io | bash -s stable --ruby

    # edit .bash_profile file and add following file then press Ctrl-D if you are # using cat
  • cat >>~/.bash_profile
  • [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" 
  • Ctrl+D 

  • rvm install 1.9.3
  • rvm use 1.9.3
  • rvm rubygems latest
  • sudo gem install rails '3.2.9'
  • sudo apt-get install mysql-client-5.5 mysql-server-5.5
  • sudo apt-get -y install postgresql libpq-dev
  • sudo service mysql stop 
  • sudo service mysql start
MySql Gems
  • sudo gem install mysql2
  • sudo gem install therubyracer

Installation of Git
  • sudo apt-get install git
  • sudo apt-get update
  • which git
  • sudo apt-get install git-core
  • which git
  • /usr/bin/git
  • git --version
  • git version 1.7.0.4

    Git Configuration
  • sudo nano ~/.gitconfig
  • git config --global user.name "NewUser"
  • git config --global user.email newuser@example.com
  • git config –list
Installation of Nginx
Update and install our dependencies
  • sudo apt-get -y update

  • sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev curl git-core python-software-properties
  • gem install passenger
  • rvmsudo passenger-install-nginx-module

    # Choose "download, compile, and install Nginx for me"

         # Accept defaults for any other questions it asks you
Next we want to setup a script to allow us to control Nginx
  • wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh

  • sudo mv init-deb.sh /etc/init.d/nginx

  • sudo chmod +x /etc/init.d/nginx

  • sudo /usr/sbin/update-rc.d -f nginx defaults
You can now control Nginx with this script. To start and stop the server manually, you run:
  • sudo /etc/init.d/nginx stop
  • sudo /etc/init.d/nginx start
    We can verify nginx is running by opening up Firefox and going to http://localhost
Node.js for the Rails asset pipeline
  • sudo apt-add-repository ppa:chris-lea/node.js

  • sudo apt-get -y update

  • sudo apt-get -y install nodejs
Configure Your Rails App
you can modify your /opt/nginx/conf/nginx.conf
server {

    listen 80;

    server_name example.com;

    root /home/deploy/myapplication/public;   # <--- be sure to point to 'public'!

    passenger_enabled on;

}

Just change the application folder name and the server name and then restart the nginx service.
http://www.kosmetikstudio-hamburg.net http://www.howtoaddlikebutton.com