TextMate suddenly showing <CR> tag in code files - textmate

I have been using TextMate version 2 for MAC from quite some time now, but suddenly yesterday in my code files I am seeing a <CR> tag.
Not sure what the issue is. After doing some googling around I found that it is supposed to be a INVISIBLE character.
But now how do I remove it, can any one suggest any ideas?
Thanks.

Textmate files are set with one of three options..
CR(e.g. Carriage Return or \r) line endings.
LF (e.g. Line Feed or \n)
CRLF (e.g. Carriage Return Line Feed or \r\n)
If a file has inconsistent line endings, Textmate will treat \n as a line ending marker and display <CR> as text.
The issue is caused by a corrupt Launch Services database and can be fixed by running the following command in Terminal and resetting Finder.
sudo /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder
lsregister: [OPTIONS] [-domain { system | local | user | network }]... [path]...
Search the paths for application bundles and add each found item to the Launch
Services database. For domain specifications, ask CF for the list of application
locations in the given domain(s).
-kill Reset the global Launch Services database before doing anything else
-lint Print information about plist errors while registering bundles
-convert Register apps found in older LS database files
-load Load the LaunchServices service plugin if it's not already loaded.
-lazy n Sleep for n seconds before registering apps if the local cache
is aleady populated.
-r Recursively register directory contents, do not recurse into
packages or invisible directories.
-R Recursively register directory contents, including the contents
of packages and invisible directories.
-f force-update registration info even if mod date is unchanged
-v Display progress information.
-dump Display full database contents after registration.
-h Display this help.

Open the file with TextMate, select one <CR>, copy it. Open the "Find" dialogue with the "Regular Expression" option activated. Paste the <CR>, and replace them all with an empty string.

Related

Why is `ls -lF` listing files with the prefix "~$" not present in the directory?

I'm currently practicing basic Shell Commands in WSL, Windows Subsystem for Linux (I do not have a linux system but I want to get familiar with commands).
I start a bash session on the command prompt window and navigate to my desktop using cd . In desktop I noticed that after using ls -lF some files with the prefix ~$ appear, such as: '~$executable.x'* or '~$file.txt'
These files are not currently present under the desktop directory, but I was able to remember that they were at one point (varying from a week to months ago).
When I do the same process in powershell windows (not using linux commands) I noticed that files displayed match the desktop and no extra files are listed.
I was wondering if anyone could explain what ~$ means in this context? my intuition is telling me they are backed up files that are somehow hidden in the desktop. After googling, all I could find is that ~ reefers to the home. I also understand that $ is the default prompt symbol for the bash shell when it is waiting for me to type something, but I'm still confused on why it would show up as a prefix for the name of a file.
Hope I made my question clear.
I'm currently reading "Linux® Command Line and Shell Scripting BIBLE" by Blum and Bresnahan but I could not find an answer there, this is my last resource after many googling attempts. Any other source for more information on the topic would be helpful.
On Windows, files that start with ~ are used for hidden files. More specifically,, the prefix ~$ are often used as backups for programs, should they crash before writing updates to a file (e.g. Microsoft Word, etc.)
From Wikipedia:
The tilde symbol is used to prefix hidden temporary files that are created when a document is opened in Windows. For example, when you open a Word document called “Document1.doc,” a file called “~$cument1.doc” is created in the same directory. This file contains information about which user has the file open, to prevent multiple users from attempting to change a document at the same time.
See: Why does Word make temporary files?
Relevant superuser question: https://superuser.com/questions/405257/what-type-of-file-is-file

How do I revert my .bash_profile back to a TextEdit document?

I was following a Git course on Udacity and we made some changes to our bash profiles.
Somehow my .bash_profile is now recognized as a Unix executable file rather than a TextEdit document. I can still use it as before, but it bothers me that this change has happened. More than anything I would also like to know what is going on under the hood.
Where on my computer (I'm running MacOS) is the data stored that this is an executable? It doesn't have a file extension so how does the computer know? I changed its 'open with' field found in the 'get info' window but it still identifies as an executable.
in unix each file has permission bits which you can see with ls -l. In this case the 'x' bit has been set which means the file is executable. To revert the file back simply execute chmod -x on the file and it will unset the 'x' permission flag making the file a text file.

Where do I find out when a pycharm python file was made?

If there is no way to find out is there any way to find out when a file was first created on a Mac?
Mac shows the created time when you select a file in Finder. Almost always editors depend on os provided attributes for this.
There are at least two ways to determine this, and for any file in OSX.
The first option works if you are familiar with Terminal and navigation in Unix (Bash etc on OSX). Use the list files "ls" command.
Navigate to the folder your pycharm python file is contained in. Use the ls command to list the contents of that folder (directory) and include the options t,r and U.
For example:
ls -alhtrU
This instructs the ls command to list:
"a" both visible and invisible files in the directory,
"l" in long (single column down the page) format,
"h" with human readable file sizes,
"t" listed in order of time modified/last accessed/created,
"r" in reverse so most recently created file is at the bottom of the list and hence visible if the list is long as nearest to your command prompt. Finally add the
"U" directing the ls command to use the date the file was
created as the time information for ordering and displaying the
files.
This method is not perfect. If the file was created last calendar year, only the year is displayed. If the file was created this calendar year, the created date and time to the minute is displayed. If you include an r in the ls command as suggested, the most recently created files appear in the ls list at the bottom (reverse order). This is helpful if there are many files in that folder/directory and your files of interest were created recently compared to the other files in that directory.
There is likely a different unix command to show the creation date and time of the particular file your interested in.
Learning the options available for basic Unix commands can be very helpful. This and other options for the ls command can be found by entering in Terminal.
man ls
This gives you the manual page for the ls command. Press "q" to exit when your finished reading to return to the Terminal command line. Or open a second Terminal window to load man pages so that you can reference your options in one terminal window while practicing them in the command line in another.
The second option is to open the folder the file your interested in sits in, in the OSX GUI.
Open the folder, then go to the Finder Menu, under View, select View Options. You can tick the box to show file "Date Created".
This solution saves you the time required to learn more about the ls Unix command and has the benefit of a real time update as you create new files in that folder, which may be desirable. However, as downside, if your interested in invisible files (begin with a "." as shown in ls command in Terminal), then these will not be visible without additional OSX tweaks. An alternative here is using Finder, Find, for that folder specifically and using the more detailed options available in Find.

export PATH not saving

I'm trying to install the Google SDK
I type:
export PYTHONPATH=$PYTHONPATH:/Users/morganallen/Dropbox/google_appengine
then:
echo $PATH
And I see:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/morganallen/Dropbox/google_appengine
But when I quit terminal and re-open it and type echo $PATH I only see:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Why isn't it saving?
I've seen other answers mentioning a .bashrc file, but I can't find mine? Not sure what to do.
If you type that into the command line, it only applies for the current session (until you close the bash window). Instead, save that line of code into your .bash_profile and it should work for every single session.
A file whose name begins with a period (.) is a hidden file. Depending on the file manager/browser which you may be using, hidden files may not be shown by default. You will need to enable viewing hidden files in the preferences/options as the case may be.
If you are using a command line to list the contents, you can use ls -a instead of plain ls.
And of course, if you need to modify the hidden file using a text editor at the command line itself, (say, using vim/nano etc.) then you can always supply the full name of the file as an argument (including the period).

SVN ignore problem in OS X Lion

Before installing Lion, when I tried to ignore something on my svn, I just typed the following command:
svn propedit svn:ignore .
This opened a temporary file for the current directory with the selected editor and I could write there my patterns, which where ignored by svn.
After I installed Lion, when I type this command the following error appears: The document “svn-prop.tmp” could not be opened. The file doesn’t exist.
Did anybody else met this error before? (I tried googling, but I didn't find any solution).
SVN_EDITOR=/Applications/TextEdit.app/Contents/MacOS/TextEdit
It seems that with Lion it is no more possible to open a file with TextEdit on the command line giving the file name as argument.
A workaround is to use open
export SVN_EDITOR='open -e -W -n '
-e tells to open with TextEdit (use -a if you want to specify a different application)
-W tells open to wait for TextEdit to quit. If not specified svn propedit will read the file before it's edited and return telling the no changes were done.
-n tells to open a new instance of TextEdit even if there is another one already open. On one hand it will avoid that you have to quit an open editor and on the other hand it was not working without the option :-)

Resources