A pen and handwriting

Make OSX and Linux command line behave more like Windows

Lately, I have been doing more and more work in my native OSX image. And I am really loving it.

However, being an old Windows user, I find a lot of habits hard to break and I constantly find myself wanting the standard Bash command line to behave just a little more like good old DOS. To avoid the same typing error over and over again, I found these modifications to be useful. I am sharing them here in hope they may help other people who are transitioning from Windows.
Now, if I could only find a proper text editor. Edit: I have since encountered TextWrangler, which is pretty good. See below

Add ./ to the path

This is an immensely useful thing to do. As a Windows user, I expect that my current directory is searched for binaries. I know some old school Unix people consider this a security hole. Well, Windows has lived with this for years without running into issues.

Make cd.. work

In bash, typing cd.. without the space is an error. Obviously, this convenient short hand from DOS is the superior option. Here is how to make that work:

Make dir work

I find myself typing dir instead of ls a lot. Well, there is no reason that dir should not work. Here is how to make it work:

Make copy and ren work

Another Windows classic. Unix likes short command lines with odd names, Windows uses longer names. Vanilla or chocolate ice cream.

Adding it all to your .bash_profile

OSX uses a file called .bash_profile located in your home directory ~/ to store aliases and bash settings.

By default, this file does not exist, so you have to create it. Once you do, just copy the aliases you want in there, and say:

A Text Editor that won’t drive you mad

As Windows users, we are spoiled with Visual Studio as a text editor.

If you feel masochistic enough, you may be able to learn the high speed interface of VIM. If you do, I recommend installing the improved version that comes from here https://code.google.com/p/macvim/ – it is much better than the one that ships with OSX.

If getting carpal tunnel syndrome is your idea of a good time, there is always Emacs. I used to run this, until I installed Visual Studio one fine day and never looked back.

For a great cross platform experience, I found UltraEdit to be reasonable. It comes at a cheap price tag and looks similar on both Mac, Linux and Windows. It is also very lightweight.

But my favourite text editor so far on Mac is TextWrangler. It’s free, it has sensible shortcut keys and it uses the Perl regular expression syntax for some seriously elegant search/replace functionality. It can also be loaded up with different language modules.

File Management

Let’s face it, Finder is a joke. Apple actually managed to create a file manager that is WORSE than Explorer. That is quite a feat. On both Windows and Mac, there is a better way. MuCommander, a clone of the old Norton Commander, gives you a great cross platform experience and allows you to handle files easily (Except for Keynote files which are a travesty).

An alternative to MSPaint

OSX doesn’t really ship with a reasonable bitmap image editor. Maybe people buy Photoshop when they buy a Mac?

There is a free and nice way to get the basic functionality of mspaint and then some: Install Seashore. It is a little unstable, but much more lightweight than GIMP (as a bonus, it doesn’t require you to run X11).

  11Comments

  1. Chuck Lathrope   •  

    Hey Thomas, I also have made the jump to using MacOS and more opensource tools like python, git, AWS, postgresql from the strict MS diet of SQL Server and Windows Server. I recommend you should look into zsh shell. The mac bash shell is super old. I found a slideshare on accident that talks about some of its benefits: http://www.slideshare.net/jaguardesignstudio/why-zsh-is-cooler-than-your-shell-16194692 I have used it for a month now and really like it. I added a bunch of plugins, which seems to slow the prompt down a bit, probably from adding too much.

    Finding a good IDE like Visual Studio or SSMS is impossible, but here are some suggestions: PyCharm (not free) and they have alpha DBE tool now which is working out well. RazorSQL and Navicat are some good not free db tools. Eclipse of course if you get into java.

    Have you looked into Vagrant and Virtualbox combination? I find the combination of that and Puppet can do code and infrastructure deployment work very easily, much easier than I could with powershell and hyper-v, but I didn’t spend a lot of time figuring out how on MS stack.

    Thanks for all the great presentations at PASS conferences, you challenged my performance tuning methods to new heights!

    -Chuck
    @sqlguychuck

    • Thomas Kejser   •     Author

      Hi Chuck

      Thanks for a lot of good input.

      Of all the tools on Windows, I miss visual studio the most. I actually found MySQL Workbench to be better than SSMS. PGAdmin I find a bit light on functionality and unstable.

      I am actually part of the Beta program for 0xDBE which looks mega promising. However, the version I am currently running does not have the ability to graphically view the query plans (Which I consider a crucial ability). Do you know if there is something in the works on that front?

      While at Livedrive, we used Chef to build boxes and that was really efficient.

      I will have a look at zsh. Happy to hear I helped challenge you – mission accomplished 🙂

  2. Erdogan Kurtur   •  

    Try Sublime Text, you will wonder how you have ever lived without it. Works on Windows, Linux and OSX and you better start watching small gifs on home page about features of sublime.

    • Thomas Kejser   •     Author

      Erdogan. I will take it for a spin. At the moment I am using TextWrangler, which has pretty sensible shortcuts and a good RegEx S/R.

  3. Alexander Kilian   •  

    You forgot the most important one!

    export PS1=’C:\w> ‘

    • Thomas Kejser   •     Author

      LOL. That would be too much familiarity. Next thing, I might want to reimplement TSR.

  4. Vincent   •  

    The first thing you should do when you start working with a new OS is realize that you are not working on your previous OS, and that you should learn how things are done on this new OS. An alias can only hide the real name of a command, it cannot translate command line parameters, so if you want to do ‘dir /AH’ you will still have to learn how to do that in ls, ‘dir /AH’ on windows becomes ‘dir -al’ on osx, and that means you will find yourself typing ‘dir -al’ on windows every now and then. I’ve never typed ‘dir’ on linux, or ‘ls’ on windows, because I associate ‘dir’ with windows only, and ‘ls’ only with un*x based systems.

    And of course you don’t want to know what kind of problems you can get into if you start aliasing dangerous commands like ‘del’ for ‘rm -f’, and some script that uses a tool called ‘del’ suddenly starts removing files instead of doing something innocent that just happens to be named ‘del’.

    Finally, don’t add the current directory to your path, because it has security implications on *nix systems: http://superuser.com/questions/350844/how-to-permanently-add-current-directory-to-path-in-linux

    • Thomas Kejser   •     Author

      Vincent, I respectfully disagree.

      First of all, I switch between OS’es all the time. I have no illusion that going FreeBSD, Linux, OSX will free me up from using Windows – nor would I wish it to. Perhaps you never type ls on Windows, but I do. What is important to me is productivity and if I have Windows habits that are easily fixable on OSX – I implement a fix. While there might be some theoretical universe where I type Dir /AH – I don’t think I have ever found it necessary to do so. In fact, I am aliasing ls on Windows to dir too, for the very same reason.

      The del aliasing to rm -f is again a false sense of security. Who is to say that someone hasn’t already added another del in my /bin path that messes up that tool too? That is why the path is searched in a specific order.

      I don’t buy the argument that adding current dir into the path either. Windows works fine (and I might add, a heck of a lot more secure than most Linux variants) like this and in fact, it is used as a way to implement override commands – which is an immensely useful feature. As you say, you should know what you are doing when you are doing things. Having sporadically named CHMOD executable files hanging about in my directories indicates that someone has already breached my system. Removing the current dir to the path doesn’t add any additional security holes that aren’t already there – not even in a theoretical universe.

  5. Dave Wentzel   •  

    These hints are so patently obvious that I can’t believe I’ve been dealing with this for so long. Just a note though, and I could be wrong about this since I deal with ONLY debian flavors of Linux, the commands you mention are only good for that terminal session. You would need to add them to ~/.bash_aliases. Your post got my thinking about other commands I use frequently that don’t have a direct bash equivalent. alias cls = “clear”. or alias del = “rm”…but maybe aliasing something destructive like del isn’t so great.

    Thank you for your posts. Every one is a good read.

    • Thomas Kejser   •     Author

      Hi Dave. You are right, I should add them to my bash alias and global path. Guess I just shows how little I reboot. 🙂 I will update the post as I add more aliases

    • Thomas Kejser   •     Author

      Hi Dave.

      Additional thing, on OSX, you need to change .bash_profile instead. I have added the details to the blog entry. Again, thanks for the constructive input.

Leave a Reply

Your email address will not be published. Required fields are marked *