Open dot-file with dialogue in OSX - macos

Since the GUI-side of OSX treats all dot-files (such as .htaccess) as hidden, it doesn't display them in any of the graphical UI:s, e.g. Finder or the Open-dialogues.
How can I open a dot-file (.htaccess in this case) in a graphical editor, without doing that thing for all hidden files, universally and without going through Terminal.app?
Edit: I'm on Leopard, if that makes a difference.
Edit2: TextWrangler and TextMate seem to have features that allow you to open hidden files, which partly answers my question.

In an "Open File" dialog you can use Command-Shift-. to see dot files.

You could tell Finder to display hidden files as well (enter in Terminal):
defaults write com.apple.finder AppleShowAllFiles TRUE
But that’s not really nice since there are a lot more hidden files. So I recommend to use an editor that allows you to view those in the open dialog like Chuck mentioned.

If you only want to do this for one specific file, you can create a symbolic link to the dot-file. Open up Terminal.app, cd to the directory containing your dot-file, and run
ln -s .htaccess dot_htaccess
Then you should be able to double-click the file dot_htaccess as a regular file, and any edits you make will really go into .htaccess.

TextMate (a really nice text editor for OS X) open dialog has a "Show hidden files" option, and TextWrangler (and its big brother BBEdit) has it has a menu item.

In the command line, for a file named FILE, type:
open -e FILE
The open command will open the file in TextEdit (-e flag). Check out "man open" for more flags (e.g., specify the app to open with -a)

Smultron (another nice OS X editor mentioned in the comment above and similar to TextMate, but free) has an "Open Hidden..." file menu item that works splendidly for this purpose.
Sad news: Smultron is apparently no longer being developed further beyond v3.5.1 (which requires Leopard), according to a post from its author at its homepage: http://tuppis.com/smultron/
jEdit is another free option that has hidden file support: www.jedit.org/users-guide/vfs-browser.html (sorry for the lack of 'http' in the link -- being a new user, my posts are limited to just one link. Alas...)

Related

Changing Atom editor copy/paste behavior

The Atom editor is a very good product, but in some areas it attempts to deviate from long standing user interface standards for operating systems, which can extremely annoying.
For example, on a Mac running OS/X, all apps compliant with Apple's guidelines will handle a Copy command with no selection by leaving the clipboard intact. On Atom, this action will either delete the contents of the clipboard if the line is empty, or overwrite them with the contents of the entire line.
Deviating from such very basic user interface guidelines is not a good idea, but if it's going to be done, the deviation should be an option, not the default.
Is there a way to force Atom to behave the way it should on a Mac, through options or scripting?
Figured it out.
Adding the following at the bottom of the keymap.cson configuration file returned Cmd-C to the correct behavior.
'body':
'cmd-c': 'native!'
To edit the keymap.cson file open Preferences, then Keybindings, then click on "your keymap file" at the end of the sentence under the "Keybindings" title.

AppleScript to paste text from clipboard into a file

I thought this would be easy. The Google makes me think otherwise.
What I want is a poor man's inter-OS clipboard. Everything I looked at on the net is either not free, no app this simple should cost anybody anything, or isn't compatible with local linux installs or Windows or some such.
In the best solution a right mouse action would be added to "cut", "copy" and "paste" named something like "copy to file". The file might or might not exist but would have a fixed name and be on a shared disk.
I guess I'd need a second right mouse action "Paste from file" to complement the "copy to file".
So, would some one show me how to have an AppleScript or, maybe, Automator, take the current text contents of the clipboard and paste into an existing file, overwriting any
existing contents of the file?
OS/X Snow Leopard
Thanks.
how to have an AppleScript […], take the current text contents of the clipboard and paste into an existing file, overwriting any existing contents of the file
AppleScript code:
do shell script "pbpaste > /path/to/your/clipboard-file.txt"
In order to read text from the file back into the clipboard, use
do shell script "cat /path/to/your/clipboard-file.txt | pbcopy"
For documentation, see man pbpaste
EDIT: Now, to convert the AppleScript into a Mac OS X Service, which will appear in the "Services" group of every context menu (at right-click / CTRL+click on any text), you can use Automator, as described in this tutorial.

"Open folder in Terminal" for Spotlight or Alfred

Is there any way in Spotlight to have a folder open in a Terminal window, either by providing an "Open in Terminal" option in search results, or (ideally) by holding down a key when selecting a result? Basically the same way holding down command will "Open containing folder" maybe make it so holding option (or whatever key) could "Open in Terminal".
Alternately, is there a way to setup the Alfred app so that it will always open folder search results in the Terminal? that might be even better, then I could use ctrl-space exclusively for opening folders in the Terminal and command-space (Spotlight) for everything else.
The closest thing I can find to anything like these is the "cdto" application, which adds an "Open in Terminal" button to the Finder. This is nice, but being able to do this directly from Spotlight or with a keypress would be much more convenient.
This question is old and you undoubtedly found the answer by now; for the sake of completeness: the latest version of Alfred allows one to search/navigate the filesystem from within Alfred, and take action on the folder or file found. One folder action is "Open Terminal Here", which seems to be what you are asking for.
I've found this to be the fastest method without any external tinkering.
Requirement: need to have iTerm or Terminal in the Dock:
Type the folder name into Alfred / Spotlight
Click and drag the folder that was found into the iTerm / Terminal icon in the Dock
Try this tool:
https://github.com/nmadhok/OpenInTerminal
This is a really handy tool for programmers on Mac as it lets you open the folder directly in Terminal. You can select multiple folders to open them in multiple terminal windows. You can also select files to open the parent directory in Terminal. This application works with Finder as well as without Finder which is a plus!
use this Alfred extension
https://github.com/LeEnno/alfred-terminalfinder
then just lob off the input and set it to a hotkey.. I have one to open the current finder in terminal and vice-versa
#Verboze - I'm still looking for an answer :)
Perhaps it should be migrated to stack exchange or the other one used non-programming topics, such as system administrivia. Though a case could be made that the command line is essential to programming.....
Windows has "Command Prompt Here". Linux has Nautilus' "Open In Terminal". The world's most advanced operating system has nothing (the best I can tell).
For completeness, I did look at the customizable toolbar ('drag your favorites here'; but my favorite is missing). I also found an old Action Script or Automator Script that did not work (the article was old, and it could not be followed).
I did find a program called "CD To...", but its broken. Upon opening the first terminal, the program opens two terminals. I'm not sure what other programming mistakes were made by the developer, and I really don't want to experiment.
Check this: https://github.com/miromannino/alfred-new-terminal-window
It opens a new Terminal/iTerm window in the current space.
Holding the alt key, the new window is also opened opened in the current frontmost Finder folder.
For me that is almost sufficient for my daily work!
Hope it helps!

How do I make certain files accessible in Mac OS X?

I have a db file which I want to open using a firefox plugin.
However, I can't open the file.
I've also got other files like this with other file types.
I'm sure I've had this problem before, any ideas ?
I've tried...
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
But that didn't work.
Mac OS X displays all of the files in a particular folder on your disk in its Open/Save common dialogs, but it grays out the ones that are in a format that can't be opened by whatever program's Open/Save dialog you're browsing from.
The title of the dialog in the screenshot above gives away your problem. It says "Set Default Directory", which means it's only looking for a folder. The file "bc.db" is just that: a file. Whatever program you're trying to open it from isn't willing to accept it because a file is not interchangeable with a folder/directory. That explains why none of your other file types work, either. You need to choose a folder from that dialog to set as the default.
It's also worth nothing that the .DB extension means that file is a database file of some sort. It's very likely that it's in a proprietary format that can only be read by one particular application. Thus, even if you try to open it from the Finder, you're not likely to get very far. You need to figure out what program originally generated that file and try to open/use it there.

Is there a Firefox add-on to use vim to edit textboxes?

or "How do I answer questions on SO in Firefox using gVim inside the textboxes?"
It's All Text!
From the extension page:
At the bottom right corner of any edit
box, a little edit button will appear.
Click it. If this is the first time
you've used "It's All Text!" then you
will be asked to set your preferences,
most importantly the editor.
The web page will pop up in your
selected editor. When you save it,
it'll refresh in the web page. Wait
for the magic yellow glow that means
that the radiation has taken effect!
Vimperator makes Firefox act very much like VIM:
Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor. It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.
Once you have the cursor in a text box, hit Ctrl-I to open in your editor, which defaults to gvim.
The current answers don't work anymore now that Mozilla removed XUL in favour of WebExtensions. With recent firefox versions, there are the following options (sorted in descending order by the current popularity on addons.mozilla.org).
GhostText provides instant synchronization between editor and textbox via editor-specific plugins. The project is on github and the vim extension is written in Tcl.
withExEditor is cross-platform but requires a native application written in node.js. In addition to editing text fields it also allows viewing the source of the page, MathML, SVG and the current selection. The project on github and the native node.js application
Textern requires a (currently) Linux-only native application written in Python. Synchronizes the content of the text field while you type in the editor. The extension and the native app can be found on github
Tridactyl is probably what you're looking for nowadays.
It's the spiritual successor to the likes of Pentadactyl and Vimperator, which are not available for the current version of Firefox.
If you want something more like It's All Text, where the editing area appears right on top of the browser text area rather than launching an editor window, and you're willing to use Neovim, check out firenvim.
It's All Text! will let you use whatever editor you want. To use vim with it, you'll need a small shell script to open it in a terminal:
#!/bin/sh
exec xterm -e /usr/bin/vim "$#"
If you have GVim, you won't need the shell, script, obviously.
ViewSourceWith is another addon worth lookng at. It supports more than just edit boxes and text. For example, you can configure it to open images in the GIMP.
Another feature that I find useful is that it can pop-up a dialog box that shows all the js and css scripts used on the page. You can then choose to view/edit file in your preferred editor.
For answering questions on SO, you may also want to get the Vim Markdown Syntax file
The "It's all Text" extension, perhaps?
http://addons.mozilla.org/en-US/firefox/addon/4125
If you use vimperator and have the markdown syntax file installed, a useful line for your .vimperatorrc is:
au LocationChange .* :set editor="gvim -f"
au LocationChange stackoverflow\.com :set editor="gvim -f -c 'set ft=mkd'"
This will tell vim to do syntax highlighting for markdown when you are on stackoverflow.com, but not when you are any other site. There are similar hacks for wikipedia/mediawiki etc. Enjoy :)
One way to do this is to use the vimperator extension - of course, that does a lot more than what you're looking for.
At the time of writing it is experimental, but the jV extension looks good. To quote from the page:
This extension makes all html textareas into a very stripped-down version of Vi[m]. It's modal, supports infinite undo, has register support, search, visual mode, and various movement and editing commands.
When using Vimperator in Windows (I am using Vista) you may need to double-escape the path to gvim.exe to use it as the external editor. Single escaping did not work for me as Vimperator unescapes it twice. Eg:
:set editor="C:\\\\Program\\ Files\\ (x86)\\\\Vim\\\\vim72\\\\gvim.exe" -f
Then while in a text box you use Ctrl+I and it will open gvim for editing. When you save and exit it will update the text box.
There is an experimental way to directly embed the real vim in firefox using embedded editor - though it requires mozplugger and will only work on Linux.
Try out the wasavi extension. You might want to check out the all versions page to make sure you try out the latest version. (Copy of this answer.)
You can also use the ViewSourceWith addon to achieve the same. Just right-click on any text input and you can edit it using Vim.
As said by others,
as a Vi/(g)Vim user you'll probably want to look at the Vimperator addon, which also provides the what you ask:
inside a textbox, hit <C-i> to launch the external editor.
(can be defined in _vimperatorrc: set editor=gvim -f )
A hint for Mac users: if you want to use "It's all text" with vim, the easiest way is to use http://code.google.com/p/macvim/ . Point "It's all text" to the mvim script that's provided along with the .app (you can place this script anywhere, I choose /usr/bin/ so that I can load mvim from the command line)
Pterosaur is a Firefox plugin that allows you to use Vim in all input fields. It uses an actual Vim process in the background so it has all the functionality you expect, including reading your .vimrc configuration and your plugins.
With Firefox-57 on Linux, I installed textern https://addons.mozilla.org/en-US/firefox/addon/textern/, and found it to be a suitable replacement for ViewSourceWith for editing text boxes.

Resources