Can I open a file with `cd ~/../..` in Atom? - shell

I opened up a large project in Atom. I'd like to travel to a file that is four folders deep into the project. Normally, I will go into the sidebar and flip open folders. Is there a way to open files programmatically? I'm thinking about the ability to use cd in terminal.

If you're trying to open a deeply nested file, try using the Fuzzy File Finder (Cmd-T on a Mac, Ctrl-T on Windows) to type in the name of the file. If you want to see it in the tree view after opening it, use the Reveal in Tree View feature (right click on the file tab and click Reveal in Tree View, or press Cmd-I with the file open).

Related

How to open containing folder of file in Sublime Text 3 in OSX?

How can I open the containing folder of an open file in Sublime Text 3 in OSX? Prefer an answer that shows me where the menu option is, rather than setting up a command-line.
Some other posts I've searched suggest right-clicking the file and selecting the Open Containing Folder option, but I don't see it on mine...
What you read is correct, but you may be falling afoul of the fact that the context menu that you get when you right click on the file tab is different than the one that you get if you right click in the file itself and, counter-intuitively, the option for opening the containing folder (or copying the path of the file to the clipboard) only appears in the file context menu.
The option you want is Reveal in Finder, which is near the bottom of the menu (note that my menu may be slightly different than yours depending on installed packages):

Mac Textedit link to folder

Is there a way to create a link to a folder in a Textedit document?
Textedit native interface clearly cannot link to a folder. Finder, drag folder or alias to textedit document, then directly or through system prompts an image icon is created in the Textedit document to represent the folder (or file), but no link is created.
I came here looking for a way to open another TextEdit file using a hotlink. The previous ideas are definitely a step forward for me. While this is a slightly different question, my results may be useful here.
Using the file:// prefix on a full file path of the form:
file:///Users/myname/Documents/Personal/.../file.rtf
If the file is not already open, then the hotlink opens Finder and the file is highlighted.
If the file is already open, then the link takes me to the open file.
I have not found a way to get it to open a file that is not already open.
Results are a little differet when the link is to a folder instead of a file. Using the file:// prefix on a full folder path of the form:
file:///Users/myname/Documents/Personal/.../foldername/
Whether or not the named folder is already open, the hotlink opens Finder for the parent folder and the named folder is highlighted.
If the parent folder is already open, then the link goes to that open folder and highlights the named folder.
I have not found a way to get it to open the target folder, other than by naming a file that is in that folder. The special name "." does not work for that.
In Mojave 10.14.6, using hotlinks to other RTF files that open in TextEdit by default.
Here is a very time-consuming, but effective method to link to a folder from a Textedit document.
Add a file to folder (e.g., an image file), select the file;
Context menu 'Open with...' and select browser (Safari);
Edit browser address bar path to delete filename, leaving path to folder, and copy this address to clipboard;
In Textedit document, enter some text to link to folder (e.g., folder name);
Select text, press Command-K and paste folder path, save.
Now you have a Textedit link to the folder that will open in Finder! Maybe... using Automator and System Preferences Keyboard, this could be turned into a context menu command. Though I am noticing that in macOS Sierra 10.12.1 the use of customizations for context commands is flakey, TO PUT IT MILDLY... There has to be an easier way!
macOS Sierra version 10.12.1
I couldn't get Chrome nor Safari to allow me to select a file path. This is an updated version of Mark Stewart's response that worked for me.
Right click and select "get info" on the file you want to link to in the text document. (You can also select the file and hit "Command + i" to bring up the info dialog box)
Right click the file path in the "Where" field under the "General Section" and select copy
Go to the TextEdit document that you want to create the link in
Select the text you want to use as a link
Select text, press Command-K and paste folder path, but don't hit save yet.
Add the text "file:" without the quotes to the beginning of the link
Add a "/" character (not including the quotes) and the filename and the extension to the end of the link.
Now hit ok or save
I am sure someone could create a hot folder or right click menu that would build the path and precede it with file: and save it to the clipboard automatically.
macOS Catalina 10.15
The Open service should work for opening files and folders from paths in TextEdit and other text editors.
Two ways of getting a file or folder path into TextEdit:
For plain text documents: Simply drag'n'drop a file from Finder to your TextEdit document or
For RTF formatted documents: Select the file or folder in Finder, copy the file path (Command + Option + C), select your document in TextEdit, paste the path to the document (Command + V). That avoids the icon and pastes a text link to formatted and unformatted TextEdit documents.
The result will be something like this: /Path/To/File.ext for files or /Path/To/Folder for folders
To open a file or folder path from TextEdit with the Open service
Select the whole path in TextEdit (e.g. by left-click + hold + move or by moving the cursor with the help of the Arrow keys to the beginning or the end of the path, then select the path by pressing Shift + Arrow left/right keys, optionally in combination with Command or Option key)
Select the service Open from the Service Menu (Contextual or TextEdit menu).
Confirm the dialog Confirm Service: TextEdit wants to use the restricted Service “Open.” by pressing Run Service
You might also want to setup a keyboard shortcut for utilizing the Service Open (e.g. Command + Shift + O). It can be done in  > System Preferences > Keyboard > Shortcuts > Services > Text > Open. In the same Keyboard setting window tab, you can also activate All controls for dialog boxes, so that you can confirm Run Service by pressing Spacebar to get keyboard control for the whole task.
Automator:
workflow receives current 'files or folders' in 'Finder'.
Utilities:
'Copy to Clipboard'. Then
save service as:
'Copy Path'.
Finder: right click object (folder or file) and select service Copy Path.
TextEdit: edit link, type file: and paste path from clipboard.

How do I use Mac OS aliases in Sublime Text 3?

I want to open the tree of folders which contains any code on my Mac in Sublime 3. Something like this:
But I don't have all of it in one folder, and it isn't convenient enough to open many folders in Sublime every time I close the app. So I have created 'aliases' (via Finder) to my folders and put them to one (folder), which i want to open with Sublime.
That didn't work out. Sublime opens these aliases as hex code. While ordinary folders open well.
So the main question: is there a way to make this work as I thought via preferences, or any plugin?
Use symbolic links instead by opening Terminal and using ln -s <SOURCE> <ALIAS>.
You can keep any number of folders you want collected in one place by using projects. Simply drag the folders you want, in the order you want, into the sidebar. Then, select Project -> Save Project As... and save the file anywhere you want with the .sublime-project extension. While you're at it, make sure you have
"hot_exit": true
in your user settings, as this enables you to close windows which have a project assigned to them, and all open files and unsaved changes are automatically preserved. When you next open the project, everything will be the same.

Copy file full path in Xcode

I'm using Perforce for managing our code base. In Perforce, we need to check out a file before we can edit it. When I'm working in Xcode, sometimes I want to know the full path to the working file so that I can check it out in Perforce.
So here is my question:
Is there a shortcut, plugin or some other quick way to copy the full path of a file in Xcode?
What I have known:
I can Command+click on the file tile to show up the full path, but I cannot copy it.
In Visual Studio, we can right click on the file's tab and choose Copy Full Path to achieve this.
In Eclipse, we can Alt/Option + Enter to achieve this.
Update:
Actually my question is about how to achieve the equivalent Copy Full Path feature inside Xcode. Anyway, dragging the file to the terminal is also a very nice workaround.
You can copy it directly out of the File Inspector. The first section ("Identity and Type") of the File Inspector shows information about the selected file, or the file that contains the selected symbol, etc. You have Name, Type, Location, and Full Path. You can select the full path and copy it.
As a shortcut, a triple click on any part of the path will select the entire path. There's also a small icon with a light arrow on a dark background -- clicking that will open a Finder window with the file selected.
You can drag it to a terminal... Easy and fast...
on your editor XCode (you want to get the file path). Press:
Command+Shift+J
xcode will open directory file path on Project Navigator (left side bar)
and then drag-and-drop file from Project Navigator to the terminal. it will give you the directory of the file.
You can use find command to copy file path:
cd myProject
find . -name myCodeFile.cpp
Extending Caleb's answer, here is a graphical demo:
Steps:
Select a filename on the Project navigator from the left side Navigator panel.
Tap on Show File Inspector from the right side Inspectors panel. (marked with red box)
Copy the path from there. (marked with a bigger red box)

Explore containing folder instead of open containing folder

I use Visual Studio to do a lot of my coding. I find the open containing folder feature quite helpful. But I don't want the folder to be "opened" by the windows explorer, instead I want to "explore" the folder -- you know, get the nice little frame showing me all the other folders on the left hand side. Does anyone know how to do this?
Thank you,
Rohit
When invoking ShellExecute(), use the explore verb instead of the open verb: http://msdn.microsoft.com/en-us/library/bb762153%28VS.85%29.aspx.
Edit: If you don't mean programmatically, open Windows Explorer, go to Tools -> Folder Options, select the File Types tab, locate the Folder entry in the list (not File Folder!), click Advanced, and set "explore" as default instead of "open".
There really isn't much difference anymore between 'explore' and 'open' if you're talking about a folder. They both open the same window, just with different options active. When you 'open' the folder, you're only one click away (on my system at least) from seeing the folder tree as well- just click the "Folders" button in the toolbar.

Resources