From 90b074e8ebd54541c5b59d85c079fcccc8a94ec7 Mon Sep 17 00:00:00 2001 From: Dale Campbell Date: Tue, 26 Oct 2010 04:31:04 -0400 Subject: [PATCH] adding gnome trash helper --- bin/trash | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/alias.zsh | 1 + zshrc | 16 +++++++-------- 3 files changed, 63 insertions(+), 8 deletions(-) create mode 100755 bin/trash diff --git a/bin/trash b/bin/trash new file mode 100755 index 0000000..11258ef --- /dev/null +++ b/bin/trash @@ -0,0 +1,54 @@ +#!/usr/bin/env ruby + +# Command line tool for Gnome users to send something to the Trash (with restore info). +# TODO: Support trashing files of the same name. +class Janitor + + TRASH_DIR = File.expand_path(File.join(ENV['HOME'], '.local/share/Trash')) + FILES_DIR = File.join(TRASH_DIR, 'files') + INFO_DIR = File.join(TRASH_DIR, 'info') + + class << self + def sweep!(files = []) + files.each { |file| trash!(file) } + end + + def trash!(file) + return unless File.exists?(file) + $stdout.puts "Trashing #{file}" + create_info_for(file) + move_to_trash(file) + end + + private + + def create_info_for(file) + info_file = File.join(INFO_DIR, "#{file}.trashinfo") + raise "Info file exists for #{file}: #{info_file}" if File.exists?(info_file) + + deletion_date = Time.now.strftime("%Y-%m-%dT%H:%M:%S") + + File.open(info_file, 'w') do |info| + info.puts "[Trash Info]" + info.puts "Path=#{File.expand_path(file)}" + info.puts "DeletionDate=#{deletion_date}" + end + end + + def move_to_trash(file) + system "mv #{file} #{FILES_DIR}" + end + + end # self +end # Janitor + + +if __FILE__ == $0 + if ARGV.empty? + $stderr.puts "No file(s) given!\n" + $stderr.puts "Usage: #{File.basename($0)} .." + exit + end + + Janitor.sweep!(ARGV) +end diff --git a/lib/alias.zsh b/lib/alias.zsh index 325ea5a..77bac11 100644 --- a/lib/alias.zsh +++ b/lib/alias.zsh @@ -30,6 +30,7 @@ alias rails='nocorrect rails' alias gemi='gem install --no-ri --no-rdoc ' alias sgemi='sudo gem install --no-ri --no-rdoc ' alias bundle='nocorrect bundle' +alias autotest='nocorrect autotest' # misc alias pfind='ps aux |grep ' diff --git a/zshrc b/zshrc index 23fa552..8c7e95d 100644 --- a/zshrc +++ b/zshrc @@ -7,12 +7,12 @@ export ZSH_HOME=$HOME/.zsh # Bindings -bindkey -e -bindkey '^A' beginning-of-line -bindkey '^E' end-of-line -bindkey '^r' history-incremental-search-backward -bindkey '^[[A' up-line-or-search -bindkey '^[[B' down-line-or-search +# bindkey -v +# bindkey '^A' beginning-of-line +# bindkey '^E' end-of-line +# bindkey '^r' history-incremental-search-backward +# bindkey '^[[A' up-line-or-search +# bindkey '^[[B' down-line-or-search # Completion autoload -Uz compinit @@ -41,12 +41,12 @@ zle -N self-insert url-quote-magic # ---------------------- # variables # ---------------------- -# export PATH=$PATH:/sbin:/usr/sbin +export PATH=$PATH:$HOME/.zsh/bin export EDITOR=/usr/bin/vim export GREP_OPTIONS='--color=auto' export LC_ALL=C export PAGER=less -export LESS='-M -R -X' +export LESS='-F -M -R -X' export IRB_HISTORY_FILE=$HOME/.irb_history