Adding Emojis to OSX terminal

If you have to ssh to work and have the local system and get confused every now and then. Then you might add some visual indicators in the bash shell so you can easily spot where you are!

1. Open your .bash_profile and add the following line.

PS1="\h ¬†ūüćÄ ¬†\W "

To Open emoji’s in Mac, you need to go to ‘Edit’ > ‘Emojis & Symbols’ and add your desired emoji. Be it in twitter, notes or anywhere this is the way to do in a Mac.

2. Save the bash_profile file,

3. Reopen terminal and BOOM!

Note: while Adding PS1=” ” remember that you shouldn’t have a space between = and “.

This artical was inspired by one of Ruby programmers having vidcast. And idea is borrowed from http://itsras.blogspot.com/2013/04/os-x-daily-customize-command-line-by.html

Let me know what other emoji’s you like the most to have them on terminal.

Cheers!

Commandline tricks

Installing ‘ll’ in mac osx:

Sometimes you will notice¬†that the ‘ll’ command is not found in MAC OSX. To enable it do something like this:

alias ll='ls -lG'

Bingo!

http://unix.stackexchange.com/a/28426/97013

Know more about Running Processes and killing them in Unix:

https://www.digitalocean.com/community/tutorials/how-to-use-ps-kill-and-nice-to-manage-processes-in-linux

To see all the processes on the system:

ps -af

ps -af | more

You can also search for particular sorts of process using the grep command.¬†grep searches for a given string of characters within a file. If you “pipe” the output from ps into grep it will search for a string and only display those lines on which the string occurs.

ps -af | grep pine

To get a list of the current environment variables and their values

env

https://www.st-andrews.ac.uk/ITS/training/unix/unix7.html


If I know the PID number of a process, how can I get its name?

On all POSIX-compliant systems, and with Linux, you can use ps:

ps -p 1337 -o comm=

Here, the process is selected by its PID with -p. The -o option specifies the output format, comm meaning the command name.

http://superuser.com/a/632987/314977

http://pubs.opengroup.org/onlinepubs/009696799/utilities/ps.html

http://pubs.opengroup.org/onlinepubs/9699919799/

ProTip: Creating a code snippet in Sublime Text 2/3

I wanted to use the code snippets for the erb files and in erb files the most common snippet you would wish for is:

<%=

%>

So I wanted to create a snippet that would do it for me and be sure of the ending %> So that I don’t really have to cross check every time I write it.

To create a snippet in Sublime Text

  1. Go to Tools > select ‘New Snippet’
  2. You would have a sample template something like this:
    <snippet>
    <content><![CDATA[
    Hello, ${1:this} is a ${2:snippet}.
    ]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <!-- <tabTrigger>hello</tabTrigger> -->
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
    </snippet>
  3. So edit the default template to:
    <snippet>
    <content><![CDATA[
    <%= $0
    
    %>
    
    ]]></content>
    <tabTrigger>erb</tabTrigger>
    </snippet>
    
  4. The content for which you want to template should go in between [[ ]] tags.

    And $0 is the place the cursor will be when this snippet is invoked.

    And to trigger the snippet you need to use <tabTrigger> tag, where you give a name to your snippet.

  5. Save the above created snippet in the Packages/User/ folder with the name <your-snippet-name>.sublime-snippet
  6. Close Sublime and Open it again and try your snippet. Voila!( In ST3 you don’t have to close Sublime, it picks up for you in a new tab.)

Installing TMUX.

This post outlines the way to install tmux in Mac OSX

Disclaimer: At the time of writing this article I have just gone as far as installing tmux and thats it!

    1. If you want to install tmux you can do that by downloading it at this link: http://tmux.github.io/
    2. You have to read the README doc which tells how to install it.
      tmux depends on libevent 2.x. Download it from:
      
      	http://www.monkey.org/~provos/libevent/

      libevent site seemed hard to parse and I couldn’t get a way to install it after downloading the project.

    3. So in order to install libevent:
      1. cd to the libevent project folder
      2. Run ./configure && make
      3. Run sudo make install

      http://cloudspace.com/blog/2009/01/13/installing-libevent-on-mac-osx/

    4. Now install tmux as told in README
      $ ./configure && make
      $ sudo make install
    5. …. and may be you are done.

Installing TMUX using homebrew:

I did it this way coz I found brew was more easier to do

      1. $ brew update and $ brew doctor
      2. Install libevent first:
        $ brew install libevent You will be prompted to link libevent after installing, do that if so
      3. Then install tmux:
        $ brew install libevent
      4. If you get the permissions error saying /usr/local is not writable do change the persmissions:
        sudo chmod -R g+w /usr/local
        http://stackoverflow.com/a/12748803/981616
      5. Then install tmux
        $ brew install tmux

To learn about tmux and its shortcuts visit this page: https://gist.github.com/MohamedAlaa/2961058

A tmux Primer