Categories
server ssh sublime text

Using Sublime Text on Remote Servers (Mac OSX)

If you need to work on a remote server and aren’t comfortable with tools like Vim or Emacs, this technique will let you use Sublime Text to work with remote files.

This script works by mounting directories of remote servers on our local machine and work with them as if they are local machines. This article will walk you through setting up the scripts and shortcuts on your machine so you can use this fast and convenient method too. Obviously, it is easy to delete and change things so be careful and always use version control.

These directions are for Mac OSX. You might be able to do it via the command line on Linux and Window but you will need to change a few things.

Prerequisites

1. You need to have Sublime Text set up to be able to be opened from the command line. Mac/*nix Instructions Windows Instructions
This usually resembles a symlink in one of the directories linked from your $PATH to the Sublime shortcut so you can use $ subl to open it from within Terminal.

2. Make sure you have sshfs installed. If not, download and install *both* FUSE and SSHFS from here https://osxfuse.github.io/

3. You need to have your local public key ( contents of ~/.ssh/id_rsa.pub) in the ~/.ssh/authorized_keys file on the the remote server so you can log in.

Script

Name this file something like “remote-server-in-sublime.sh” and put it somewhere in your home directory. It will need to have execute permissions by your user. Obviously change the username to your own.

!/bin/bash

if [ ! $1 ]
then
echo -e "Please pass in a directory path"
exit
fi

mkdir -p ~/remote-server$1

sshfs andy@remote.server.com:$1 ~/remote-server$1 -o reconnect

~/subl ~/remote-server$1

Usage:

Put something like this in your aliases file.

alias remote-server-in-sublime=’~/remote-server-in-sublime.sh’

To run it, you just need the full path to the folder as the argument.

$  remote-server-in-sublime /var/www/website

—–
Extra Stuff

Remember to unmount it from your local machine at the end of the day/ when you are done.

$ df   // view all mounted volumes
$ umount  {name of “filesystem”}    // unmount the specified volume

e.g.

$ umount andy@remote.server.com

The default file for aliases is ~/.bash_profile but if you want to keep your bash_profile clean you can do this:

if [ -f ~/.bash_aliases ]; then
             . ~/.bash_aliases
fi

alias aliases=’vim ~/.bash_aliases’

It’s normal that it creates a ‘~/remote-server/var/www/etc etc’ folder on your computer. Don’t worry.

Categories
drupal

Make a Webform available as a block in Drupal 7

Making Drupal Webforms available on blocks on Drupal 7 is something you’d think would be simple but it’s buried away among all the Drupal options.

When you create a new Webform, you will see a set of tabs up the top.

Next to [View], [Edit] there should be a [Webform] tab.

Click that and go to > [Form Settings] > [Advanced Settings] and select ‘ Available as block‘ option.

This will make the form show up as a block so you can move it around as you like and have it appear on any page in your site.

Categories
Uncategorized

Making WordPress store its files in a secret folder

Do you want to install WordPress on your server but want to keep your root directory clean?

The easiest way to do this is just to install the files for WordPress into a subdirectory, change the site address to the root, and then copy the index.php up to the root, and then edit one line to reference the new WordPress subdirectory.

require( dirname( __FILE__ ) . '/wp-blog-header.php' );

becomes

require( dirname( __FILE__ ) . '/subdirectory/wp-blog-header.php' );

For more info, check out the official WordPress documentation https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory