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

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.

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

Keep output from less on screen after exiting in Git Bash for Windows

To list dir in my GIT BASH Terminal I use the following command
ls -al | less (to show one page at a time).
However upon exiting from the listing using ZZ or Q, the display on the terminal is getting refreshed and I am losing all the content just listed, and I am going back to the command line.
What would be nice is to use CTL-C key combination out of the ls listing at the point where I want it, and to keep that content displayed on the terminal so I can copy the file name or whatever. Any suggestions how to solve this problem?
My .bashrc file is pretty minimal and I don't have much going on there.
Reproduced here.
alias 'll=ls -al|less'
PS1="\$PWD:\d\n\$"
Thanks for any pointers.

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).

How do I run a Ruby script created in text editor in the Mac OS Terminal?

I just started reading the Well-Grounded Rubyist, and I am just beginning to use Ruby in my terminal on my Mac.
I'm on the very first lesson, creating a Celsius to Farenheit converter in a text editor. I've saved the code as an .rb file by using Textmate (my text editor). The file name is c2f.rb. The file is saved in a folder on my desktop titled "Rubycode".
I am having difficulty running the .rb file in the terminal however. I've tried many different methods of trying to call the file, including using:
cd /Users/rexrose/Desktop/Rubycode/c2f
and many others.
Any thoughts on what exactly, I'm supposed to type into terminal in order to call the c2f file?
Thanks in advance.
I just started reading Well-Grounded Rubyist.
That's a very good book. I consider it more of an intermediate level book than a beginner book, but no matter.
I've tried many different methods of trying to call the file,
including using
cd /Users/rexrose/Desktop/Rubycode/c2f
The cd command means "change directories" and you cannot change directories to a file. Instead, you have to change directories to the directory containing the file:
$ cd /Users/rexrose/Desktop/Rubycode
Then you can execute your program contained in the file c2f.rb like this:
$ ruby c2f.rb
Here are some Terminal tips:
1) You can use ~ instead of /Users/YourUserName, so you can save some typing by doing this:
$ cd ~/Desktop/Rubycode
Typing '~' instead of '/Users/YourUserName' will become second nature.
2) Using the cd command with no arguments:
$ cd
will take you to your home directory, i.e. /Users/YourUserName
3) You should change your prompt to indicate what directory you are currently in. To do that, create a file called .bash_profile in your home directory(/Users/YourUserName). Check to see if it exists first:
$ cd
$ ls -al
The command ls -al will show all the files in a directory, including hidden files, which are files whose name begins with a .. If a file named .bash_profile exists, open it; if it doesn't exist, create it. Put this in .bash_profile:
PS1="\w$ "
To get Terminal to recognize the changes, you can either Quit Terminal and relaunch it, or do this:
$ source .bash_profile
Then open a new Terminal widow.
You can also add 'aliases' to .bash_profile. For instance, in my .bash_profile I have the alias 'r' for 'ruby', so that I can execute a ruby program like this:
$ r my_program.rb
In .bash_profile you make an alias like this:
alias r="ruby"
4) Tab completion in Terminal:
You might have noticed that you can type part of a file name, then hit tab and Terminal will complete the file name. Using tab completion, I can execute my ruby program like this:
$ r my_pr<tab>
In fact, I name my practice ruby programs so that I can use tab completion to the greatest effect. I have files named 1.rb, 2.rb, 3.rb, and then I execute one of them by simply typing:
$ r 1<tab>
And in fact, you may not even have to type that! If you hit the up arrow key on your keyboard, Terminal will display the previous command, and if you hit the up arrow key again, you will see the command before that. So you can scroll up to a previous command, then hit return to execute it--without having to type anything.
You should endeavor to use tab completion for each of the file names in a path. For example, if you are cd'ing to /Users/YourUserName/dir1/dir2, you should do this:
$ cd /Use<tab>/YourUser<tab>/di<tab>/di<tab>
The reason you should use tab completion for each filename(by the way in Unix filename is a general term for both directory names and file names) is because when the name won't tab complete, then you are in the wrong directory or you are trying a filename that doesn't exist in that directory. So instead of having to type out the whole path '/Users/YourUserName/dir1/dir2' and then finding out about the error when you hit return, the tab completion will let you know immediately when there is an error(because the filename won't tab complete)--saving you some typing.
5) Because you will probably be using Terminal for mostly ruby programs for awhile, you can set up things so that Terminal will automatically open up in your directory Users/rexrose/Desktop/Rubycode. Put this in .bash_profile:
cd "/Users/rexrose/Desktop/Rubycode" (Here you cannot use ~)
6) Occasionally, you may have to type a long file name that exists on your computer into the command line:
$ cd /Library/SomeLongName/AnotherLongName34832o222/142582dir/some_file.txt
Instead of having to type all that at the command line, you can locate the file in Finder first. Then if you drag the file onto the Terminal window, the file name will be entered at the point of the cursor.
Finally, a better way to organize your files might be to put them in directories below your home directory, like this:
~$ mkdir ruby_programs
~$ cd ruby_programs
~/ruby_programs$ mate 1.rb
First things first: cd stands for "Change directory".
Normally the terminal should open in "~", which is the home directory where most of your things are. In OS X it will be /Users/[username]. It's also possible possible that in OS X, it will save the location of the last session. I also recommend, since you're starting to install, "Iterm2", which is a nice terminal to use. It supports multiple tabs, etc.
Ruby, the interpreter, is the command "ruby". To call a script you have to call Ruby with a filename:
ruby /Users/rexrose/Desktop/Rubycode/c2f/c2f.rb
That is almost the equivalent of:
cd /Users/rexrose/Desktop/Rubycode/c2f/
ruby c2f.rb
It's almost equivalent, but for now the difference shouldn't bother you. Let say that the second way to call the script is more favorable than the first.
Now, the second thing: If you want to try things in Ruby, you can start an interactive shell. The command is "irb".
Type irb and Enter and then you can type Ruby code. If you want to leave, press CTRL+C multiple times.
The last thing, I recommend installing "RVM". It will save you time and pain, I hope. If you want to install Ruby gems, it will not mess with the Ruby already present with the system. That's my personal opinion but I believe lots of people will agree. Even if Ruby comes with OS X, you should install a different Ruby for development. It will make sure that if something goes wrong in dev, it will not mess the Ruby OS X might be using.

Side-by-side view in Vim of svn-diff for entire directory

I have a MacVim setup on my OSX machine so that the default Vim application (ie: /usr/bin/vim) is actually a symbolic link to the command-line version of Vim that ships with MacVim (ie: /Applications/MacVim.app/MacOS/vim), as it provides some key benefits over the stock Vim that ships with OSX10.6.
I periodically need to prepare a diff between a set of files, and export it into a colorful side-by-side-view HTML file. This is commonly achieved via:
vim -d file1 file2
(Within Vim): toHTML
The problem with this is that I have to manually check out the HEAD revision and a specific revision of the two sets of files, and do this operation for each pair of files. This is very time consuming.
Is it possible to have the results of svn diff command piped into Vim so I can have a colorful side-by-side-view diff for an entire directory (ie: the PWD), as opposed to just the unified diff view?
I have found several Vim scripts and bash scripts that attempt to achieve this, but there are two key problems:
I wish to explicitly call vim -d as the diff tool, and not vimdiff, as the MacVim application does not appear to ship with vimdiff, so I would be using the wrong version of Vim when launching the application
I wish to have multi-file diffs generated against an entire directory recursively, as opposed to just one or two files at a time.
If this is not feasible, I could likely create a bash script that more-or-less achieves this, but I'd like to avoid putting together a hacked/unreliable script if there is a more effective means of doing this.
Thank you.
vimdiff is merely an alternate name for vim. The binary checks to see how it's launched and determines its behavior accordingly. (That's why there isn't a different file for gvim and vim also.)
On my Mac OS and Linux machines I created a ~/bin directory, and then inside it created soft-links from the various names to my macvim binary. I put ~/bin very early in my path.
I'm not at work where I could check to make sure, but I think you can change the default SVN diff to point to vimdiff in ~/.subversion/config. Look for the diff-cmd section. https://stackoverflow.com/a/9604604/128421 might give you some useful information too.
You can try my aurum plugin, it ships with :AuVimDiff command which is as well capable of viewing all changes in a multiple tabs with vimdiff split:
AuVimDiff full HEAD 300
and get diffs between two revisions without you having to checkout them manually:
AuVimDiff file file1 HEAD 300
(file file1 part is optional, it will open diffsplit with current file if omitted. All revisions are also optional, for subversion specifying one revision is diffing it with file in the working directory and specifying no revisions is like svn diff: between BASE and working directory.)
300 here is just an example revision.
I have since resolved this fully in another, more recent post of mine. Posting a backtrack URL to it for future readers:
VIM - Passing colon-commands list via command-line

Resources