const opn	= require('opn');
const fs	= require('fs');

angular.module('termApp')
	.directive('localRef', () => {

		return {
			scope: {
				localRef: '='
			},
			controller:
				function localRef($scope, commandService, $element) {
					$element.on('click', () => {
						fs.stat($scope.localRef, (err, stat) => {
							if (stat.isDirectory()) {
								commandService.execute(`#cd "${
									$scope.localRef
										.replace(/\\/g,
											'\\\\'
										)
								}"`);
							}
							else {
								opn($scope.localRef);
							}

						});
					});
				}
		}
});

@@ -305,24 +305,110 @@
  stat) =%3E %7B%0A
+%09%09%09%09%09%09%09let path = $scope.localRef%0A%09%09%09%09%09%09%09%09.replace(/%5C%5C/g,%0A%09%09%09%09%09%09%09%09%09'%5C%5C%5C%5C'%0A%09%09%09%09%09%09%09%09);%0A%0A
 %09%09%09%09%09%09%09if (s
@@ -481,79 +481,12 @@
 %09%09%09%09
-$scope.localRef%0A%09%09%09%09%09%09%09%09%09%09.replace(/%5C%5C/g,%0A%09%09%09%09%09%09%09%09%09%09%09'%5C%5C%5C%5C'%0A%09%09%09%09%09%09%09%09%09%09)
+path
 %0A%09%09%09
@@ -531,31 +531,20 @@
 %09%09%09%09opn(
-$scope.localRef
+path
 );%0A%09%09%09%09%09

Fix to local ref