Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 53 lines (40 sloc) 3.221 kB
#!/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 can find a copy of the GNU General Public License on <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
#Jumper is a simple script to add aliases to your .bashrc file. To insert a bookmark you just type -after installation- the command 'jump BOOKMARK_NAME BOOKMARK_DESTINATION'.
#After this you should reload your .bashrc-file with the command 'source ~/.bashrc'.
#Before installing Jumper you should make sure that the Ruby Interpreter is installed on your system. Also the Rubygems package should be installed, you can find this in the package manager of all major distro's.
#The script is only tested on Linux but should work on all UNIX/Linux based systems.
#After installing the Ruby Interpreter and the Rubygems package run the command: 'gem install jumper'
#Then run the command 'gem contents jumper', this will print the location of all the jumper-files. Next, open your favorite text-editor and open your .bashrc file. At the end of this file you should add the next line: 'alias jump="ruby PATH_TO_JUMP.RB_FILE"'
#Next you reload your .bashrc file (source ~/.bashrc). Now you can add bookmarks (aliasses to your .bashrc). You can change dir with the command 'jump-BOOKMARK_NAME', if you want a list of all your bookmarks, type 'alias'.
#If you have problems running the script: please make sure that the jump.rb script is executable.
#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
Jump to Line
Something went wrong with that request. Please try again.