cetus 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -76,14 +76,21 @@ Optionally has interface to `z` and `viminfo` -- can be replaced with what you u
76
76
 
77
77
  ## INSTALL ##
78
78
 
79
- Copy cetus.rb to somewhere on your path, e.g. $HOME/bin
79
+ (I have renamed cetus.rb to cetus and created a gem, so its in the bin folder)
80
80
 
81
- cp cetus.rb ~/bin
81
+ Copy cetus to somewhere on your path, e.g. $HOME/bin
82
82
 
83
- alias c=~/bin/cetus.rb
83
+ cp cetus ~/bin
84
+
85
+ alias c=~/bin/cetus
84
86
 
85
87
  $ c
86
88
 
89
+ Or :
90
+
91
+ gem install cetus
92
+ alias c=cetus
93
+
87
94
  To quit, press "Q" or :q or :wq or :x. If you have created bookmarks, they will be saved with :x and :wq. :q will warn if you quitting with unsaved bookmarks. Used files and dirs are also saved when saving happens. However, if you have not saved bookmarks then you will not be prompted to save used dirs and files.
88
95
 
89
96
  Be sure to try zfm, too. zfm requires only zsh and contains a VIM mode too if that interests you.
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # ----------------------------------------------------------------------------- #
3
- # File: cetus.rb
3
+ # File: cetus
4
4
  # Description: Fast file navigation, a tiny version of zfm
5
5
  # but with a diffrent indexing mechanism
6
6
  # Author: rkumar http://github.com/rkumar/cetus/
7
7
  # Date: 2013-02-17 - 17:48
8
8
  # License: GPL
9
- # Last update: 2013-03-03 18:01
9
+ # Last update: 2013-03-05 15:51
10
10
  # ----------------------------------------------------------------------------- #
11
11
  # cetus.rb Copyright (C) 2012-2013 rahul kumar
12
12
  require 'readline'
@@ -21,7 +21,7 @@ require 'fileutils'
21
21
  # copy into PATH
22
22
  # alias c=~/bin/cetus.rb
23
23
  # c
24
- VERSION="0.1.1-b"
24
+ VERSION="0.1.2"
25
25
  O_CONFIG=true
26
26
  CONFIG_FILE="~/.lyrainfo"
27
27
 
@@ -613,7 +613,9 @@ end
613
613
  def goto_dir
614
614
  print "Enter path: "
615
615
  begin
616
- path = gets.chomp
616
+ #path = gets.chomp
617
+ path = Readline::readline('>', true)
618
+ return if path == ""
617
619
  #rescue => ex
618
620
  rescue Exception => ex
619
621
  perror "Cancelled cd, press a key"
@@ -706,7 +708,8 @@ end
706
708
  ## take regex from user, to run on files on screen, user can filter file names
707
709
  def enter_regex
708
710
  print "Enter (regex) pattern: "
709
- $patt = gets().chomp
711
+ #$patt = gets().chomp
712
+ $patt = Readline::readline('>', true)
710
713
  ctr = 0
711
714
  end
712
715
  def next_page
@@ -753,6 +756,8 @@ def main_menu
753
756
  :F => :filter_menu,
754
757
  :c => :command_menu ,
755
758
  :B => :bindkey_ext_command,
759
+ :M => :newdir,
760
+ "%" => :newfile,
756
761
  :x => :extras
757
762
  }
758
763
  menu "Main Menu", h
@@ -847,7 +852,7 @@ def command_menu
847
852
  # should be able to sort THIS listing and not rerun command. But for that I'd need to use
848
853
  # xargs ls -t etc rather than the zsh sort order. But we can run a filter using |.
849
854
  #
850
- h = { :t => :today, :D => :default_command }
855
+ h = { :t => :today, :D => :default_command , :R => :remove_from_list}
851
856
  if $editor_mode
852
857
  h[:e] = :pager_mode
853
858
  else
@@ -1022,7 +1027,9 @@ end
1022
1027
  def subcommand
1023
1028
  print "Enter command: "
1024
1029
  begin
1025
- command = gets().chomp
1030
+ #command = gets().chomp
1031
+ command = Readline::readline('>', true)
1032
+ return if command == ""
1026
1033
  rescue Exception => ex
1027
1034
  return
1028
1035
  end
@@ -1242,7 +1249,9 @@ def file_actions action=nil
1242
1249
  refresh
1243
1250
  when :move
1244
1251
  print "move #{text} to : "
1245
- target = gets().chomp
1252
+ #target = gets().chomp
1253
+ target = Readline::readline('>', true)
1254
+ return if target == ""
1246
1255
  if target.size > 2
1247
1256
  if File.directory? target
1248
1257
  FileUtils.mv text, target
@@ -1255,7 +1264,9 @@ def file_actions action=nil
1255
1264
  end
1256
1265
  when :zip
1257
1266
  print "Archive name: "
1258
- target = gets().chomp
1267
+ #target = gets().chomp
1268
+ target = Readline::readline('>', true)
1269
+ return if target == ""
1259
1270
  # don't want a blank space or something screwing up
1260
1271
  if target && target.size > 3
1261
1272
  if File.exists? target
@@ -1378,11 +1389,11 @@ end
1378
1389
  # i need to do a shell join if I am to pipe ffiles to say: xargs ls -t
1379
1390
  # but if i want to pipe names to grep xxx then i need to join with newlines
1380
1391
  def pipe
1381
- #print "Enter pipe to filter existing files through: "
1382
- #pipe = gets().chomp
1383
- #if pipe != ""
1384
- #end
1385
1392
  end
1393
+
1394
+ ## some cursor movement functions
1395
+ ##
1396
+ #
1386
1397
  def cursor_scroll_dn
1387
1398
  moveto(pos() + MSCROLL)
1388
1399
  end
@@ -1443,6 +1454,8 @@ end
1443
1454
  def file_matching? file, patt
1444
1455
  file =~ /#{patt}/
1445
1456
  end
1457
+
1458
+ ## generic method to take cursor to next position for a given condition
1446
1459
  def return_next_match binding, *args
1447
1460
  first = nil
1448
1461
  ix = 0
@@ -1500,4 +1513,62 @@ def revert_dir_pos
1500
1513
  raise "cursor is nil" unless $cursor
1501
1514
  end
1502
1515
  end
1516
+ def newdir
1517
+ print
1518
+ print "Enter directory name: "
1519
+ str = Readline::readline('>', true)
1520
+ return if str == ""
1521
+ if File.exists? str
1522
+ perror "#{str} exists."
1523
+ return
1524
+ end
1525
+ begin
1526
+ FileUtils.mkdir str
1527
+ $used_dirs.insert(0, str) if File.exists?(str)
1528
+ refresh
1529
+ rescue Exception => ex
1530
+ perror "Error in newdir: #{ex}"
1531
+ end
1532
+ end
1533
+ def newfile
1534
+ print
1535
+ print "Enter file name: "
1536
+ str = Readline::readline('>', true)
1537
+ return if str == ""
1538
+ system "$EDITOR #{str}"
1539
+ $visited_files.insert(0, str) if File.exists?(str)
1540
+ refresh
1541
+ end
1542
+
1543
+ ##
1544
+ # remove current entry from used dirs list, since we may not want some entries being there
1545
+ #
1546
+ def remove_from_list
1547
+ if $selected_files.size > 0
1548
+ sz = $selected_files.size
1549
+ print "Remove #{sz} files from used list (y)?: "
1550
+ ch = get_char
1551
+ return if ch != "y"
1552
+ $used_dirs = $used_dirs - $selected_files
1553
+ $visited_files = $visited_files - $selected_files
1554
+ unselect_all
1555
+ $modified = true
1556
+ return
1557
+ end
1558
+ print
1559
+ ## what if selected some rows
1560
+ file = $view[$cursor]
1561
+ print "Remove #{file} from used list (y)?: "
1562
+ ch = get_char
1563
+ return if ch != "y"
1564
+ file = File.expand_path(file)
1565
+ if File.directory? file
1566
+ $used_dirs.delete(file)
1567
+ else
1568
+ $visited_files.delete(file)
1569
+ end
1570
+ refresh
1571
+ $modified = true
1572
+ end
1573
+
1503
1574
  run if __FILE__ == $PROGRAM_NAME
data/cetus.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cetus/version'
4
+ #require 'cetus/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "cetus"
8
- spec.version = Cetus::VERSION
8
+ spec.version = "0.1.3"
9
9
  spec.authors = ["Rahul Kumar"]
10
10
  spec.email = ["sentinel1879@gmail.com"]
11
11
  spec.description = %q{lightning fast file navigator}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cetus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -47,7 +47,7 @@ description: lightning fast file navigator
47
47
  email:
48
48
  - sentinel1879@gmail.com
49
49
  executables:
50
- - cetus.rb
50
+ - cetus
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
@@ -56,10 +56,8 @@ files:
56
56
  - LICENSE.txt
57
57
  - README.md
58
58
  - Rakefile
59
- - bin/cetus.rb
59
+ - bin/cetus
60
60
  - cetus.gemspec
61
- - lib/cetus.rb
62
- - lib/cetus/version.rb
63
61
  homepage: http://github.com/rkumar/cetus
64
62
  licenses:
65
63
  - MIT
@@ -75,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
73
  version: '0'
76
74
  segments:
77
75
  - 0
78
- hash: 3898393208339945918
76
+ hash: 3846346114453194451
79
77
  required_rubygems_version: !ruby/object:Gem::Requirement
80
78
  none: false
81
79
  requirements:
@@ -84,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
82
  version: '0'
85
83
  segments:
86
84
  - 0
87
- hash: 3898393208339945918
85
+ hash: 3846346114453194451
88
86
  requirements: []
89
87
  rubyforge_project:
90
88
  rubygems_version: 1.8.25
data/lib/cetus.rb DELETED
@@ -1,5 +0,0 @@
1
- require "cetus/version"
2
-
3
- module Cetus
4
- # Your code goes here...
5
- end
data/lib/cetus/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module Cetus
2
- VERSION = "0.1.1"
3
- end