cetus 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/cetus +98 -127
- data/cetus.gemspec +1 -1
- data/scripts/back +30 -0
- data/scripts/remove_brackets +16 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0318abcc4c63333edf5206aa2437530ca07c4379cc4887e1634535db8d86d1b
|
|
4
|
+
data.tar.gz: 526dab38dce30caba04507bd473eddfadd308a4cea301278dc79826daffa6eb4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab77bcbf1fc65397d1bc3afa2729b37bb60a7929468cc1d50eaebd1ac94a66c322e01f18dd8342f723d386dc319e935dfb9e5672c7722ce60a071a331ccec8c0
|
|
7
|
+
data.tar.gz: 83ff786fd0130ccd8417b4ab14a4a0c96f7801b20c376670fa905911e8032d2a1feb292a7a82254abf967d0f20c7e9445200f60c9a0e833347d0beb793c59b57
|
data/bin/cetus
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# Author: rkumar http://github.com/rkumar/cetus/
|
|
9
9
|
# Date: 2013-02-17 - 17:48
|
|
10
10
|
# License: GPL
|
|
11
|
-
# Last update: 2019-04-
|
|
11
|
+
# Last update: 2019-04-22 12:37
|
|
12
12
|
# --------------------------------------------------------------------------- #
|
|
13
13
|
# cetus.rb Copyright (C) 2012-2019 rahul kumar
|
|
14
14
|
# == CHANGELOG
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
# 2019-03-04 - first dirs then files
|
|
21
21
|
# 2019-03-22 - refactoring the code, esp run()
|
|
22
22
|
# 2019-04-21 - search_as_you_type
|
|
23
|
+
# 2019-04-22 - new search_as_you_type
|
|
23
24
|
# == TODO
|
|
24
25
|
|
|
25
26
|
require 'readline'
|
|
@@ -39,7 +40,7 @@ now = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
39
40
|
# alias c=~/bin/cetus.rb
|
|
40
41
|
# c
|
|
41
42
|
|
|
42
|
-
VERSION = '0.1.
|
|
43
|
+
VERSION = '0.1.41.0'
|
|
43
44
|
CONFIG_PATH = ENV['XDG_CONFIG_HOME'] || File.join(ENV['HOME'], '.config')
|
|
44
45
|
CONFIG_FILE = "#{CONFIG_PATH}/cetus/conf.yml"
|
|
45
46
|
|
|
@@ -338,7 +339,7 @@ PAGER_COMMAND = {
|
|
|
338
339
|
@cursor_movement = @old_cursor = nil # cursor movement has happened only, don't repaint
|
|
339
340
|
## FLAGS
|
|
340
341
|
@multiple_selection = true # single select
|
|
341
|
-
@
|
|
342
|
+
@group_directories = :first
|
|
342
343
|
# truncate long filenames from :right, :left or :center.
|
|
343
344
|
@truncate_from = :center
|
|
344
345
|
@filename_status_line = true
|
|
@@ -346,6 +347,7 @@ PAGER_COMMAND = {
|
|
|
346
347
|
@selected_files_fullpath_flag = false
|
|
347
348
|
@selected_files_escaped_flag = false
|
|
348
349
|
@keys_to_clear = nil
|
|
350
|
+
@ignore_case = true
|
|
349
351
|
|
|
350
352
|
# See toggle_value
|
|
351
353
|
# we need to set these on startup
|
|
@@ -365,16 +367,10 @@ PAGER_COMMAND = {
|
|
|
365
367
|
toggle_filename_status_line: true,
|
|
366
368
|
instant_search: true
|
|
367
369
|
}
|
|
368
|
-
# @cycles = { truncate_from: :center,
|
|
369
|
-
# show_hidden: nil }
|
|
370
|
-
# @enums = {
|
|
371
|
-
# truncate_from: %i[left right center],
|
|
372
|
-
# show_hidden: [nil, 'D']
|
|
373
|
-
# }
|
|
374
370
|
# var is name of variable to be set
|
|
375
371
|
@options = {
|
|
376
372
|
truncate_from: { current: :center, values: %i[left right center], var: :truncate_from },
|
|
377
|
-
group_directories: { current: :first, values: %i[first none last] },
|
|
373
|
+
group_directories: { current: :first, values: %i[first none last], var: :group_directories },
|
|
378
374
|
show_hidden: { current: nil, values: [nil, 'D'], var: :hidden }
|
|
379
375
|
}
|
|
380
376
|
|
|
@@ -458,19 +454,12 @@ CURSOR_COLOR = REVERSE
|
|
|
458
454
|
def read_directory
|
|
459
455
|
rescan_required false
|
|
460
456
|
|
|
461
|
-
# http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html
|
|
462
|
-
# zsh print -rl
|
|
463
|
-
# -l Print the arguments separated by newlines instead of spaces.
|
|
464
|
-
# -r Ignore the escape conventions of echo.
|
|
465
|
-
# zshglob M = MARK_DIRS
|
|
466
|
-
|
|
467
457
|
@filterstr ||= 'M' # XXX can we remove from here
|
|
468
|
-
# @files = `zsh -c 'print -rl -- *(#{@sorto}#{@hidden}#{@filterstr})'`.split("\n")
|
|
469
|
-
# @files = list_files
|
|
470
458
|
list_files
|
|
471
|
-
|
|
459
|
+
|
|
472
460
|
group_directories_first
|
|
473
|
-
return unless cget(:enhanced_mode)
|
|
461
|
+
# return unless cget(:enhanced_mode)
|
|
462
|
+
return unless @enhanced_mode
|
|
474
463
|
|
|
475
464
|
enhance_file_list
|
|
476
465
|
@files = @files.uniq
|
|
@@ -478,6 +467,7 @@ end
|
|
|
478
467
|
|
|
479
468
|
# return a list of directory contents sorted as per sort order
|
|
480
469
|
# NOTE: FNM_CASEFOLD does not work with Dir.glob
|
|
470
|
+
# XXX _filter unused.
|
|
481
471
|
def list_files dir='*', sorto=@sorto, hidden=@hidden, _filter=@filterstr
|
|
482
472
|
dir += '/*' if File.directory?(dir)
|
|
483
473
|
dir = dir.gsub('//', '/')
|
|
@@ -520,7 +510,7 @@ def list_files dir='*', sorto=@sorto, hidden=@hidden, _filter=@filterstr
|
|
|
520
510
|
end
|
|
521
511
|
end
|
|
522
512
|
|
|
523
|
-
sorted_files.sort! { |w1, w2| w1.casecmp(w2) } if func == :path &&
|
|
513
|
+
sorted_files.sort! { |w1, w2| w1.casecmp(w2) } if func == :path && @ignore_case
|
|
524
514
|
|
|
525
515
|
# zsh gives mtime sort with latest first, ruby gives latest last
|
|
526
516
|
sorted_files.reverse! if sorto[0] == 'O'
|
|
@@ -545,7 +535,8 @@ end
|
|
|
545
535
|
# ------------------- create_viewport ------------------ #
|
|
546
536
|
def create_viewport
|
|
547
537
|
@view = if @patt
|
|
548
|
-
if cget(:ignore_case)
|
|
538
|
+
# if cget(:ignore_case)
|
|
539
|
+
if @ignore_case
|
|
549
540
|
@files.grep(/#{@patt}/i)
|
|
550
541
|
else
|
|
551
542
|
@files.grep(/#{@patt}/)
|
|
@@ -584,7 +575,8 @@ def print_title
|
|
|
584
575
|
fl = @view.size
|
|
585
576
|
|
|
586
577
|
# fix count of entries so separator and enhanced entries don't show up
|
|
587
|
-
if cget(:enhanced_mode)
|
|
578
|
+
# if cget(:enhanced_mode)
|
|
579
|
+
if @enhanced_mode
|
|
588
580
|
ix = @viewport.index SEPARATOR
|
|
589
581
|
fin = @sta + ix if ix
|
|
590
582
|
|
|
@@ -610,15 +602,15 @@ def status_line
|
|
|
610
602
|
# prompt
|
|
611
603
|
v_mm = @mode ? "[#{@mode}] " : ''
|
|
612
604
|
cf = current_file
|
|
613
|
-
@message =
|
|
605
|
+
@message = " | No matches. Press ESCAPE " if @patt && !cf
|
|
614
606
|
|
|
615
607
|
clear_last_line
|
|
616
608
|
|
|
617
609
|
# Print the filename at the right side of the status line
|
|
618
610
|
# sometimes due to search, there is no file
|
|
619
611
|
if cf
|
|
620
|
-
if cget(:debug_flag)
|
|
621
|
-
|
|
612
|
+
# if cget(:debug_flag)
|
|
613
|
+
if @debug_flag
|
|
622
614
|
print_debug_info cf
|
|
623
615
|
else
|
|
624
616
|
# print_on_right "#{Dir.pwd}"
|
|
@@ -629,7 +621,8 @@ def status_line
|
|
|
629
621
|
# patt and message are together, no gap, why not ? 2019-04-08 -
|
|
630
622
|
if @patt && @patt != ''
|
|
631
623
|
patt = "[/#{@patt}" + ']' # to get unfrozen string
|
|
632
|
-
patt[-1] = '/i]' if cget(:ignore_case)
|
|
624
|
+
# patt[-1] = '/i]' if cget(:ignore_case)
|
|
625
|
+
patt[-1] = '/i]' if @ignore_case
|
|
633
626
|
end
|
|
634
627
|
# bring cursor to start of line
|
|
635
628
|
# add background color
|
|
@@ -758,30 +751,27 @@ def tput_cup row, col
|
|
|
758
751
|
print "\e[#{row + 3};#{col + 1}H"
|
|
759
752
|
end
|
|
760
753
|
|
|
761
|
-
# FIXME flag is unused ???? XXX
|
|
762
754
|
def redraw_required flag=true
|
|
763
755
|
@redraw_required = flag
|
|
764
756
|
end
|
|
765
757
|
|
|
758
|
+
# return value determines if screen is redrawn or not.
|
|
766
759
|
def resolve_key key
|
|
767
|
-
ret = true
|
|
768
760
|
clear_message
|
|
769
761
|
|
|
770
|
-
|
|
762
|
+
# hint mode, pick file based on shortcut
|
|
763
|
+
return select_hint(@viewport, key) if key.match?(/^[a-pr-zZ]$/)
|
|
771
764
|
|
|
772
|
-
if
|
|
773
|
-
|
|
774
|
-
ret = select_hint @viewport, key
|
|
765
|
+
if '0123456789'.include?(key)
|
|
766
|
+
resolve_numeric_key(key)
|
|
775
767
|
elsif key == 'BACKSPACE'
|
|
776
768
|
@patt = @patt[0..-2] if @patt && !@patt.empty?
|
|
777
769
|
@message = @patt = nil if @patt == ''
|
|
778
770
|
@title = nil unless @patt
|
|
779
|
-
elsif '0123456789'.include? key
|
|
780
|
-
resolve_numeric_key key
|
|
781
771
|
else
|
|
782
772
|
resolve_binding key
|
|
783
773
|
end
|
|
784
|
-
|
|
774
|
+
true
|
|
785
775
|
end
|
|
786
776
|
|
|
787
777
|
def resolve_binding key
|
|
@@ -816,68 +806,39 @@ def resolve_numeric_key key
|
|
|
816
806
|
message "Created bookmark #{key}."
|
|
817
807
|
end
|
|
818
808
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
# returning false allows these keys to be processed
|
|
824
|
-
# returning true means that these keys will be ignored
|
|
825
|
-
def search_as_you_type key
|
|
826
|
-
return false unless @searching
|
|
827
|
-
|
|
828
|
-
# @log.info "sayt: #{key}, patt: #{@patt}"
|
|
829
|
-
|
|
830
|
-
# escape should nil patt and come out of search.
|
|
831
|
-
if key == 'ESCAPE'
|
|
832
|
-
exit_search
|
|
833
|
-
return IGNORE_KEY
|
|
834
|
-
end
|
|
835
|
-
|
|
836
|
-
# We exit the search but screen shows search results.
|
|
837
|
-
if key == 'ENTER' # || key == 'TAB'
|
|
838
|
-
@searching = false
|
|
839
|
-
redraw_required true # ??? any effect ?
|
|
840
|
-
@mode = 'NORM'
|
|
841
|
-
# nilifying patt means we will not see searched results. we want to stay there.
|
|
842
|
-
@title = 'Search Results (ESCAPE to return)'
|
|
843
|
-
message ' '
|
|
844
|
-
status_line
|
|
845
|
-
return IGNORE_KEY
|
|
846
|
-
end
|
|
809
|
+
# v2 if search_as_you_type which takes keyboard control
|
|
810
|
+
# This is fairly straightforward and took only a few minutes to get done.
|
|
811
|
+
# return value is not used.
|
|
812
|
+
def search_as_you_type
|
|
847
813
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
814
|
+
@patt = '' + '' # rubocop suggestion to get unfrozen string
|
|
815
|
+
@title = 'Search Results (ENTER to return, ESC to cancel)'
|
|
816
|
+
clear_last_line
|
|
817
|
+
print "\r/"
|
|
818
|
+
loop do
|
|
819
|
+
key = get_char
|
|
820
|
+
if key == 'ENTER'
|
|
821
|
+
@title = 'Search Results (ESCAPE to return)'
|
|
822
|
+
return true
|
|
823
|
+
elsif key == 'ESCAPE'
|
|
824
|
+
@mode = @title = @patt = nil
|
|
825
|
+
status_line
|
|
826
|
+
return false
|
|
827
|
+
elsif key == 'BACKSPACE'
|
|
828
|
+
@patt = @patt[0..-2]
|
|
829
|
+
@message = nil # remove pesky ESCAPE message
|
|
830
|
+
elsif key.match?(/^[a-zA-Z0-9\. _]$/)
|
|
831
|
+
@patt += key if @patt
|
|
832
|
+
else
|
|
833
|
+
resolve_key key
|
|
834
|
+
@mode = @title = nil
|
|
835
|
+
# if directory changes, then patt is nilled causing error above
|
|
836
|
+
return true
|
|
837
|
+
end
|
|
838
|
+
# XXX is rescan required ?
|
|
839
|
+
draw_directory
|
|
840
|
+
place_cursor
|
|
866
841
|
end
|
|
867
|
-
|
|
868
|
-
@mode = 'INST'
|
|
869
|
-
@title = 'Search results: Use ENTER to return, ESCAPE to cancel.'
|
|
870
|
-
@patt ||= '' + '' # rubocop suggestion to get unfrozen string
|
|
871
|
-
@patt += key
|
|
872
|
-
message "> #{@patt} "
|
|
873
|
-
redraw_required true
|
|
874
|
-
|
|
875
|
-
return IGNORE_KEY
|
|
876
|
-
end
|
|
877
|
-
|
|
878
|
-
def exit_search
|
|
879
|
-
@searching = @mode = @title = @patt = nil
|
|
880
|
-
status_line
|
|
881
842
|
end
|
|
882
843
|
|
|
883
844
|
def set_bookmark key, dir=Dir.pwd
|
|
@@ -1416,7 +1377,6 @@ def escape
|
|
|
1416
1377
|
@viewctr = 0
|
|
1417
1378
|
@title = nil
|
|
1418
1379
|
@filterstr = 'M'
|
|
1419
|
-
@searching = false
|
|
1420
1380
|
@message = nil
|
|
1421
1381
|
@mode = nil
|
|
1422
1382
|
visual_block_clear
|
|
@@ -1433,13 +1393,14 @@ end
|
|
|
1433
1393
|
|
|
1434
1394
|
# put directories first, then files
|
|
1435
1395
|
def group_directories_first
|
|
1436
|
-
return if cget(:group_directories) == :none
|
|
1396
|
+
# return if cget(:group_directories) == :none
|
|
1397
|
+
return if @group_directories == :none
|
|
1437
1398
|
|
|
1438
1399
|
files = @files
|
|
1439
1400
|
dirs = files.select { |f| File.directory?(f) }
|
|
1440
1401
|
# earlier I had File? which removed links, esp dead ones
|
|
1441
1402
|
fi = files.reject { |f| File.directory?(f) }
|
|
1442
|
-
@files = if
|
|
1403
|
+
@files = if @group_directories == :first
|
|
1443
1404
|
dirs + fi
|
|
1444
1405
|
else
|
|
1445
1406
|
fi + dirs
|
|
@@ -1549,20 +1510,13 @@ end
|
|
|
1549
1510
|
|
|
1550
1511
|
## take regex from user, to run on files on screen, user can filter file names
|
|
1551
1512
|
def ask_regex
|
|
1552
|
-
|
|
1553
|
-
|
|
1513
|
+
@title = 'Search Results: (Press Escape to cancel)'
|
|
1514
|
+
@mode = 'SEARCH'
|
|
1515
|
+
if cget(:instant_search)
|
|
1516
|
+
search_as_you_type
|
|
1517
|
+
else
|
|
1554
1518
|
@patt = readline '/'
|
|
1555
|
-
@title = 'Search Results: (Press Escape to return)'
|
|
1556
|
-
@mode = 'SEARCH'
|
|
1557
|
-
return
|
|
1558
1519
|
end
|
|
1559
|
-
|
|
1560
|
-
# this is the instant search as you type thingie
|
|
1561
|
-
@patt = nil
|
|
1562
|
-
@log.info "Inside ask_regex instant."
|
|
1563
|
-
message 'I/'
|
|
1564
|
-
@searching = true
|
|
1565
|
-
status_line
|
|
1566
1520
|
end
|
|
1567
1521
|
|
|
1568
1522
|
# page/scroll down.
|
|
@@ -1600,11 +1554,12 @@ def print_help
|
|
|
1600
1554
|
file.puts ' HELP'
|
|
1601
1555
|
|
|
1602
1556
|
file.puts
|
|
1603
|
-
file.puts 'To open a file or dir press
|
|
1604
|
-
file.puts 'Ctrl-s to select file under cursor'
|
|
1605
|
-
file.puts '
|
|
1606
|
-
file.puts '
|
|
1607
|
-
file.puts '
|
|
1557
|
+
file.puts 'To open a file or dir, press a-z A-Z (shortcut on left of file)'
|
|
1558
|
+
file.puts 'Ctrl-s to select file under cursor. * for multiple select.'
|
|
1559
|
+
file.puts 'Ctrl-Space: Enter and exit Visual Selection mode'
|
|
1560
|
+
file.puts 'Ctrl-x: file actions for selected files, or file under cursor'
|
|
1561
|
+
file.puts '1-9: bookmark a dir, and go to it.'
|
|
1562
|
+
|
|
1608
1563
|
file.puts 'Use left and right arrows to move through directories'
|
|
1609
1564
|
file.puts
|
|
1610
1565
|
ary = []
|
|
@@ -1630,6 +1585,25 @@ def page_stat_for_file
|
|
|
1630
1585
|
end
|
|
1631
1586
|
end
|
|
1632
1587
|
|
|
1588
|
+
# display values of flag and options in pager
|
|
1589
|
+
def page_flags
|
|
1590
|
+
# XXX once this is changed to an array, then remove 'keys'
|
|
1591
|
+
page_with_tempfile do |file|
|
|
1592
|
+
file.puts 'Values of toggles/flags'
|
|
1593
|
+
file.puts '-----------------------'
|
|
1594
|
+
@toggles.keys.each do |flag|
|
|
1595
|
+
value = instance_variable_get "@#{flag}"
|
|
1596
|
+
file.puts "#{flag} : #{value}"
|
|
1597
|
+
end
|
|
1598
|
+
file.puts '-----------------------'
|
|
1599
|
+
@options.each_pair do |flag, struc|
|
|
1600
|
+
var = struc[:var]
|
|
1601
|
+
value = instance_variable_get "@#{var}"
|
|
1602
|
+
file.puts "#{flag} : #{value}"
|
|
1603
|
+
end
|
|
1604
|
+
end
|
|
1605
|
+
end
|
|
1606
|
+
|
|
1633
1607
|
def page_with_tempfile
|
|
1634
1608
|
require 'tempfile'
|
|
1635
1609
|
file = Tempfile.new('cetus')
|
|
@@ -2006,12 +1980,13 @@ end
|
|
|
2006
1980
|
def extras
|
|
2007
1981
|
h = { '1' => :one_column,
|
|
2008
1982
|
'2' => :multi_column,
|
|
2009
|
-
:
|
|
1983
|
+
c: :columns,
|
|
2010
1984
|
s: :scripts,
|
|
2011
1985
|
g: :generators,
|
|
2012
|
-
:
|
|
2013
|
-
:
|
|
2014
|
-
:
|
|
1986
|
+
B: :bindkey_ext_command,
|
|
1987
|
+
f: :page_flags,
|
|
1988
|
+
r: :config_read,
|
|
1989
|
+
w: :config_write }
|
|
2015
1990
|
key, menu_text = menu 'Extras Menu', h
|
|
2016
1991
|
case menu_text
|
|
2017
1992
|
when :one_column
|
|
@@ -3513,7 +3488,8 @@ end
|
|
|
3513
3488
|
# latest source, but in some cases even this can be misleading since running a program accesses
|
|
3514
3489
|
# include files.
|
|
3515
3490
|
def enhance_file_list
|
|
3516
|
-
return unless cget(:enhanced_mode)
|
|
3491
|
+
# return unless cget(:enhanced_mode)
|
|
3492
|
+
return unless @enhanced_mode
|
|
3517
3493
|
|
|
3518
3494
|
begin
|
|
3519
3495
|
actr = @files.size
|
|
@@ -3522,11 +3498,6 @@ def enhance_file_list
|
|
|
3522
3498
|
# zshglob: N = NULL_GLOB no error if no result, this is causing space to split
|
|
3523
3499
|
# file sometimes for single file.
|
|
3524
3500
|
|
|
3525
|
-
# FIXME: append only if we are adding.
|
|
3526
|
-
# FIXME: this makes it possible to select this row,
|
|
3527
|
-
# FIXME: and count it as a file !!
|
|
3528
|
-
# @files.append SEPARATOR
|
|
3529
|
-
|
|
3530
3501
|
# if only one entry and its a dir
|
|
3531
3502
|
# get its children and maybe the recent mod files a few
|
|
3532
3503
|
# FIXME: simplify condition into one
|
|
@@ -3813,7 +3784,7 @@ def only_cursor_moved?
|
|
|
3813
3784
|
end
|
|
3814
3785
|
|
|
3815
3786
|
# we may want to print debug info if flag is on
|
|
3816
|
-
if
|
|
3787
|
+
if @debug_flag
|
|
3817
3788
|
clear_last_line
|
|
3818
3789
|
print_debug_info
|
|
3819
3790
|
else
|
data/cetus.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = 'cetus'
|
|
9
|
-
spec.version = '0.1.
|
|
9
|
+
spec.version = '0.1.41'
|
|
10
10
|
spec.authors = ['Rahul Kumar']
|
|
11
11
|
spec.email = ['oneness.univ@gmail.com']
|
|
12
12
|
spec.description = %q{lightning fast file navigator}
|
data/scripts/back
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ----------------------------------------------------------------------------- #
|
|
3
|
+
# File: back.sh
|
|
4
|
+
# Description: copies given file into dropbox dir with timestamp appended
|
|
5
|
+
# Author: j kepler http://github.com/mare-imbrium/canis/
|
|
6
|
+
# Date: 2019-01-18 - 12:23
|
|
7
|
+
# License: MIT
|
|
8
|
+
# Last update: 2019-02-23 10:13
|
|
9
|
+
# ----------------------------------------------------------------------------- #
|
|
10
|
+
# YFF Copyright (C) 2012-2018 j kepler
|
|
11
|
+
errecho(){ >&2 echo $@; }
|
|
12
|
+
|
|
13
|
+
if [ $# -eq 0 ]; then
|
|
14
|
+
errecho "Give a file name to copy into dropbox dir"
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
TODAY=$(date +"%Y%m%d%H%M")
|
|
18
|
+
#if [[ ! -d back ]]; then
|
|
19
|
+
#mkdir back
|
|
20
|
+
#fi
|
|
21
|
+
BASE=~/Dropbox/backups
|
|
22
|
+
YEAR=$(date +"%Y")
|
|
23
|
+
TARGET=${BASE}/${YEAR}
|
|
24
|
+
if [[ ! -d $TARGET ]]; then
|
|
25
|
+
mkdir -p $TARGET
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
cp -p "$1" ${TARGET}/${1}.${TODAY}
|
|
30
|
+
ls -l ${TARGET}/$1.${TODAY}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Remove brackets and quotes from filenames
|
|
3
|
+
# replaces space with underscore
|
|
4
|
+
IFILE=~/tmp/selected_files
|
|
5
|
+
if [[ -f $IFILE ]]; then
|
|
6
|
+
wc -l $IFILE
|
|
7
|
+
else
|
|
8
|
+
echo "No files selected."
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
while IFS= read -r file
|
|
13
|
+
do
|
|
14
|
+
NEWNAME=$( echo "$file" | tr ' ' '_' | tr -d "[]()\"'")
|
|
15
|
+
[ -f "$file" ] && mv "$file" "$NEWNAME"
|
|
16
|
+
done < "$IFILE"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.41
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rahul Kumar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -55,8 +55,10 @@ files:
|
|
|
55
55
|
- cetus.gemspec
|
|
56
56
|
- generators/viminfo
|
|
57
57
|
- generators/z
|
|
58
|
+
- scripts/back
|
|
58
59
|
- scripts/create_dir_with_selection
|
|
59
60
|
- scripts/encrypt.sh
|
|
61
|
+
- scripts/remove_brackets
|
|
60
62
|
- scripts/zip
|
|
61
63
|
homepage: http://github.com/rkumar/cetus
|
|
62
64
|
licenses:
|