Where is the Trash directory? - linux-mint

The trash spec tells me that the Trash directory is here: $XDG_DATA_HOME/Trash
Looking at my environment variables on my Linux Mint system, I find a bunch of XDG stuff, but no XDG_DATA_HOME
I've done some looking, but so far I have not been able to locate the Trash directory. Where is it?

your home trash directory MUST be available and defined.
Usually it's under ~/.Trash or ~/.local/share/Trash as default
you can echo $XDG_DATA_HOME to display it, if you get nothing, you can set it by yourself.
XDG_DATA_HOME=/usr/local/share/
export XDG_DATA_HOME
and
XDG_DATA_DIRS=/usr/local/share/
export XDG_DATA_DIRS
for details see setting XDG_DATA_DIRS and XDG_DATA_HOME
and I recommend that you make trash-cli as an alternative for the rm, it's the command line interface to FreeDesktop.org Trash,
see https://pypi.python.org/pypi/trash-cli/0.12.9.14
https://github.com/andreafrancia/trash-cli

your home trash directory MUST be available and defined.
Usually it's under ~/.Trash or ~/.local/share/Trash as default
you can echo $XDG_DATA_HOME to display it, if you get nothing, you can set >it by yourself.
First it is impossible to set something you cannot find in the first place.
Secondly env | grep XDG does not return any variable XDG_DATA_HOME, so that provided no help whatsoever. Thirdly, Google search on e.g. "where is linux Trash folder stored" does indeed turn up results -- namely this page and others like it. Search engines are source referrers, not source providers. If someone hasn't already posted it somewhere, it won't show in Google or anywhere else. Suggesting a Google search as an answer is not helpful.
So indeed, find / -iname trash will find it (recommend adding 2>/dev/null to eliminate all errors that will occur for inaccessible files), but novices have a lot of trouble with find's syntax.
So yes, it is usually ~/.Trash or ~/.local/share/Trash.
As for trash-cli, yes very helpful, but the correct instructions for it are:
sudo apt install trash-cli -y
alias rm=trash-put
alias rm >> ~/.bashrc ( or >> ~/.bash_aliases)
Now, I would like to know, if I set XDG_DATA_HOME to /tmp, will trashing a file move to /tmp instead? The concept of a Trash folder is great, but I'd like a little more sophistication like an Archive folder where I can archive-put little used files that I still want to keep but keep out of my main folder stash to eliminate clutter. I'm no linux novice, but I do have limited time--so that is why we collaborate--I save you time, you save me time!! I hope. Less is more, more or less.

Related

How to find out current directory and go to a directory in MySQL console?

I have the following instruction in I need to perform to run a web app I that have received:
"Go to the directory where the app is unpacked and type 'gradle jettyRun'."
Sounds simple enough, if you know the commands for finding out your current directory and changing it. The problem is, searching for these basic things only nets a huge amounts of irrelevant answers to much more advanced questions where the same terms are used with a slightly different meaning. So what do they exactly mean by what they say and how do I achieve that? It sound's so simple I'm almost embarrased to have to ask it, yet I'm still dumbfounded by the MySQL command line enough to have to.
This has nothing to do with the MySQL command line (>>>), or MySQL itself. This is simply saying:
Open your terminal or shell. In Windows, this is called Command Prompt.
Change the directory to where the files are located, you do this with the cd (change directory) command.
Next you simply type gradle jettyRun.

options "--read-only" Ipython Notebook

I can't run my ipython notebook with the --read-only option.
It says :
[NotebookApp] CRITICAL | Unrecognized flag: '--read-only'
It's weird because I've seen several blog mentionning it.
I'm running with the 1.1 version of ipython.
Do you know if this option was removed or moved elsewhere?
There is a super easy way to do what you're trying to do I think though--simply use OS security.
Do this:
When you're ready to deploy to read only, make a special folder
for your read-only work, and copy your *.ipynb files into that.
Make the *.ipynb files read-only at the Linux level: chmod 444
*.ipynb.
Run iPython Notebook from that directory. Use a different port
so that it won't conflict.
Send the URL to everyone using the URL that has the read-only
port.
They can then read it all, even run code, but they will not be
able to save changes.
They cannot navigate anywhere outside that directory. E.g. the
little home icon only brings them to the folder with your read-only
content.
Thus they have full access to the page and its functionality, but
cannot mess it up on anyone else. And all you need is a cp and a
chmod. Profit!
At least this solved my need. I have my regular port with write authority for all my development, then I copy it over, chmod it, and let people at it. Works just fine for me.
Hope this helps others!
Yes the option was removed, it might be re-introduced in another form later when nbconvert/nbviewer is refined, but you better run your own local instance of nbviewer to this effect.

Is there a method for sharing and syncing the iOS simulator Applications folder

Our sales team often needs to give demos of apps currently in development. We've used a variety of methods to get them installed on their laptops but everything has been very manual.
The initial method we were using had us downloading the source code and compiling each and every project for each and every salesman. Very time consuming and annoying.
Then we got a little smarter and realized that we could copy out the Applications folder for the iOS simulator and just past that over the iOS simulator's Applications folder on each salesman's laptop. Much better, but still the manual part of copying them all over to each laptop.
So I started poking around about some folder syncing options for macs and came across this technique http://www.youtube.com/watch?v=iWoXPWlu_Dk
Very awesome and seemed to meet my need exactly. I had one central shared folder I could throw new iOS applications into and then the salesmen's laptops would automagically sync with that applications folder and new apps would just appear with no need to ever have their laptops here.
Unfortunately, the iOS simulator does not seem to be recognizing the Applications folder when it's a symbolic link or alias. Is there some Mac magic that could make this work? (I'm a Windows guy normally, just recently been working in the iOS world, so there could be something basic I'm missing here).
I'd love to have the Applications folder /Application Support/iPhone Simulator/5.1/Applications be a shared folder that syncs automatically for them, grabbing any new applications we have ready for demos (and getting them updates to old ones). Just seems like a nice smooth way to get them early builds.
We've used services like TestFlight for the actual devices and that's a great option for that, but when they don't have a device handy or are just blasting through demos on their laptops we'd love to have a nice easy process for keeping them up to date with new builds for their simulator install.
First a bit of background, you don't really need this, but I like teaching :).
On Unix, and now MacOS, there are two basic kinds of links. 'normal' links, and symbolic links. Alias, on windows, unix and mac are a kind of symbolic link: the link contains a reference to the original file. Normal, or hard links create a second directory entry that points to the data, if you delete the original file, the OS knows that there is still another entry pointing to it, so it only actually deletes the file (or directory) when all hard links have been removed. The disadvantage of hard links is that they have to be on the same file system, so that the file system can keep count of how many hard links there are.
OK, I've just installed Dropbox, and it seems that it creates a real folder in the user's home directory, so unless you're a complicated disk partitioning scheme, or file vault 1, where the user's home directory is actually an encrypted disk image, you can use a hard link. It also means that you don't need to copy or sync, as Dropbox is already doing that.
One thing not corrected, but didn't actually point out is that in your post, you seem to be copying to /Application Support, not ~/Library/Application Support or /Library/Application Support. Since you've got the basic scheme working without dropbox, I'll assume that is a typo.
Before I give you the commands, you might want to delete the old iPhone Simulator Applications directory with the Finder, instead of using the rm command, as the rm command is potentially very destructive.
OK, finally, the commands to do the linking; the quotes are important whenever filenames contain spaces. This example is for ~/Library
rm -rf "~/Library/Application Support/iPhone Simulator/5.1/Applications"
ln "~/Dropbox/Simulator Applications" "~/Library/Application Support/iPhone Simulator/5.1/Applications"
This should work, you can stop reading now, the rest is just more education :)
Tilde (~) is a short cut for the users home directory. Use the commands without this to work on /Library instead.
If you want to be sure you've got the exact path, you can drag files and folders from a finder window into the terminal, the path gets pasted instead of the file.
If you're messing with stuff in the root filesystem, you might need superuser rights. If you are logged in with an admin account, you can run single commands with superuser access as follows.
sudo ln "/Library/Application Support/iPhone Simulator" fred
The shell asks for your password, and then runs the command for you as superuser.
sudo remembers the authorization for a few minutes, then you have to authenticate again.
Haven't tested this since I only have one Mac, but give this a try:
Install Dropbox
Create a shared folder there and copy your apps from /Users/USERNAME/Library/Application Support/iPhone Simulator/5.1/Applications
Create a shell script to copy them back to the simulator's location, and add it to the shared folder. It should look something like this:
#!/bin/sh
cp -R ~/Dropbox/Appfolder/appname ~/Library/Application Support/iPhone Simulator/5.1/Applications/
Have your users sync their dropboxes to get the files, then run the shell script to copy the files.

Eclipse's local history...where are files saved?

Can someone explain how Eclipse's local history works?
I accidentally overwrote a file in a project but need to revert to an earlier version.
Is there a chance that Eclipse has the older file cached somewhere?
To complete CurtainDog's answer: from eclipse FAQ
Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history. At any time, you can compare or replace a file with any older version from the history.
Although this is no replacement for a real code repository, it can help you out when you change or delete a file by accident.
Local history also has an advantage that it wasn’t really designed for: The history can also help you out when your workspace has a catastrophic problem or if you get disk errors that corrupt your workspace files.
As a last resort, you can manually browse the local history folder to find copies of the files you lost, which is a bit like using Google’s cache to browse Web pages that no longer exist.
Each file revision is stored in a separate file with a random file name inside the history folder. The path of the history folder inside your workspace is
.metadata/.plugins/org.eclipse.core.resources/.history/
You can use your operating system’s search tool to locate the files you are looking for.
Note, if your need to import your local history into a new workspace, you will need both:
.metadata/.plugins/org.eclipse.core.resources/.history
.metadata/.plugins/org.eclipse.core.resources/.project
to have a functional local history in that new workspace.
Try right-clicking on the file in eclipse, and choose Replace With->Local History.
If there's history available, it'll show up as a list of edit times.
But more importantly, as pointed out in other answers, be sure to put your files in version control! SVN is pretty easy to set up (you don't need a server; it can just use the file system); use it even if you aren't sharing with others.
A tip: whenever you hear yourself say "yes!", check in all of your code. 10 minutes later, you'll be saying "how did I mess that up?"
If you have lost a full package structure due to accidental deletion or svn/cvs override, select the project> right click> Restore from local history => select the files.
VonC's answer has all the information you need for finding the location of your code backups. I would simply add that if you are on a Mac or Linux, you can do something like this:
$ cd [WORKSPACE]/.metadata/.plugins/org.eclipse.core.resources/.history/
$ grep -rl "class Foo" . | xargs ls -lt
This will find all the versions of a file that contains a particular string (ie. "class Foo"), and sort them by date/time to easily find the most recent version.
You can use the link http://wiki.eclipse.org/FAQ_Where_is_the_workspace_local_history_stored%3F is very helpfull
Open the CVS view and you should see a filter for local history. You should then be able to right-click on the correct version and Get Contents or do a manual compare and merge. I'm not sure what the eclipse defaults are for keeping local history but there is a decent chance you'll be able to get your stuff back if you act quickly.

Can you "ignore" a file in Perforce?

I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'.
I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in. Does P4 have the equivalent of Subversion's 'ignore file' feature?
As of version 2012.1, Perforce supports the P4IGNORE environment variable. I updated my answer to this question about ignoring directories with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess.
Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this:
-//depot/foo/*.dll //CLIENT/foo/*.dll
-//depot/foo/.../*.dll //CLIENT/foo/.../*.dll
The first line removes them from the directory "foo" and the second line removes them from all sub directories. Now, when you 'Reconcile Offline Work...', all the .dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to.
You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won't be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn't matter).
-//depot/foo.../*.dll //CLIENT/foo.../*.dll
Yes, But.
Perforce version 2012.1 added a feature known as p4ignore, inspired by Git. However the Perforce developers made a change to the behaviour, without justification, that happens to make the feature a lot less useful.
Whilst Git takes rules from all .gitignore files, Perforce doesn't know where to look until you specify a filename in an environment variable P4IGNORE. This freedom is a curse. You can't hack on two repositories that use different names for their ignore files.
Also, Perforce's ignore feature doesn't work out the box. You can set it up easily enough for yourself, but others don't benefit unless they explicitly opt-in. A contributor who hasn't may accidentally commit unwelcome files (eg. a bin folder created by a build script).
Git's ignore feature is great because it works out the box. If the .gitignore files are added to the repository (everyone does this), they'll work out the box for everyone. No-one will accidentally publish their private key.
Amusingly, the Perforce docs shows '.p4ignore' as an example ignore rule, which is backwards! If the rules are useful, they should be shared as part of the repository.
Perforce could still make good on the feature. Choose a convention for the file names, say p4ignore.txt, so the feature works out the box. Drop the P4IGNORE environment variable, it's counterproductive. Edit the docs, to encourage developers to share useful rules. Let users write personal rules in a file in their home folder, as Git does.
If you know anyone at Perforce, please email them this post.
This works as of Perforce 2013.1, the new P4IGNORE mechanism was first added in release, 2012.1, described on the Perforce blog here:
https://www.perforce.com/blog/new-20121-p4ignore
As it's currently described, you set an environment variable "P4IGNORE" to a filename which contains a list of the files to ignore.
So you can check it out to see how you like it.
If you want a solution that will apply to all work-spaces without needing to be copied around, you (or your sysadmin) can refuse submission of those file-types through using lines like the below in the p4 protect table:
write user * * -//.../*.suo
write user * * -//.../*.obj
write user * * -//.../*.ccscc
I remember doing this before, but I don't have the necessary permissions to test this here. Check out Perforce's Sysadmin guide and try it out
Perforce Streams makes ignoring files much easier, as of version 2011.1. According to the documentation, you can ignore certain extensions or certain paths in your directory.
From p4 help stream
Ignored: Optional; a list of file or directory names to be ignored in
client views. For example:
/tmp # ignores files named 'tmp'
/tmp/... # ignores dirs named 'tmp'
.tmp # ignores file names ending in '.tmp'
Lines in the Ignored field may appear in any order. Ignored
names are inherited by child stream client views.
This essentially does what #raven's answer specifies, but is done easier with streams, as it automatically propagates to every work-space using that stream. It also applies to any streams inheriting from the stream in which you specify the ignore types.
You can edit the stream via p4 stream //stream_depot/stream_name or right-clicking the stream in p4v's stream view.
And as #svec noted, the ability to specify ignore files per workspace is coming soon, and is in fact in P4 2012.1 beta.
Will's suggestion of using .p4ignore only seems to work with the WebSphere Studio (P4WSAD) plugin. I just tried it on my local windows box and any files and directories that I listed were not ignored.
Raven's suggestion of modifying your client spec is the correct way under Perforce. Proper organization of your code/data/executables and generated output files will make the process of excluding files from being checked in much easier.
As a more draconian approach, you can always write a submit trigger which will reject submission of change-lists if they contain a certain file or files with a certain extension, etc.
HISTORICAL ANSWER - no longer correct. At the time this was written originally it was true;
You can not write and check in a file that the server will use to make ignore rules; general glob or regexp file pattern ignore in perforce.
Other answers have global server configurations that are global (and not per folder).
The other answers show things that might work for you, if you want one line in your view per folder times number of extensions you want to ignore in that single folder, or that provide this capability in WebSphere Studio plugins only, or provide capability for server administrators, but not available to users.
In short, I find Perforce really weak in this area. While I appreciate that those who use the Eclipse Plugin can use .p4ignore, and I think that's great, it leaves those of us that don't, out in the dark.
UPDATE: See accepted answer for new P4IGNORE capability added mid-2012.
I have found it easiest to reconcile offline work using a BASH script like this one:
#!/bin/bash
# reconcile P4 offline work, assuming P4CLIENT is set
if [ -z "$P4CLIENT" ] ; then echo "P4CLIENT is not set"; exit 1; fi
unset PWD # confuses P4 on Windows/CYGWIN
# delete filew that are no longer present
p4 diff -sd ... | p4 -x - delete
# checkout files that have been changed.
# I don't run this step. Instead I just checkout everything,
# then revert unchanged files before committing.
p4 diff -se ... | pr -x - edit
# Add new files, ignoring subversion info, EMACS backups, log files
# Filter output to see only added files and real errors
find . -type f \
| grep -v -E '(\.svn)|(/build.*/)|(/\.settings)|~|#|(\.log)' \
| p4 -x - add \
| grep -v -E '(currently opened for add)|(existing file)|(already opened for edit)'
I adapted this from this Perforce Knowledge Base article.
I'm looking for a .p4ignore like solution as well (and not one tied to a particular IDE). Thus far, the closest thing I've found is p4delta. It sounds like it will do exactly what the original poster was asking, albeit through another layer of indirection.
http://p4delta.sourceforge.net
Unfortunately, while this does seem to produce the proper list of files, I can't get "p4delta --execute" to work ("Can't modify a frozen string") and the project has not been updated in year. Perhaps others will have better luck.
If you are using the Eclipse Perforce plugin, then the plugin documentation lists several ways to ignore files.