Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
My Painted Shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Marie
My Painted Shell
Commits
b2509ebb
Commit
b2509ebb
authored
Apr 16, 2018
by
Cédric Marie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indent with 4 spaces (instead of 2)
Signed-off-by:
Cédric Marie
<
cedric@hjuvi.lautre.net
>
parent
a0cebde3
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
844 additions
and
844 deletions
+844
-844
bash/init
bash/init
+3
-3
scripts/freeze-dry
scripts/freeze-dry
+50
-50
scripts/grepar
scripts/grepar
+53
-53
scripts/mycdrip
scripts/mycdrip
+21
-21
scripts/myrsync
scripts/myrsync
+16
-16
scripts/myunzip
scripts/myunzip
+13
-13
scripts/myvfatcp
scripts/myvfatcp
+11
-11
scripts/myzip
scripts/myzip
+29
-29
scripts/rmbg
scripts/rmbg
+24
-24
scripts/tag-sieve
scripts/tag-sieve
+624
-624
No files found.
bash/init
View file @
b2509ebb
...
...
@@ -4,7 +4,7 @@
# init - Configuration for bash
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2013-201
7
by Cédric Marie
# Written in 2013-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -22,14 +22,14 @@ umask 0022
# Enable extended color mode
if
[
"
$TERM
"
=
"xterm"
]
;
then
export
TERM
=
xterm-256color
export
TERM
=
xterm-256color
fi
# Define aliases
source
$PAINTED_SHELL_PATH
/bash/alias
# Set colorful prompt
if
[
"
$TERM
"
!=
""
]
;
then
PS1
=
"
\[\e
[1;37;43m
\]\t
\[\e
[1;36;44m
\]\w
\[\e
[0m
\]\[\e
[1;31m
\]
>
\[\e
[0m
\]
"
PS1
=
"
\[\e
[1;37;43m
\]\t
\[\e
[1;36;44m
\]\w
\[\e
[0m
\]\[\e
[1;31m
\]
>
\[\e
[0m
\]
"
fi
# Add the path to scripts if not yet present
echo
$PATH
|
grep
-q
"
$PAINTED_SHELL_PATH
/scripts"
||
PATH
=
$PATH
:
$PAINTED_SHELL_PATH
/scripts
...
...
scripts/freeze-dry
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# freeze-dry - Convert FLAC files to MP3 files
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2014-201
7
by Cédric Marie
# Written in 2014-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,51 +15,51 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[FILE/DIRECTORY]...
\n
"
printf
"Convert FLAC files (FILE or content of DIRECTORY) to MP3 files in working directory.
\n
"
printf
"(For devices that cannot read FLAC files.)
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
[FILE/DIRECTORY]...
\n
"
printf
"Convert FLAC files (FILE or content of DIRECTORY) to MP3 files in working directory.
\n
"
printf
"(For devices that cannot read FLAC files.)
\n
"
}
convert_file
()
{
flac_file
=
"
$1
"
file_without_ext
=
`
basename
"
$flac_file
"
.flac
`
if
test
"
$file_without_ext
"
!=
"
$flac_file
"
&&
file
"
$flac_file
"
|
grep
-q
"FLAC audio"
;
then
wav_file
=
${
file_without_ext
}
.wav
mp3_file
=
${
file_without_ext
}
.mp3
flac_file
=
"
$1
"
file_without_ext
=
`
basename
"
$flac_file
"
.flac
`
if
test
"
$file_without_ext
"
!=
"
$flac_file
"
&&
file
"
$flac_file
"
|
grep
-q
"FLAC audio"
;
then
wav_file
=
${
file_without_ext
}
.wav
mp3_file
=
${
file_without_ext
}
.mp3
# Get tags from FLAC file
metaflac
--export-tags-to
=
$tags_filename
"
$flac_file
"
tag_artist
=
`
grep
"^ARTIST="
$tags_filename
|
tail
-n
1
`
tag_artist
=
${
tag_artist
#ARTIST=
}
tag_title
=
`
grep
"^TITLE="
$tags_filename
|
tail
-n
1
`
tag_title
=
${
tag_title
#TITLE=
}
tag_album
=
`
grep
"^ALBUM="
$tags_filename
|
tail
-n
1
`
tag_album
=
${
tag_album
#ALBUM=
}
tag_date
=
`
grep
"^DATE="
$tags_filename
|
tail
-n
1
`
tag_date
=
${
tag_date
#DATE=
}
tag_tracknumber
=
`
grep
"^TRACKNUMBER="
$tags_filename
|
tail
-n
1
`
tag_tracknumber
=
${
tag_tracknumber
#TRACKNUMBER=
}
# Get tags from FLAC file
metaflac
--export-tags-to
=
$tags_filename
"
$flac_file
"
tag_artist
=
`
grep
"^ARTIST="
$tags_filename
|
tail
-n
1
`
tag_artist
=
${
tag_artist
#ARTIST=
}
tag_title
=
`
grep
"^TITLE="
$tags_filename
|
tail
-n
1
`
tag_title
=
${
tag_title
#TITLE=
}
tag_album
=
`
grep
"^ALBUM="
$tags_filename
|
tail
-n
1
`
tag_album
=
${
tag_album
#ALBUM=
}
tag_date
=
`
grep
"^DATE="
$tags_filename
|
tail
-n
1
`
tag_date
=
${
tag_date
#DATE=
}
tag_tracknumber
=
`
grep
"^TRACKNUMBER="
$tags_filename
|
tail
-n
1
`
tag_tracknumber
=
${
tag_tracknumber
#TRACKNUMBER=
}
# Convert from .flac to .wav
flac
-d
-o
"
$wav_file
"
"
$flac_file
"
# Convert from .wav to .mp3 (insane = 320 kbps)
lame
--preset
insane
"
$wav_file
"
"
$mp3_file
"
# Remove temporary .wav file
rm
-f
"
$wav_file
"
# Convert from .flac to .wav
flac
-d
-o
"
$wav_file
"
"
$flac_file
"
# Convert from .wav to .mp3 (insane = 320 kbps)
lame
--preset
insane
"
$wav_file
"
"
$mp3_file
"
# Remove temporary .wav file
rm
-f
"
$wav_file
"
# Set tags in MP3 file
id3v2
--id3v2-only
--artist
"
$tag_artist
"
"
$mp3_file
"
id3v2
--id3v2-only
--song
"
$tag_title
"
"
$mp3_file
"
id3v2
--id3v2-only
--album
"
$tag_album
"
"
$mp3_file
"
id3v2
--id3v2-only
--year
"
$tag_date
"
"
$mp3_file
"
id3v2
--id3v2-only
--track
"
$tag_tracknumber
"
"
$mp3_file
"
# Set read-only permission
chmod
444
"
$mp3_file
"
else
printf
"
$flac_file
is not a FLAC file
\n
"
fi
# Set tags in MP3 file
id3v2
--id3v2-only
--artist
"
$tag_artist
"
"
$mp3_file
"
id3v2
--id3v2-only
--song
"
$tag_title
"
"
$mp3_file
"
id3v2
--id3v2-only
--album
"
$tag_album
"
"
$mp3_file
"
id3v2
--id3v2-only
--year
"
$tag_date
"
"
$mp3_file
"
id3v2
--id3v2-only
--track
"
$tag_tracknumber
"
"
$mp3_file
"
# Set read-only permission
chmod
444
"
$mp3_file
"
else
printf
"
$flac_file
is not a FLAC file
\n
"
fi
}
if
[
$#
=
0
]
;
then
print_usage
;
exit
1
;
fi
...
...
@@ -67,17 +67,17 @@ tags_filename=/tmp/freeze-dry.tags
for
arg
in
"
$@
"
do
if
[
-f
"
$arg
"
]
;
then
convert_file
"
$arg
"
elif
[
-d
"
$arg
"
]
;
then
ls
-1
"
$arg
"
/
*
.flac |
{
while
read
file
do
convert_file
"
$file
"
done
}
fi
if
[
-f
"
$arg
"
]
;
then
convert_file
"
$arg
"
elif
[
-d
"
$arg
"
]
;
then
ls
-1
"
$arg
"
/
*
.flac |
{
while
read
file
do
convert_file
"
$file
"
done
}
fi
done
rm
-f
$tags_filename
scripts/grepar
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# grepar - Grep recursively in archives
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2013-201
7
by Cédric Marie
# Written in 2013-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,75 +15,75 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
STRING
\n
"
printf
"Grep STRING recursively in archives in current directory.
\n
"
printf
"Supported archives: tar, tar.gz, tgz, tar.bz2, tbz2, tar.xz, and zip.
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
STRING
\n
"
printf
"Grep STRING recursively in archives in current directory.
\n
"
printf
"Supported archives: tar, tar.gz, tgz, tar.bz2, tbz2, tar.xz, and zip.
\n
"
}
clean_and_exit
()
{
rm
-rf
/tmp/grepintar-
$$
-
*
exit
0
rm
-rf
/tmp/grepintar-
$$
-
*
exit
0
}
grep_in_archive
()
{
local
depth
=
$1
local
path
=
$2
local
file
=
${
3
#./
}
local
opt
=
$4
local
depth
=
$1
local
path
=
$2
local
file
=
${
3
#./
}
local
opt
=
$4
path
=
$path
/
$file
path
=
${
path
#./
}
printf
"
\0
33[1;32mProcessing
$path
\0
33[0m
\n
"
rm
-rf
/tmp/grepintar-
$$
-
$depth
mkdir
/tmp/grepintar-
$$
-
$depth
if
[
"
$opt
"
=
"zip"
]
;
then
unzip
-q
$file
-d
/tmp/grepintar-
$$
-
$depth
else
tar
$opt
$file
-C
/tmp/grepintar-
$$
-
$depth
fi
# Change current directory in order to show relative path
cd
/tmp/grepintar-
$$
-
$depth
grep
--color
=
auto
-r
"
$grep_string
"
.
cd
-
>
/dev/null
pushd
/tmp/grepintar-
$$
-
$depth
>
/dev/null
depth
=
$((
$depth
+
1
))
search_for_archives
$depth
$path
popd
>
/dev/null
path
=
$path
/
$file
path
=
${
path
#./
}
printf
"
\0
33[1;32mProcessing
$path
\0
33[0m
\n
"
rm
-rf
/tmp/grepintar-
$$
-
$depth
mkdir
/tmp/grepintar-
$$
-
$depth
if
[
"
$opt
"
=
"zip"
]
;
then
unzip
-q
$file
-d
/tmp/grepintar-
$$
-
$depth
else
tar
$opt
$file
-C
/tmp/grepintar-
$$
-
$depth
fi
# Change current directory in order to show relative path
cd
/tmp/grepintar-
$$
-
$depth
grep
--color
=
auto
-r
"
$grep_string
"
.
cd
-
>
/dev/null
pushd
/tmp/grepintar-
$$
-
$depth
>
/dev/null
depth
=
$((
$depth
+
1
))
search_for_archives
$depth
$path
popd
>
/dev/null
}
search_for_archives
()
{
local
depth
=
$1
local
path
=
$2
local
depth
=
$1
local
path
=
$2
for
file
in
`
find
-name
"*.tar"
`
do
grep_in_archive
$depth
$path
$file
-xf
done
for
file
in
`
find
-name
"*.tar.gz"
-o
-name
"*.tgz"
`
do
grep_in_archive
$depth
$path
$file
-zxf
done
for
file
in
`
find
-name
"*.tar.bz2"
-o
-name
"*.tbz2"
`
do
grep_in_archive
$depth
$path
$file
-jxf
done
for
file
in
`
find
-name
"*.tar.xz"
`
do
grep_in_archive
$depth
$path
$file
-Jxf
done
for
file
in
`
find
-name
"*.zip"
`
do
grep_in_archive
$depth
$path
$file
zip
done
for
file
in
`
find
-name
"*.tar"
`
do
grep_in_archive
$depth
$path
$file
-xf
done
for
file
in
`
find
-name
"*.tar.gz"
-o
-name
"*.tgz"
`
do
grep_in_archive
$depth
$path
$file
-zxf
done
for
file
in
`
find
-name
"*.tar.bz2"
-o
-name
"*.tbz2"
`
do
grep_in_archive
$depth
$path
$file
-jxf
done
for
file
in
`
find
-name
"*.tar.xz"
`
do
grep_in_archive
$depth
$path
$file
-Jxf
done
for
file
in
`
find
-name
"*.zip"
`
do
grep_in_archive
$depth
$path
$file
zip
done
}
if
[
$#
!=
1
]
;
then
print_usage
exit
1
print_usage
exit
1
fi
trap
"clean_and_exit"
2 3 15
...
...
scripts/mycdrip
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# mycdrip - Extract audio tracks from a CD and convert them to FLAC
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2016-201
7
by Cédric Marie
# Written in 2016-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,26 +15,26 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... [DISCNUMBER]
\n
"
printf
"Extract audio tracks from a CD and convert them to FLAC.
\n
"
printf
"Prefix the filenames with DISCNUMBER if set.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... [DISCNUMBER]
\n
"
printf
"Extract audio tracks from a CD and convert them to FLAC.
\n
"
printf
"Prefix the filenames with DISCNUMBER if set.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
}
print_header
()
{
printf
"
\n\0
33[1;32m
$1
\0
33[0m
\n
"
printf
"
\n\0
33[1;32m
$1
\0
33[0m
\n
"
}
# Get options from command line
while
getopts
h OPT
do
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
done
shift
$((
$OPTIND
-
1
))
...
...
@@ -45,17 +45,17 @@ print_header "Step 2: Convert to .flac files"
flac
--delete-input-file
--no-seektable
*
.wav
if
[
-z
"
$1
"
]
;
then
print_header
"Step 3: Rename files (##. .flac)"
print_header
"Step 3: Rename files (##. .flac)"
else
print_header
"Step 3: Rename files (
$1
.##. .flac)"
print_header
"Step 3: Rename files (
$1
.##. .flac)"
fi
for
file
in
*
.cdda.flac
;
do
file_nb
=
${
file
#track
}
file_nb
=
${
file_nb
%.cdda.flac
}
if
[
-z
"
$1
"
]
;
then
mv
-v
"
$file
"
"
$file_nb
. .flac"
else
mv
-v
"
$file
"
"
$1
.
$file_nb
. .flac"
fi
file_nb
=
${
file
#track
}
file_nb
=
${
file_nb
%.cdda.flac
}
if
[
-z
"
$1
"
]
;
then
mv
-v
"
$file
"
"
$file_nb
. .flac"
else
mv
-v
"
$file
"
"
$1
.
$file_nb
. .flac"
fi
done
scripts/myrsync
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# myrsync - Synchronize directories
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2013-201
7
by Cédric Marie
# Written in 2013-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,24 +15,24 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... SRCDIR DESTDIR
\n
"
printf
"Synchronize local or remote directories with command: rsync -av --delete.
\n
"
printf
"DESTDIR content will be an exact copy of SRCDIR content (rights and modified times are preserved).
\n
"
printf
"rsync is called first with --dry-run option, because --delete option can be dangerous if DEST
\n
"
printf
"is not the right one (all content will be deleted!).
\n
"
printf
"After confirmation, rsync is called without --dry-run option.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... SRCDIR DESTDIR
\n
"
printf
"Synchronize local or remote directories with command: rsync -av --delete.
\n
"
printf
"DESTDIR content will be an exact copy of SRCDIR content (rights and modified times are preserved).
\n
"
printf
"rsync is called first with --dry-run option, because --delete option can be dangerous if DEST
\n
"
printf
"is not the right one (all content will be deleted!).
\n
"
printf
"After confirmation, rsync is called without --dry-run option.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
}
# Get options from command line
while
getopts
h OPT
do
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
done
shift
$((
$OPTIND
-
1
))
if
[
$#
!=
2
]
;
then
print_usage
;
exit
1
;
fi
...
...
@@ -44,7 +44,7 @@ rsync -av --delete --dry-run "$srcdir" "$2" || exit 1
printf
"Enter
\"
yes
\"
to confirm: "
read
answer
if
[
"
$answer
"
=
"yes"
]
;
then
rsync
-av
--delete
"
$srcdir
"
"
$2
"
rsync
-av
--delete
"
$srcdir
"
"
$2
"
else
printf
"rsync cancelled
\n
"
printf
"rsync cancelled
\n
"
fi
scripts/myunzip
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# myunzip - Uncompress a .tar.xz[.crypt] file
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2013-201
7
by Cédric Marie
# Written in 2013-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,20 +15,20 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... FILE
\n
"
printf
"Unzip a zipped directory.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... FILE
\n
"
printf
"Unzip a zipped directory.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
}
# Get options from command line
while
getopts
h OPT
do
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
done
shift
$((
$OPTIND
-
1
))
...
...
@@ -37,15 +37,15 @@ option_crypt=0
if
[
"
$1
"
=
""
-o
!
-f
"
$1
"
]
;
then
print_usage
;
exit
1
;
fi
file
=
${
1
%.crypt
}
if
[
"
$file
"
!=
"
$1
"
]
;
then
option_crypt
=
1
[
-e
"
$file
"
]
&&
printf
"
$file
already exists
\n
"
&&
exit
1
option_crypt
=
1
[
-e
"
$file
"
]
&&
printf
"
$file
already exists
\n
"
&&
exit
1
fi
dir
=
${
file
%.tar.xz
}
[
"
$dir
"
=
"
$file
"
]
&&
print_usage
&&
exit
1
dir
=
${
dir
%.*-*-*.*h*m*s
}
[
-e
"
$dir
"
]
&&
printf
"
$dir
already exists
\n
"
&&
exit
1
if
[
$option_crypt
-eq
1
]
;
then
openssl bf-cbc
-d
-a
-in
$1
-out
$file
openssl bf-cbc
-d
-a
-in
$1
-out
$file
fi
tar
-Jxvf
$file
[
$option_crypt
-eq
1
]
&&
rm
-f
$file
...
...
scripts/myvfatcp
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# myvfatcp - Copy files to VFAT filesystem with supported file names
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2016-201
7
by Cédric Marie
# Written in 2016-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,21 +15,21 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... FILES... VFAT_DIR
\n
"
printf
"Copy FILES to VFAT_DIR with supported file names for VFAT filesystem.
\n
"
printf
"Unsupported characters (?,
\"
, and :) are converted to _.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... FILES... VFAT_DIR
\n
"
printf
"Copy FILES to VFAT_DIR with supported file names for VFAT filesystem.
\n
"
printf
"Unsupported characters (?,
\"
, and :) are converted to _.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
}
# Get options from command line
while
getopts
h OPT
do
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
case
$OPT
in
h
)
print_usage
;
exit
0
;;
*
)
print_usage
;
exit
1
;;
esac
done
shift
$((
$OPTIND
-
1
))
...
...
scripts/myzip
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# myzip - Compress a directory to .tar.xz[.crypt] file
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2013-201
7
by Cédric Marie
# Written in 2013-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,13 +15,13 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... DIRECTORY
\n
"
printf
"Zip a directory.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
printf
" -c encrypt output file with password
\n
"
printf
" -t timestamp output file
\n
"
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... DIRECTORY
\n
"
printf
"Zip a directory.
\n\n
"
printf
"Options:
\n
"
printf
" -h display this message
\n
"
printf
" -c encrypt output file with password
\n
"
printf
" -t timestamp output file
\n
"
}
option_crypt
=
0
...
...
@@ -29,43 +29,43 @@ option_timestamp=0
# Get options from command line
while
getopts
hct OPT
do
case
$OPT
in
h
)
print_usage
;
exit
0
;;
c
)
option_crypt
=
1
;;
t
)
option_timestamp
=
1
;;
*
)
print_usage
;
exit
1
;;
esac
case
$OPT
in
h
)
print_usage
;
exit
0
;;
c
)
option_crypt
=
1
;;
t
)
option_timestamp
=
1
;;
*
)
print_usage
;
exit
1
;;
esac
done
shift
$((
$OPTIND
-
1
))
if
[
"
$1
"
=
""
-o
!
-d
"
$1
"
]
;
then
print_usage
;
exit
1
;
fi
dir
=
${
1
%/
}
if
[
$option_timestamp
-eq
1
]
;
then
file
=
$dir
.
`
date
+%F.%Hh%Mm%Ss
`
.tar.xz
file
=
$dir
.
`
date
+%F.%Hh%Mm%Ss
`
.tar.xz
else
file
=
$dir
.tar.xz
file
=
$dir
.tar.xz
fi
[
-e
"
$file
"
]
&&
printf
"
$file
already exists
\n
"
&&
exit
1
if
[
$option_crypt
-eq
1
]
;
then
output_file
=
${
file
}
.crypt
[
-e
"
$output_file
"
]
&&
printf
"
$output_file
already exists
\n
"
&&
exit
1
output_file
=
${
file
}
.crypt
[
-e
"
$output_file
"
]
&&
printf
"
$output_file
already exists
\n
"
&&
exit
1
else
output_file
=
$file
output_file
=
$file
fi
tar
-Jcvf
$file
$dir
if
[
$option_crypt
-eq
1
]
;
then
openssl bf-cbc
-e
-a
-salt
-in
$file
-out
$output_file
rm
-f
$file
[
-f
$output_file
]
||
exit
1
openssl bf-cbc
-e
-a
-salt
-in
$file
-out
$output_file
rm
-f
$file
[
-f
$output_file
]
||
exit
1
fi
chmod
444
$output_file
printf
"
\0
33[1mOutput file:
\0
33[0m
$output_file
\n
"
if
[
$option_crypt
-eq
1
]
;
then
printf
"
\n
$output_file
was successfully created:
\n
"
ls
-l
$output_file
printf
"Do you want to delete
$dir
directory (y/N)? "
read
answer
if
[
"
$answer
"
==
"y"
]
;
then
rm
-rf
$dir
fi
printf
"
\n
$output_file
was successfully created:
\n
"
ls
-l
$output_file
printf
"Do you want to delete
$dir
directory (y/N)? "
read
answer
if
[
"
$answer
"
==
"y"
]
;
then
rm
-rf
$dir
fi
fi
scripts/rmbg
View file @
b2509ebb
...
...
@@ -3,7 +3,7 @@
# rmbg - Delete directories in the background
# This file is part of Painted Shell - Shell configuration and scripts.
#
# Written in 2014-201
7
by Cédric Marie
# Written in 2014-201
8
by Cédric Marie
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
...
...
@@ -15,38 +15,38 @@
print_usage
()
{
command
=
$(
basename
$0
)
printf
"Usage:
$command
[OPTION]... [DIR]...
\n
"
printf
"Delete directories DIR (rm -rf) in the background (&).
\n
"
printf
"Each DIR is renamed to ____rmbg.DIR.<timestamp>____ (in the same parent
\n
"
printf
"directory) before deletion, so that the directory name can be used again before
\n
"
printf
"deletion is finished.
\n\n
"