cetus 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -0
- data/bin/cetus +133 -9
- data/cetus.gemspec +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -53,6 +53,8 @@ Other than using bookmarks, you can jump quickly to other directories or open fi
|
|
53
53
|
|
54
54
|
* Use slash "/" to run a regex on the dir listing.
|
55
55
|
|
56
|
+
* Use question "?" view directory tree in order to jump down several levels at once
|
57
|
+
|
56
58
|
* Use ESCAPE or C-c to clear any filter, regex, sort order, sub-listing etc
|
57
59
|
|
58
60
|
* TAB switches between various views such as order by modified time, order by access time, dirs only, oldest files etc.
|
@@ -63,8 +65,16 @@ Other than using bookmarks, you can jump quickly to other directories or open fi
|
|
63
65
|
|
64
66
|
* Use BACKTICK "a" for using `ack` in the current dir. Then you can select from listed files and edit or do whatever. Similarly, BACKTICK "l" for running `locate`, and BACKTICK "/" for running `find`.
|
65
67
|
|
68
|
+
* For small projects with more directories and few files, traversal can be a pain. Now, `dirtree` gives directory tree, and tree gives the entire tree of files and dirs to get to a file deep within instantly. Dirtree is mapped to BACKTICK-t and F3. Tree is mapped to BACKTICK-4 and F4.
|
69
|
+
Thus, F2 gives only child dirs in current dir, F3 gives recursive directories and F4 gives the entire tree.
|
70
|
+
|
66
71
|
* Note that I use readline for most entries, so you can press UP arrow to get previous entries.
|
67
72
|
|
73
|
+
* A new enhanced list mode (Which can be toggled off), which tries to add more files to the list if there are very few shown:
|
74
|
+
- it detects a rubygem dir and shows a few recent files from bin and lib
|
75
|
+
- if there's only one file in the dir and it is a dir, it expands it
|
76
|
+
- if there are less than 15 files in list, it gets the recently modified and recently accessed
|
77
|
+
dir/s and shows the most recent file from each.
|
68
78
|
|
69
79
|
## Requirements ##
|
70
80
|
|
data/bin/cetus
CHANGED
@@ -6,9 +6,13 @@
|
|
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-
|
9
|
+
# Last update: 2013-03-11 18:30
|
10
10
|
# ----------------------------------------------------------------------------- #
|
11
11
|
# cetus.rb Copyright (C) 2012-2013 rahul kumar
|
12
|
+
# == TODO
|
13
|
+
# To dirs add GEMHOME RUBYLIB PYTHONILB or PYTHONPATH,
|
14
|
+
# Make rubygem aware : gemspec or Gemfile the expand lib and bin
|
15
|
+
# fpath if existing
|
12
16
|
require 'readline'
|
13
17
|
require 'io/wait'
|
14
18
|
# http://www.ruby-doc.org/stdlib-1.9.3/libdoc/shellwords/rdoc/Shellwords.html
|
@@ -71,7 +75,9 @@ $bindings = {
|
|
71
75
|
|
72
76
|
"M-?" => "print_help",
|
73
77
|
"F1" => "print_help",
|
74
|
-
"F2" => "child_dirs"
|
78
|
+
"F2" => "child_dirs",
|
79
|
+
"F3" => "dirtree",
|
80
|
+
"F4" => "tree"
|
75
81
|
|
76
82
|
}
|
77
83
|
|
@@ -187,6 +193,7 @@ $gviscols = 3
|
|
187
193
|
$pagesize = $grows * $gviscols
|
188
194
|
$stact = 0
|
189
195
|
$editor_mode = true
|
196
|
+
$enhanced_mode = true
|
190
197
|
$visual_block_start = nil
|
191
198
|
$pager_command = {
|
192
199
|
:text => 'most',
|
@@ -221,7 +228,8 @@ $visited_files = []
|
|
221
228
|
$visited_dirs = []
|
222
229
|
## dirs where some work has been done, for saving and restoring
|
223
230
|
$used_dirs = []
|
224
|
-
$
|
231
|
+
$default_sort_order = "om"
|
232
|
+
$sorto = $default_sort_order
|
225
233
|
$viewctr = 0
|
226
234
|
$history = []
|
227
235
|
$sta = $cursor = 0
|
@@ -235,7 +243,8 @@ def run()
|
|
235
243
|
home=ENV['HOME']
|
236
244
|
ctr=0
|
237
245
|
config_read
|
238
|
-
$files = `zsh -c 'print -rl -- *(#{$hidden}M)'`.split("\n")
|
246
|
+
$files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}M)'`.split("\n")
|
247
|
+
enhance_file_list
|
239
248
|
fl=$files.size
|
240
249
|
|
241
250
|
selectedix = nil
|
@@ -584,6 +593,7 @@ end
|
|
584
593
|
# such as visited dirs or files
|
585
594
|
def escape
|
586
595
|
$sorto = nil
|
596
|
+
$sorto = $default_sort_order
|
587
597
|
$viewctr = 0
|
588
598
|
$title = nil
|
589
599
|
$filterstr = "M"
|
@@ -753,7 +763,9 @@ def main_menu
|
|
753
763
|
:v => :viminfo,
|
754
764
|
:z => :z_interface,
|
755
765
|
:d => :child_dirs,
|
766
|
+
:r => :recent_files,
|
756
767
|
:t => :dirtree,
|
768
|
+
"4" => :tree,
|
757
769
|
:s => :sort_menu,
|
758
770
|
:F => :filter_menu,
|
759
771
|
:c => :command_menu ,
|
@@ -764,10 +776,6 @@ def main_menu
|
|
764
776
|
}
|
765
777
|
menu "Main Menu", h
|
766
778
|
end
|
767
|
-
def toggle_menu
|
768
|
-
h = { :h => :toggle_hidden, :c => :toggle_case, :l => :toggle_long_list , "1" => :toggle_columns}
|
769
|
-
menu "Toggle Menu", h
|
770
|
-
end
|
771
779
|
def menu title, h
|
772
780
|
return unless h
|
773
781
|
|
@@ -784,7 +792,8 @@ def menu title, h
|
|
784
792
|
return ch, binding
|
785
793
|
end
|
786
794
|
def toggle_menu
|
787
|
-
h = { :h => :toggle_hidden, :c => :toggle_case, :l => :toggle_long_list , "1" => :toggle_columns
|
795
|
+
h = { :h => :toggle_hidden, :c => :toggle_case, :l => :toggle_long_list , "1" => :toggle_columns,
|
796
|
+
:p => :toggle_pager_mode, :e => :toggle_enhanced_list}
|
788
797
|
ch, menu_text = menu "Toggle Menu", h
|
789
798
|
case menu_text
|
790
799
|
when :toggle_hidden
|
@@ -799,6 +808,16 @@ def toggle_menu
|
|
799
808
|
#$long_listing = false if $gviscols > 1
|
800
809
|
x = $grows * $gviscols
|
801
810
|
$pagesize = $pagesize==x ? $grows : x
|
811
|
+
when :toggle_pager_mode
|
812
|
+
$editor_mode = !$editor_mode
|
813
|
+
if $editor_mode
|
814
|
+
$default_command = nil
|
815
|
+
else
|
816
|
+
$default_command = ENV['MANPAGER'] || ENV['PAGER']
|
817
|
+
end
|
818
|
+
when :toggle_enhanced_list
|
819
|
+
$enhanced_mode = !$enhanced_mode
|
820
|
+
|
802
821
|
when :toggle_long_list
|
803
822
|
$long_listing = !$long_listing
|
804
823
|
if $long_listing
|
@@ -974,6 +993,8 @@ def post_cd
|
|
974
993
|
$visual_block_start = nil
|
975
994
|
$stact = 0
|
976
995
|
screen_settings
|
996
|
+
# i think this will screw with the dir_pos since it is not filename based.
|
997
|
+
enhance_file_list
|
977
998
|
revert_dir_pos
|
978
999
|
end
|
979
1000
|
#
|
@@ -1094,6 +1115,19 @@ def dirtree
|
|
1094
1115
|
$title = "Child directories"
|
1095
1116
|
$files = `zsh -c 'print -rl -- **/*(/#{$sorto}#{$hidden}M)'`.split("\n")
|
1096
1117
|
end
|
1118
|
+
#
|
1119
|
+
# Get a full recursive listing of what's in this dir - useful for small projects with more
|
1120
|
+
# structure than files.
|
1121
|
+
def tree
|
1122
|
+
# Caution: use only for small projects, don't use in root.
|
1123
|
+
$title = "Full Tree"
|
1124
|
+
$files = `zsh -c 'print -rl -- **/*(#{$sorto}#{$hidden}M)'`.split("\n")
|
1125
|
+
end
|
1126
|
+
def recent_files
|
1127
|
+
# print -rl -- **/*(Dom[1,10])
|
1128
|
+
$title = "Recent files"
|
1129
|
+
$files = `zsh -c 'print -rl -- **/*(Dom[1,15])'`.split("\n")
|
1130
|
+
end
|
1097
1131
|
def select_current
|
1098
1132
|
## vp is local there, so i can do $vp[0]
|
1099
1133
|
#open_file $view[$sta] if $view[$sta]
|
@@ -1561,6 +1595,7 @@ def newfile
|
|
1561
1595
|
end
|
1562
1596
|
|
1563
1597
|
##
|
1598
|
+
# Editing of the User Dir List.
|
1564
1599
|
# remove current entry from used dirs list, since we may not want some entries being there
|
1565
1600
|
#
|
1566
1601
|
def remove_from_list
|
@@ -1590,5 +1625,94 @@ def remove_from_list
|
|
1590
1625
|
refresh
|
1591
1626
|
$modified = true
|
1592
1627
|
end
|
1628
|
+
#
|
1629
|
+
# If there's a short file list, take recently mod and accessed folders and put latest
|
1630
|
+
# files from there and insert it here. I take both since recent mod can be binaries / object
|
1631
|
+
# files and gems created by a process, and not actually edited files. Recent accessed gives
|
1632
|
+
# latest source, but in some cases even this can be misleading since running a program accesses
|
1633
|
+
# include files.
|
1634
|
+
def enhance_file_list
|
1635
|
+
return unless $enhanced_mode
|
1636
|
+
# if only one entry and its a dir
|
1637
|
+
# get its children and maybe the recent mod files a few
|
1638
|
+
|
1639
|
+
if $files.size == 1
|
1640
|
+
# its a dir, let give the next level at least
|
1641
|
+
if $files.first[-1] == "/"
|
1642
|
+
d = $files.first
|
1643
|
+
f = `zsh -c 'print -rl -- #{d}*(omM)'`.split("\n")
|
1644
|
+
if f && f.size > 0
|
1645
|
+
$files.concat f
|
1646
|
+
return
|
1647
|
+
end
|
1648
|
+
else
|
1649
|
+
# just a file, not dirs here
|
1650
|
+
return
|
1651
|
+
end
|
1652
|
+
end
|
1653
|
+
#
|
1654
|
+
# check if a ruby project dir, although it could be a backup file too,
|
1655
|
+
# if so , expand lib and maby bin, put a couple recent files
|
1656
|
+
#
|
1657
|
+
if $files.index("Gemfile") || $files.grep(/\.gemspec/).size > 0
|
1658
|
+
# usually the lib dir has only one file and one dir
|
1659
|
+
flg = false
|
1660
|
+
if $files.index("lib/")
|
1661
|
+
f = `zsh -c 'print -rl -- lib/*(om[1,5]M)'`.split("\n")
|
1662
|
+
if f && f.size() > 0
|
1663
|
+
insert_into_list("lib/", f)
|
1664
|
+
flg = true
|
1665
|
+
end
|
1666
|
+
dd = File.basename(Dir.pwd)
|
1667
|
+
if f.index("lib/#{dd}/")
|
1668
|
+
f = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]M)'`.split("\n")
|
1669
|
+
if f && f.size() > 0
|
1670
|
+
insert_into_list("lib/#{dd}/", f)
|
1671
|
+
flg = true
|
1672
|
+
end
|
1673
|
+
end
|
1674
|
+
end
|
1675
|
+
if $files.index("bin/")
|
1676
|
+
f = `zsh -c 'print -rl -- bin/*(om[1,5]M)'`.split("\n")
|
1677
|
+
insert_into_list("bin/", f) if f && f.size() > 0
|
1678
|
+
flg = true
|
1679
|
+
end
|
1680
|
+
return if flg
|
1681
|
+
|
1682
|
+
# lib has a dir in it with the gem name
|
1683
|
+
|
1684
|
+
end
|
1685
|
+
return if $files.size > 15
|
1686
|
+
|
1687
|
+
## first check accessed else modified will change accessed
|
1688
|
+
moda = `zsh -c 'print -rn -- *(/oa[1]M)'`
|
1689
|
+
if moda && moda != ""
|
1690
|
+
modf = `zsh -c 'print -rn -- #{moda}*(oa[1]M)'`
|
1691
|
+
if modf && modf != ""
|
1692
|
+
insert_into_list moda, modf
|
1693
|
+
end
|
1694
|
+
modm = `zsh -c 'print -rn -- #{moda}*(om[1]M)'`
|
1695
|
+
if modm && modm != "" && modm != modf
|
1696
|
+
insert_into_list moda, modm
|
1697
|
+
end
|
1698
|
+
end
|
1699
|
+
## get last modified dir
|
1700
|
+
modm = `zsh -c 'print -rn -- *(/om[1]M)'`
|
1701
|
+
if modm != moda
|
1702
|
+
modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]M)'`
|
1703
|
+
insert_into_list modm, modmf
|
1704
|
+
modmf1 = `zsh -c 'print -rn -- #{modm}*(om[1]M)'`
|
1705
|
+
insert_into_list(modm, modmf1) if modmf1 != modmf
|
1706
|
+
else
|
1707
|
+
# if both are same then our options get reduced so we need to get something more
|
1708
|
+
# If you access the latest mod dir, then come back you get only one, since mod and accessed
|
1709
|
+
# are the same dir, so we need to find the second modified dir
|
1710
|
+
end
|
1711
|
+
end
|
1712
|
+
def insert_into_list dir, file
|
1713
|
+
ix = $files.index(dir)
|
1714
|
+
raise "something wrong can find #{dir}." unless ix
|
1715
|
+
$files.insert ix, *file
|
1716
|
+
end
|
1593
1717
|
|
1594
1718
|
run if __FILE__ == $PROGRAM_NAME
|
data/cetus.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "cetus"
|
8
|
-
spec.version = "0.1.
|
8
|
+
spec.version = "0.1.8"
|
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.
|
4
|
+
version: 0.1.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
segments:
|
75
75
|
- 0
|
76
|
-
hash:
|
76
|
+
hash: 717877592165076099
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
none: false
|
79
79
|
requirements:
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
segments:
|
84
84
|
- 0
|
85
|
-
hash:
|
85
|
+
hash: 717877592165076099
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
88
|
rubygems_version: 1.8.25
|