shortcuts for developers i have added to my daily workflow

As a developer i switch between different Applications hundreds of times a day, therefore i had to optimize this ;). I am only sharing the most useful here, with the shortcuts i list here i personaly do not need CMD + TAB anymore.

In order to achieve this i use:

Applications i use litteraly all the time:

General shortcuts:

shortcut what it does
CMD + . will always toogle iTerm 2 no matter in which application i am.
CMD + F16 will open or switch to Safari which is my main browser
CMD + F17 will open or switch to WebStorm
CMD + F18 will open or switch to PhpStorm
CMD + F19 will open or switch to Paw

Application specific shortcuts:

I consider Keys F12,F13,F14 as application specific, therefore i re-use those multiple times. I am not showing those here as they are often code related like console.log(), var_dump()

iTerms:

As a heavy Docker user i needed shortcuts to the most important functions. These save me a lot of time every day.

shortcut what it does
CMD + F13 will type copy selected text and then paste as docker exec -it e4d509399a4a bash
CMD + F14 will type copy selected text and then paste as docker logs -f e4d509399a4a
CMD + F15 will paste docker ps

PhpStorm

Most of the time i code REST Api’s therefore the 2 main tools i use is PhpStorm and Paw, i switch hundreds of time between those 2 Apps. These Toggles are also very handy if you use „Split Screen“ in MacOS

shortcut what it does
CMD + 0 will switch to Paw if i am in PhpStorm or will switch to PhpStorm if i ma in Paw.

WebStorm

Sometimes i also do Frontend or Ionic work, therfore i this toggle.

shortcut what it does
CMD + 0 will switch to Chrome if i am in WebStorm or will switch to Webstorm if i ma in Chrome.

How i sync my code automatically to a remote server

I do not want to have my Docker setup on my Mac for several reasons. Docker on Mac sucks because of volumes. I could use Docker-Machine but i don’t like the idea of having a virtual machine running just for that.

That is why i have my docker setup running on a powerful server in the cloud.

As soon as the code changes it want all the changes to be automaticaly synced to my server.

But how the get code changes there ?

Because MacOs is awesome you can achieve this with included tools such as rsync and lauchd.

Here are my settings, please adapt it to your needs.

First of i have created a simple bash file which takes care of calling the actual rsync command. This fits my needs as a PHP/Symfony Developer but you can easily adapt it to your needs.

Please checkout my gist on github to get the code.

Put the file to ~/sync.sh

You can call it like below but first you have to replace some placeholder with your variables

– my_user=your username on the remote server
– my_remote_host=the hostname of your destination server
– my_source_folder=this is the local folder where your code resides
– my_remote_folder=this is he remote folder where the code gets synced to
– my_project_folder_to_monitor=this is the local folder where your code resides (should be the same as my_source_folder)

/bin/sh -c "~/sync.sh -h my_remote_host -u my_user -s my_source_folder -d my_remote_folder"

Okay, that is already pretty good. But i wanted to run this script as soon as code changes in my project. To do this i created a job for the laund on my mac.

Please checkout my gist on github to get the code and create a file called my_sync_job.plist in ~/Library/LaunchAgents Of course you will need to adapt the placeholder as described before.

Now we can Load the Job by doing this.

launchctl load '~/Library/LaunchAgents/my_sync_job.plist'

Now if you did all correct you can try to make a change in any file in your project folder and i will get synced to the remote server.

You can unload it by doing this

launchctl unload '~/Library/LaunchAgents/my_sync_job.plist'

You could to some more fancy stuff with these tools so be creative 😉

How to change the owner on a shared hgfs folder

Let’s assume you want to change the owner of your shared folder to the user www-data and the group www-data

  • we use VMWare Fusion
  • VMWare Tools must be installed and updated
  • tested on Ubuntu Server 14.10 LTS and 15.04

1. create file /bin/remount_hgfs

1.1 become root on your system

sudo su

1.1 create the file with touch

touch /bin/remount_hgfs

1.2 make it executable

chmod a+x /bin/remount_hgfs

1.3 add the following 3 lines to the file

!/bin/sh -e
umount /mnt/hgfs
mount /mnt/hgfs

echo '#!/bin/sh -e' >> /bin/remount_hgfs
echo 'umount /mnt/hgfs' >> /bin/remount_hgfs
echo 'mount /mnt/hgfs' >> /bin/remount_hgfs

2. update your fstab file

i assume the uid and the gid of the user www-data on your system is 33, which is default on most Debian based Systems. You can verify that by doing:

id www-data

If you want to mount as a different user you can find out the same way. If the id is different please modifiy the value of the next command.

2.1 add the following line to your fstab file

.host:/ /mnt/hgfs vmhgfs rw,ttl=1,uid=33,gid=33,nobootwait 0 0

echo '.host:/ /mnt/hgfs vmhgfs rw,ttl=1,uid=33,gid=33,nobootwait 0 0' >> /etc/fstab

3. make sure the remount_hgfs gets executed when the system starts

3.1 add the following line to /etc/rc.local, before the exit

sh /bin/remount_hgfs

line=`wc -l /etc/rc.local | cut -f1 -d' '`; sed -i "${line}ish /bin/remount_hgfs" /etc/rc.local

4. reboot you VM

reboot

Now if you do „ls -l /mnt/hgfs“ you should see that the folder belongs to www-data:www-data

For those who trust me, you can do all commands at once 😉

sudo su
touch /bin/remount_hgfs
chmod a+x /bin/remount_hgfs
echo '#!/bin/sh -e' >> /bin/remount_hgfs
echo 'umount /mnt/hgfs' >> /bin/remount_hgfs
echo 'mount /mnt/hgfs' >> /bin/remount_hgfs
echo '.host:/ /mnt/hgfs vmhgfs rw,ttl=1,uid=33,gid=33,nobootwait 0 0' >> /etc/fstab
line=`wc -l /etc/rc.local | cut -f1 -d' '`; sed -i "${line}ish /bin/remount_hgfs" /etc/rc.local
reboot

That’s it 😉