From 42f9dc325e4fef7ab940eb86924c4a1f982987e5 Mon Sep 17 00:00:00 2001 From: Marcin Morawski Date: Sat, 14 Apr 2018 10:31:32 +0200 Subject: [PATCH 1/5] Improve bash completions by adding completions for dir names Affected subcommands: * biggest-files * biggest-dirs * dir-size * remove-empty-dirs * find-duplicates * ssh-unmount * upload --- install | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/install b/install index 5256c40..7d94344 100755 --- a/install +++ b/install @@ -184,6 +184,18 @@ cat > $CLIMATE_COMPLETION << EOF then COMPREPLY=( \$(compgen -W "\${opts}" -- \${cur}) ) fi + + if [ \$COMP_CWORD == 2 ] + then + case "\$prev" in + "biggest-files"|"biggest-dirs"|"dir-size"|"remove-empty-dirs"|"find-duplicates"|"ssh-unmount"|"upload") + compopt -o nospace -o dirnames; + return 0 + ;; + *) + ;; + esac + fi } complete -F _climate climate EOF From 6ebcb9d95e92ad5839616afd1ecfc783935e0cdf Mon Sep 17 00:00:00 2001 From: Marcin Morawski Date: Sat, 14 Apr 2018 10:37:37 +0200 Subject: [PATCH 2/5] Improve bash completions for monitor subcommand --- install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install b/install index 7d94344..0d065c0 100755 --- a/install +++ b/install @@ -192,6 +192,11 @@ cat > $CLIMATE_COMPLETION << EOF compopt -o nospace -o dirnames; return 0 ;; + "monitor") + COMPREPLY=(\$(compgen -f -- \${cur})) + compopt -o nospace -o filenames; + return 0 + ;; *) ;; esac From 0d7249a986138ff39ba5a5cc27703640cb9aeb20 Mon Sep 17 00:00:00 2001 From: Marcin Morawski Date: Sat, 14 Apr 2018 10:40:41 +0200 Subject: [PATCH 3/5] Improve bash completions for extract subcommand --- install | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/install b/install index 0d065c0..93b7110 100755 --- a/install +++ b/install @@ -197,6 +197,33 @@ cat > $CLIMATE_COMPLETION << EOF compopt -o nospace -o filenames; return 0 ;; + "extract") + COMPREPLY=(\${COMPREPLY[@]} \$( compgen -d -- \$cur )); + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.rar' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tar.bz2' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tar.gz' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tar.xz' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tar' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tbz2' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tgz' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.zip' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.7z' -- \"\$cur\" )) + compopt -o nospace -o dirnames -o filenames; + return 0 + ;; + *) + ;; + esac + fi + + if [ \$COMP_CWORD == 3 ] + then + action="\${COMP_WORDS[COMP_CWORD-2]}" + case "\$action" in + "extract") + compopt -o nospace -o dirnames; + return 0 + ;; *) ;; esac From 6e767642d620e53b53f8050302aaf252f4624adf Mon Sep 17 00:00:00 2001 From: Marcin Morawski Date: Sat, 21 Apr 2018 10:11:30 +0200 Subject: [PATCH 4/5] Add support for extract *.rpm files --- README.md | 2 +- climate | 2 ++ install | 3 +++ readme-generate.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ba5eaae..b5b9fdb 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ After that's done, run `climate` to see the whole list of commands supported. `climate` has the following dependencies: ``` -upower wget curl rar unzip 7z dig git python pip node npm fdupes glances speedtest sensors sshfs http-server httpstat is-up +upower wget curl rar unzip 7z dig git python pip node npm fdupes glances speedtest sensors sshfs http-server httpstat is-up rpm2cpio cpio ``` The installation command should automatically install these for `apt`-based systems diff --git a/climate b/climate index 3c7e4ea..c3d2792 100755 --- a/climate +++ b/climate @@ -80,6 +80,7 @@ extract () { *.tgz) mkdir -p ${1%.tgz} && tar xzf $1 -C ${1%.tgz}/ ;; *.zip) unzip $1 -d ${1%.zip}/ ;; *.7z) 7za e $1 -o${1%.7z}/ ;; + *.rpm) mkdir -p ${1%.rpm} && rpm2cpio $1 | (cd ${1%.rpm} && cpio -idmv) ;; *) printf "${RED}'$1' cannot be extracted.\n" ;; esac else @@ -93,6 +94,7 @@ extract () { *.tgz) mkdir -p $2 && tar xzf $1 -C $2 ;; *.zip) unzip $1 -d $2 ;; *.7z) 7z e $1 -o$2/ ;; + *.rpm) mkdir -p $2 && rpm2cpio $1 | (cd $2 && cpio -idmv) ;; *) printf "${RED}'$1' cannot be extracted.\n" ;; esac fi diff --git a/install b/install index 93b7110..254f510 100755 --- a/install +++ b/install @@ -208,6 +208,7 @@ cat > $CLIMATE_COMPLETION << EOF COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.tgz' -- \"\$cur\" )) COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.zip' -- \"\$cur\" )) COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.7z' -- \"\$cur\" )) + COMPREPLY=(\${COMPREPLY[@]} \$( eval compgen -f -X '!*.rpm' -- \"\$cur\" )) compopt -o nospace -o dirnames -o filenames; return 0 ;; @@ -339,6 +340,8 @@ main() { system_verify "sshfs" "sshfs" "fuse-sshfs" system_verify "gawk" "gawk" "gawk" system_verify "jq" "jq" "jq" + system_verify "rpm2cpio" "rpm2cpio" "rpm2cpio" + system_verify "cpio" "cpio" "cpio" npm_verify "http-server" "http-server" npm_verify "is-up" "is-up-cli" diff --git a/readme-generate.py b/readme-generate.py index 49d37b1..9eb9258 100755 --- a/readme-generate.py +++ b/readme-generate.py @@ -57,7 +57,7 @@ `climate` has the following dependencies: ``` -upower wget curl rar unzip 7z dig git python pip node npm fdupes glances speedtest sensors sshfs http-server httpstat is-up +upower wget curl rar unzip 7z dig git python pip node npm fdupes glances speedtest sensors sshfs http-server httpstat is-up rpm2cpio cpio ``` The installation command should automatically install these for `apt`-based systems From 5466482372eac18c1c234f23d5e077952767e163 Mon Sep 17 00:00:00 2001 From: Marcin Morawski Date: Sun, 22 Apr 2018 11:30:39 +0200 Subject: [PATCH 5/5] Add subcommand seashells Pipe output to seashells in real time --- README.md | 1 + climate | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index b5b9fdb..8b212f4 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Command | Description `climate countdown ` | a countdown timer `climate stopwatch` | a stopwatch `climate ix` | pipe output to ix.io + `climate seashells` | pipe output to seashells.io in real-time
| `climate biggest-files [path]` | find the biggest files recursively `climate biggest-dirs [path]` | find the biggest directories diff --git a/climate b/climate index c3d2792..86a9b57 100755 --- a/climate +++ b/climate @@ -170,6 +170,10 @@ ipinfo() { printf "${GREEN_BOLD}Latitude/Longitude: ${YELLOW}${json_loc}\n" } +seashells() { + tee >(nc seashells.io 1337) +} + # ---------------------------------------------------------------------------- # Parse Args @@ -209,6 +213,7 @@ help=$( shelp "countdown " "a countdown timer" shelp "stopwatch" "a stopwatch" shelp "ix" "pipe output to ix.io" + shelp "seashells" "pipe output to seashells.io in real-time" printf "\n${PLAIN_BOLD}Files:\n" shelp "biggest-files [path]" "find the biggest files recursively" @@ -432,6 +437,11 @@ elif [[ $command == "stopwatch" ]]; then elif [[ $command == "ix" ]]; then ix +# ---------------------------------------------------------------------------- +# seashells.io +elif [[ $command == "seashells" ]]; then + seashells + # ---------------------------------------------------------------------------- # Recursively find the biggest files in the given directory