webdevRefinery Forum: Oh My ZSH will change your life. - webdevRefinery Forum

Jump to content

  • 4 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 30 April 2012 - 07:52 AM (#1)

Oh My ZSH will change your life.


Last week a coworker of mine really bugged me. She's all "This is so annoying. I type a 'curl' command and the response is on the same line as the next prompt." If you're not familiar with this annoyance, it looks like this (forgive the URL obfuscation):
Posted Image

My response was "Yeah, most webservices don't flush with a newline. You either have to deal with it or wrap a script around it or something." Then I realized that response was bullshit. Bash is a tool, and if the tool is annoying, you should find another tool. It's a computer. "Deal with it" is a crap response. So, I started digging over the weekend, looking for something better than Bash without a hugely steep learning curve. If you're not familiar with Bash (Bourne-Again SHell), then it's what you're using right now on your non-windows machine to interact with your command line. There are other shells, but Bash is the default on most all of them.

And it blows. Well, at least version 3 blows. Apparently version 4 is marginally better, but I'm not interested. ZSH is amazing, AND it uses the same syntax as Bash, adding lots more to it. And before I launch into why you should switch, let me just throw you a screenshot:

Posted Image

I put this prompt together over the weekend. It's worth noting, here, that you can coerce Bash to have a prompt similar to that, but not only is it easier in ZSH, there are other features we'll be getting to :).

So what you see up there is, first, a blank line (yes, it takes up space, but makes the separation of commands wonderfully obvious). On the next line, you have your username and hostname, and in this case my hostname is yellow to draw attention to the fact that I'm SSHed into a remote machine. Then the path, which is nothing special, then PURE FREAKING AWESOMENESS: The SHA of the HEAD of the git repo I'm in, the branch I'm in, and a little indicator that tells me if I have uncommitted changes. And if I'm on a branch that I'm tracking on a remote repo (like github) there would be a little yellow lightning bolt whenever I have committed changes I haven't pushed. ...And then the time, which is great when you're looking back through old commands.

Line 2, that arrow turns red when I'm root.
Posted Image

And that's just my own custom theme. There are a million more if you prefer a one-line prompt, or a different look and feel. Check some out here if you're interested.

What other cool shit do I have? Here's a list. Again, yes, Bash can be coerced to do some of these things, but in most cases ZSH can do this right out of the box or with a simple config switch:
  • You know how you can hit <tab><tab> in Bash to see all the possible completions? ZSH gives you a list you can navigate with arrow keys:
    Posted Image
  • Press the up arrow to go back through your command line history. Big whoop, right? Now type 'ssh' and press the up arrow, and navigate through your history of commands starting with 'ssh'. That works with anything.
  • Type a super long command. Realize you need to go back to the beginning. Don't you dare hold down the left arrow key for 5 minutes. Instead, realize you're using fucking VI. Hit ESC, and now you're in command mode. Capitol 'I', and now you're inserting at the beginning of the string. Hit slash and you can search for a substring and jump to it. It's VI. Use it to edit your command.
  • Ever try to run a command from your history and realize you're boned because you ran that command in a different terminal session? ZSH shares history among sessions. This is no longer an issue.
  • Built-in pagination. Type < then a filename and bam, easy reading. Sure, you could do
    cat filename | less
    , but save yourself the keystrokes!
  • That issue above with the output ending up on the same line as the next prompt? Thing of the past. ZSH detects that and throws an inverted % after the output to let you know there was no newline. Then it puts in a newline.
  • So, so much more stuff, but I'm sick of listing it.


So here's what up. This dude decided it would be cool to build a theme and plugin framework around ZSH. He calls it Oh My ZSH. It's awesome, and will make your zsh life so much easier. Install it by running this at your Bash prompt:
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh


Now edit ~/.zshrc to choose your theme and add plugins. I'm especially fond of 'nyan'. But definitely, definitely add 'git' if you use git. There are a million other useful ones too.

Enjoy :)
7


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 748
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 30 April 2012 - 08:01 AM (#2)

:o :o :o

That is so cool! :D :D

Just a question, (being a sort of noob at how command lines works), but would I need to install this on a machine im SSHing into to use it, or only on the connecting machine?

And would it work on windows (putty)? I suspect not...or could I install it on my server, and get this functionality after SSHing in with Putty?

Anyway, those features look absolutely amazing...and all this time I thought Bash was a programming language, and that the "shell" was the only one there was....and here you go! :P
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2862
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 30 April 2012 - 08:05 AM (#3)

Looks awesome, I'll try it out later :-)

Bash supports vim emulation natively, but it isn't very good.

Quote

The SHA of the HEAD of the git repo I'm in, the branch I'm in, and a little indicator that tells me if I have uncommitted changes.

That's all possible in bash, I believe lemon did it a while back and shared his script on IRC (dunno which network, though).

View PostTheMaster, on 30 April 2012 - 08:01 AM, said:

:o :o :o

That is so cool! :D :D

Just a question, (being a sort of noob at how command lines works), but would I need to install this on a machine im SSHing into to use it, or only on the connecting machine?

And would it work on windows (putty)? I suspect not...or could I install it on my server, and get this functionality after SSHing in with Putty?

Anyway, those features look absolutely amazing...and all this time I thought Bash was a programming language, and that the "shell" was the only one there was....and here you go! :P

ssh -t you@host zsh

-t for TTY, or it won't work.
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 30 April 2012 - 09:11 AM (#4)

View PostTheMaster, on 30 April 2012 - 08:01 AM, said:

would I need to install this on a machine im SSHing into to use it, or only on the connecting machine?And would it work on windows (putty)? I suspect not...or could I install it on my server, and get this functionality after SSHing in with Putty?

You use the prompt of whatever computer you connect to. So if you SSH to a machine where your shell is Bash, you get your bash prompt. You'd have to change your shell to zsh (which is included with most distibutions of *nix-like OSes -- you don't NEED oh-my-zsh to use zsh, it's just nice) on any machine you want to SSH to in order to have the prompt on that machine. Same goes for PuTTY, as it's just an SSH client. You'd need zsh set as your shell wherever you connect.

View Postcallumacrae, on 30 April 2012 - 08:05 AM, said:

That's all possible in bash, I believe lemon did it a while back and shared his script on IRC (dunno which network, though).ssh -t you@host zsh-t for TTY, or it won't work.

Yep, (almost) everything I put up there can be hacked together in one form or another on Bash. The difference is that, between zsh and oh-my-zsh, many of those features are already built-in, or cleaner/faster than what you can get out of Bash. It's not until you get into things like scripted conditionals and file globbing that you find the features that Bash either doesn't have or has an incredibly poor implementation of.
0


User is offline Cyril 

  • Group: Members
  • Posts: 2544
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 30 April 2012 - 03:28 PM (#5)

Holy crap this looks awesome :) Started (well, already a bit into it) theming my own;

Posted Image

Really like the easy git integration :D

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is offline NeilHanlon 

  • Group: Members
  • Posts: 884
  • Joined: 08-July 10
  • LocationRowley, Massachusetts
  • Expertise:HTML,CSS,PHP,Java,Graphics

Posted 30 April 2012 - 03:47 PM (#6)

So, I'm probably just an idiot and all high on painkillers because I burned myself... But how do I install ZSH, or do I need to? I understand that Oh My ZSH is a plugin framework thing... but how do I start using ZSH - I'm speaking specifically with PuTTY on windows. I can change my TTY settings - but I'm not sure what to add.

Posted Image

EDIT: Fixed issue. For some reason DNS is still fucked up.
Thanks,
兄ニール

Website | Blog | @NeilHanlon | About.Me | Facebook | LinkedIn
0


User is offline Cyril 

  • Group: Members
  • Posts: 2544
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 30 April 2012 - 03:51 PM (#7)

View PostNeilHanlon, on 30 April 2012 - 03:47 PM, said:

So, I'm probably just an idiot and all high on painkillers because I burned myself... But how do I install ZSH, or do I need to? I understand that Oh My ZSH is a plugin framework thing... but how do I start using ZSH - I'm speaking specifically with PuTTY on windows. I can change my TTY settings - but I'm not sure what to add.

Posted Image

EDIT: Fixed issue. For some reason DNS is still fucked up.


View PostKyek, on 30 April 2012 - 07:52 AM, said:

So here's what up. This dude decided it would be cool to build a theme and plugin framework around ZSH. He calls it Oh My ZSH. It's awesome, and will make your zsh life so much easier. Install it by running this at your Bash prompt:
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh



website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is offline TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5154
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 30 April 2012 - 04:00 PM (#8)

Saw this awhile back in: http://railscasts.co...s/308-oh-my-zsh

I don't have it installed yet because it makes me feel special when it starts singing:


Reserved.
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2862
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 30 April 2012 - 04:29 PM (#9)

View PostNeilHanlon, on 30 April 2012 - 03:47 PM, said:

because I burned myself...

Seriously though, hope you recover quickly :-)
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 30 April 2012 - 04:48 PM (#10)

View PostNeilHanlon, on 30 April 2012 - 03:47 PM, said:

So, I'm probably just an idiot and all high on painkillers because I burned myself... But how do I install ZSH, or do I need to? I understand that Oh My ZSH is a plugin framework thing... but how do I start using ZSH - I'm speaking specifically with PuTTY on windows. I can change my TTY settings - but I'm not sure what to add.

Posted Image

EDIT: Fixed issue. For some reason DNS is still fucked up.

This isn't a client-side thing. Whenever you connect to an SSH server and you see the prompt come up, it's not actually PuTTY that's supplying that prompt -- it's the server itself. So if you want ZSH, then you'd have to switch your user account on the server over to it (which requires admin rights) and optionally install oh-my-zsh if you want the bells and whistles (which you can do without admin rights). SO in short, it's something you do after you've connected, on the command line. Not something in your SSH client's prefs :)
0


User is offline NeilHanlon 

  • Group: Members
  • Posts: 884
  • Joined: 08-July 10
  • LocationRowley, Massachusetts
  • Expertise:HTML,CSS,PHP,Java,Graphics

Posted 30 April 2012 - 04:53 PM (#11)

View PostKyek, on 30 April 2012 - 04:48 PM, said:

This isn't a client-side thing. Whenever you connect to an SSH server and you see the prompt come up, it's not actually PuTTY that's supplying that prompt -- it's the server itself. So if you want ZSH, then you'd have to switch your user account on the server over to it (which requires admin rights) and optionally install oh-my-zsh if you want the bells and whistles (which you can do without admin rights). SO in short, it's something you do after you've connected, on the command line. Not something in your SSH client's prefs :)


I don't see an option for ZSH...

Posted Image
Thanks,
兄ニール

Website | Blog | @NeilHanlon | About.Me | Facebook | LinkedIn
0


User is offline Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3415
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 30 April 2012 - 04:59 PM (#12)

I've been meaning to try zsh but haven't gotten around to installing or configuring it. I saw a blog post that convinced me: http://friedcpu.word...oull-ever-need/ . Just the typo correction is enough for me :P
Daniel15! :D
Posted Image

Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

Spoiler
0


User is offline NeilHanlon 

  • Group: Members
  • Posts: 884
  • Joined: 08-July 10
  • LocationRowley, Massachusetts
  • Expertise:HTML,CSS,PHP,Java,Graphics

Posted 30 April 2012 - 07:21 PM (#13)

Putty doesn't like themes, I guess...

Posted Image

Also, any chance I could steal your theme, Kyek?
Thanks,
兄ニール

Website | Blog | @NeilHanlon | About.Me | Facebook | LinkedIn
0


User is offline Daniel15 

  • dan.cx
  • Group: Moderators
  • Posts: 3415
  • Joined: 17-April 10
  • LocationMelbourne, Australia
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 30 April 2012 - 07:39 PM (#14)

Neil, try choosing UTF-8 in Window -> Translation in PuTTY.
Daniel15! :D
Posted Image

Repeat after me: jQuery is not JavaScript. It is not the answer to every JavaScript-related question. When you have to write some JavaScript, do not instantly react with "Oh, I'll do that with jQuery!"

Spoiler
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 30 April 2012 - 09:35 PM (#15)

I wouldn't mind stealing that theme of yours, Kyek, as well.
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 748
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 01 May 2012 - 12:45 AM (#16)

Yeah, Kyek...I looked at the themes on GitHub and...well...not to be ungrateful or picky but....your theme looks better :P

Mind uploading it somewhere? :D

EDIT: I'm not sure if ZSH (and Oh-My-Zsh) is even working. I installed ZSH first (on my Ubuntu 12.04 machine), then tried to install Oh-My-Zsh. I received a few errors, which made me think that it wasn't really working. Is there anything special that I need to do to get it to work? I ran all the commands as sudo, and I got some erros about PAM authentication, (but i'm root!! I dont need to be authenticated!!!).
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 01 May 2012 - 08:27 AM (#17)

Here's mine, with the caveat that the code's pretty dirty (I blame the theme I was working from xD) and I'm working on making it modular so that you can add/remove/reorder the elements in each line. Not sure if I'll ever finish it, but hey, it's on my computer xD

~/.oh-my-zsh/themes/frosted.zsh-theme
Spoiler


Terminal settings recommendations:
  • Font: Menlo Regular, 12pt
  • Do NOT print bold text in a bold font
  • Print bold text in bright colors
  • Black background (semitransparent if you prefer)
  • For the color scheme, I use "Tango Dark" that comes with iTerm2. But this is personal preference.


View PostTheMaster, on 01 May 2012 - 12:45 AM, said:

EDIT: I'm not sure if ZSH (and Oh-My-Zsh) is even working. I installed ZSH first (on my Ubuntu 12.04 machine), then tried to install Oh-My-Zsh. I received a few errors, which made me think that it wasn't really working. Is there anything special that I need to do to get it to work? I ran all the commands as sudo, and I got some erros about PAM authentication, (but i'm root!! I dont need to be authenticated!!!).

What errors did you get? Also, that install script should NOT be run as root -- just as a local user. It may ask for your password in order to change your login shell.

The alternative to the install script would be just manually setting your login shell to zsh, then cloning the oh-my-zsh repository into
~/.oh-my-zsh
. Then you just need to paste this (note -- I have this slightly customized for me, and it uses the theme I posted above, so feel free to edit) into a new file at
~/.zshrc


~/.zshrc
Spoiler

0


User is offline @Tom 

  • space
  • Group: Members
  • Posts: 704
  • Joined: 24-May 11
  • Locationspace
  • Expertise:Python

Posted 01 May 2012 - 11:17 AM (#18)

I may just be thinking poorly but zsh ships with osx correct? You don't need to install anything. Then as a follow up do I need to update my zsh profile to mimic my bash profile?
ocelotapps.com
jr wdR comedian under ThatRailsGuy

View Postarronhunt, on 30 June 2012 - 10:09 PM, said:

Sir you are the first person to make me piss myself laughing. Kudos.
0


User is offline NeilHanlon 

  • Group: Members
  • Posts: 884
  • Joined: 08-July 10
  • LocationRowley, Massachusetts
  • Expertise:HTML,CSS,PHP,Java,Graphics

Posted 01 May 2012 - 11:24 AM (#19)

TheMaster - you need to change the user's shell to /bin/zsh
Thanks,
兄ニール

Website | Blog | @NeilHanlon | About.Me | Facebook | LinkedIn
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 01 May 2012 - 11:29 AM (#20)

View Postitom07, on 01 May 2012 - 11:17 AM, said:

I may just be thinking poorly but zsh ships with osx correct? You don't need to install anything. Then as a follow up do I need to update my zsh profile to mimic my bash profile?

Right -- zsh is already there on macs. If you allow the oh-my-zsh installer to change your shell for you, it will also migrate some of your .profile additions over. Just check .zshrc after the install and move anything else over that didn't make it :)
0


Share this topic:


  • 4 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

5 User(s) are reading this topic
0 members, 5 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services