Sunday, March 24, 2013

setting "rm" to move files (and folders) to trash-"rm -rf" Undo

Step1. sudo apt-get install trash-cli

Trash-cli:This package provides a command line interface trashcan utility compliant with the FreeDesktop.org Trash Specification. It remembers the name, original path, deletion date, and permissions of each trashed file

Step2sudo gedit /usr/local/bin/trash-rm

in Ubuntu 10.04 i found it to be sbin than bin so command might be 

sudo gedit /usr/local/sbin/trash-rm

Step 3
Paste this content 
#!/bin/bash
# command name: trash-rm
shopt -s extglob
recursive=1
declare -a cmd
((i = 0))
for f in "$@"
do
case "$f" in
(-*([fiIv])r*([fiIv])|-*([fiIv])R*([fiIv]))
tmp="${f//[rR]/}"
if [ -n "$tmp" ]
then
#echo "\$tmp == $tmp"
cmd[$i]="$tmp"
((i++))
fi
recursive=0 ;;
(--recursive) recursive=0 ;;
(*)
if [ $recursive != 0   -a  -d "$f" ]
then
echo "skipping directory: $f"
continue
else
cmd[$i]="$f"
((i++))
fi ;;
esac
done
trash "${cmd[@]}"

Save and Exit

Set Correct executable rights on the created file
Step:4
sudo chmod +x /usr/local/bin/trash-rm


Step 5:
gedit ~/.bashrc


Step 6:
alias rm = "trash-rm"
Step7:$bash
Re run bash on linux terminal to re run the bashrc

Step8:

Try by creating a file and then using rm -rf "createdFile.txt"

find that file in Trash 













Tuesday, March 19, 2013

ECLIPSE Shortcut for converting lower case to upper and vice versa

Just a quick short cut which is very useful for developers to convert the selected lower case text to Upper case and vice versa

Lower case: CTRL+SHIFT+Y (CMD+SHIFT+Y on Mac OS X)
Upper case: CTRL+SHIFT+X (CMD+SHIFT+X on Mac OS X)

The good thing here is you can select one or multiple characters/word/lines by using Using + ->/<-/DownArray and then convert all of it at once.