Mac keyboard shortcut to copy file path as markdown
Get link
Facebook
X
Pinterest
Email
Other Apps
The macOS productivity1 shortcut to Copy file/folder markdown path.
How to create macOS Automator Quick Action to copy the file/folder markdown path using shortcut keys as the same way you copy the path name of the file/folder. I give you an idea of how to use JXA in the Automator. As additional information, I introduce how to use macOS Cocoa that will help you to make better logging using macOS Console application.
Almost all of my blogs are now written in Markdown format. And most of the productivity tools support the markdown format such as obsidian which is my knowledge management tool where I keep all my blog information before publishing. Therefore, I need to copy locally save files links to the Obsidian the second brain most of the time.
I have created macOS Quick Action service to copy any file or folder location in markdown format.
JXA support
JXA is the new replacement to the AppleScript. JXA is a JavaScript solution for which can be used in macOS script editor as well as Automator tool. For example, to open the last email message:
Mail = Application('Mail')
Mail.activate()
var lastMsg = Mail.inbox.messages[0]
Mail.open(lastMsg)
To use the StandardAddition.osax and its functionality as shown in the dictionary: Fig.1: Standard Additions
You have to create the following second line to use the say command.
If you are using Cocoa, then as shown in the linen #1 import the library. In the line #6 you can access the Cocoa API.
ObjC.import('Cocoa');
var app = Application.currentApplication();
app.includeStandardAdditions = true;
// access the Cocoa API
var nsDocumentsPath =$("~/Documents").stringByExpandingTildeInPath;
var myDocumentsPath = Path(nsDocumentsPath.js);
//debugger;
$.NSLog("My document folder is "+ myDocumentsPath.toString());
Logging support
You can find the NSLog output in the Console application.
var app = Application('Finder')
app.includeStandardAdditions = true
var clipStr = app.theClipboard();
debugger;
As shown in the line #4, if you have debugger keyword, that implies you can debug this in the Safari Develop tools. Before use, use you have to enable the develop tool in the Safari and tick the option:"Automatically Show Web Inspector for JSContexts" under your machine name in the Develop menu.
Create Quick Action
As shown in the following Fig.2 you can create Automator Quick Action. Fig.2: MacOS Automator
First and second steps are easy. The 3rd step is given here. Search "JavaScript" component and copy:
function run(input, parameters) {
// Your script goes here
//debugger;
const clpPaths = input.map(x => getFilePath(x));
return clpPaths;
}
function getFilePath(clpPath){
var fileName = clpPath.substring(clpPath.lastIndexOf("/")+1,clpPath.length);
var mdPath = "["+fileName+"](file:///"+encodeURIComponent(clpPath)+")"
return mdPath;
}
The function run(input, parameters) should not change because that is what automator expecting to execute.
Testing using macOS Automator
You can save the above as service and assign even shortcut3. As shown in the above line #4, you can debug(uncomment the line) this script while running as a service. Fig.3: Quick Action Shortcut in context menu
As shown in the Fig.3, In the Mac open the Finder and select one or more files. Now right click and select the Copy File Path or ^ ⬆︎ ⌥ ⌘ c which is the service (it has a shortcut to do the work without a context menu) and v to paste the clipboard contents to your markdown document. Hope this will be really productive. If you need name of the file only in the Finder, then select the fie and press ⌥ ⌘ c.
The first step is sign up in the GitHub and create a new project. For example I’ve created a new project Spring3part7 in the GitHub. Before add the projects you need to configure STS for GitHub access. For example, you need to add configuration as shown in the following picture Git local repository also important Now you are ready to pull the project from the GitHub, in the STS import menu select the following Now type the project name and click the ‘Search’ as shown in the following. However, when you select the found project click ‘Finish’ nothing will change in the STS interface. Now you are going to create real project. Here I am going to create simple utility project. This template project need to be created inside the imported GitHub project You have to give the same project name of the GitHub project as shown in the following project Now your project is ready to push. Before that you need to add ignore flag to all the folders and files except pom...
This is the 7 th part of the Spring 3 Series . Create MySQL 5.6 database ‘payroll’, CREATE DATABASE payroll; Next create a user for example, user ‘ojitha’ CREATE USER 'ojitha'@'localhost' IDENTIFIED BY 'ojitha'; Need to grant the ‘payroll’ access to user ‘ojitha’ as shown in the following. GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON payroll.* TO 'ojitha'@'localhost'; You can download freeware of TOAD for MySQL from here . Let create a first table, that contains all the states in Australia. You can create a table using visually using the icon given directly below the Tables tab in the Object Explorer as shown in the above diagram. CREATE TABLE payroll.STATE ( CODE CHAR(3) ASCII COMMENT 'State code', STATE VARCHAR(30), PRIMARY KEY (CODE) ) ENGINE = InnoDB COMMENT = 'Australian states' ROW_FORMAT = DEFAULT; In the my sql console you can the newly added table using the following command SHOW ...
In this blog, I am considering how to parser and modify the xml file using python. For example, I need to parser the following xml 1 (slightly modified for this blog) and need to write the modified xml to out.xml file. Here the country.xml <?xml version="1.0"?> <actors xmlns:fictional="http://characters.example.com" xmlns="http://people.example.com"> <actor type='T1'> <name>John Cleese</name> <fictional:character>Lancelot</fictional:character> <fictional:character>Archie Leach</fictional:character> </actor> <actor type='T2'> <name>Eric Idle</name> <fictional:character>Sir Robin</fictional:character> <fictional:character>Gunther</fictional:character> <fictional:character>Commander Clement</fictional:character> </actor> </actors> In ...
Thank you, works perfectly.
ReplyDeleteLooks like a fellow Obsidian user needed the same thing as me :)
I didn't know about JXA that's awesome!