Sha256: f5efdc82fb200782da56a0699cc7ab453242a9b4fd5385104f32669c4c1b7f86

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

#!/usr/bin/env ruby

# All Jumper code is Copyright 2011 by Pascal Ryckmans <firestarter87@users.sf.net>.
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

#The file to add you bookmark to
$path = File.expand_path("~/.bashrc") 

#Get variables out of command
$info = ARGV[0]
$info1 = ARGV[1]

#Check if bookmark file exists before doing anything
bashchecker = File.exist?($path)

#If .bashrc exists
if bashchecker == true

	#Command handler
	#Check if there's info given, also check if the bookmarked dir exists
	
	bmchecker = File.directory?($info1)
	if ((defined?($info)) && (defined?($info1)) && ($info != nil) && ($info1 != nil) && (bmchecker == true))
          	
		$name = $info.downcase
		puts "Bookmark #{$name} with destination #{$info1} has been added to your bookmarks.\nYou can access your bookmark with the command jump-#{$name}.\nPlease note: If you are running a shell you should reload your .bashrc file (source ~/.bashrc).\nIf you want a list of all your bookmarks just run the command alias."
		open( $path, "a" ) do |bookmarks|
		bookmarks.puts "alias jump-#{$name}=\"cd #{$info1}\"\n"
		end

	else
          	puts "Wrong command. The format of the command needs to be: jump BOOKMARK_NAME BOOKMARK_DESTINATION.\n Or your destination does not exist.\n"
	end

#If the file does not exist: create it
else
	File.open( $path, "w" )
	File.chmod 0644, $path
  	puts "Your .bashrc-file did not existed. The program created it for you, please run your command again."

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jumper-0.1 jump.rb