aboutsummaryrefslogtreecommitdiffstats
path: root/user-scripts
diff options
context:
space:
mode:
authorGravatar Juan Adrián Castro Quintana <juacq97@gmail.com>2019-03-24 22:33:18 -0700
committerGravatar GitHub <noreply@github.com>2019-03-24 22:33:18 -0700
commit6c27098533344d8800c6ca5d632b2877f854f431 (patch)
tree65b134090fb8b674f4a6ccdeae38f358b353bda2 /user-scripts
parent21e259ecd491f62ab2971c3f7ae533ae82cb86dc (diff)
parent28ef959e7119e0ff8eed426f636f19744825e4dd (diff)
downloadnnn-6c27098533344d8800c6ca5d632b2877f854f431.tar.gz
Merge branch 'master' into add-kdeconnect
Diffstat (limited to 'user-scripts')
-rw-r--r--user-scripts/README.md26
-rwxr-xr-xuser-scripts/copier (renamed from user-scripts/copier.sh)2
-rwxr-xr-xuser-scripts/edit (renamed from user-scripts/edit.sh)8
-rwxr-xr-xuser-scripts/fzy (renamed from user-scripts/fzy.sh)8
-rwxr-xr-xuser-scripts/hexview11
-rwxr-xr-xuser-scripts/imgresize32
-rwxr-xr-xuser-scripts/imgur (renamed from user-scripts/imgur.sh)0
-rwxr-xr-xuser-scripts/kdeconnect1
-rwxr-xr-xuser-scripts/ndiff8
-rwxr-xr-xuser-scripts/nlaunch5
-rwxr-xr-xuser-scripts/paste13
-rwxr-xr-xuser-scripts/picker (renamed from user-scripts/picker.sh)2
-rwxr-xr-xuser-scripts/sxiv (renamed from user-scripts/sxiv.sh)0
-rwxr-xr-xuser-scripts/transfer16
-rwxr-xr-xuser-scripts/upgrade (renamed from user-scripts/upgrade.sh)2
15 files changed, 106 insertions, 28 deletions
diff --git a/user-scripts/README.md b/user-scripts/README.md
index 2c1b985..18ed906 100644
--- a/user-scripts/README.md
+++ b/user-scripts/README.md
@@ -1,12 +1,16 @@
-#### List of scripts
-
-| Script | Description |
+| Script (a-z) | Description |
| --- | --- |
-| copier.sh | Copy selection to clipboard |
-| edit.sh | Fuzzy find a file in directory subtree with fzy and edit in vim |
-| fzy.sh | Fuzzy find a file in directory subtree with fzy and open using xdg-open |
-| imgur.sh | Upload an image file to imgur |
-| nlaunch | drop-down app launcher (needs fzy), drop in `$PATH`; fallback regular prompt |
-| picker.sh | Pick files and pipe the newline-separated list to another utility |
-| sxiv.sh | Open images in current directory in sxiv |
-| upgrade.sh | Check and update to latest version of nnn manually on Debian 9 Stretch |
+| copier | Copy selection to clipboard |
+| edit | Fuzzy find a file in directory subtree with fzy and edit in vim |
+| fzy | Fuzzy find a file in directory subtree with fzy and open using xdg-open |
+| hexview | view a file in hex; needs xxd and $PAGER |
+| imgresize | Resize images in directory to screen resolution (needs [imgp](https://github.com/jarun/imgp)) |
+| imgur | Upload an image file to imgur |
+| kdeconnect | Send selected files to Android device using kdeconnect-cli |
+| ndiff | File and directory diff for selection using vimdiff |
+| nlaunch | Drop-down independent app launcher (needs fzy), drop in `$PATH`; fallback regular prompt |
+| paste | Paste contents of current (text) file to paste.ubuntu.com (needs [pastebinit](https://launchpad.net/pastebinit)) |
+| picker | Pick files and pipe the newline-separated list to another utility |
+| sxiv | Open images in current directory in sxiv |
+| transfer | Upload current file to transfer.sh |
+| upgrade | Check and update to latest version of nnn manually on Debian 9 Stretch |
diff --git a/user-scripts/copier.sh b/user-scripts/copier
index a99b88b..2aec820 100755
--- a/user-scripts/copier.sh
+++ b/user-scripts/copier
@@ -2,7 +2,7 @@
# Description: Copy selection to clipboard
#
-# Shell: generic
+# Shell: POSIX compliant
# Author: Arun Prakash Jana
# Linux
diff --git a/user-scripts/edit.sh b/user-scripts/edit
index f23d7a8..d15b34e 100755
--- a/user-scripts/edit.sh
+++ b/user-scripts/edit
@@ -2,11 +2,7 @@
# Description: Fuzzy find a file in directory subtree with fzy and edit in vim
#
-# Shell: generic
+# Shell: POSIX compliant
# Author: Arun Prakash Jana
-# bash, zsh
-vim $(find -type f | fzy)
-
-# fish
-# vim (find -type f | fzy)
+vim `find -type f | fzy`
diff --git a/user-scripts/fzy.sh b/user-scripts/fzy
index ba8cfc9..0e52b28 100755
--- a/user-scripts/fzy.sh
+++ b/user-scripts/fzy
@@ -2,11 +2,7 @@
# Description: Fuzzy find a file in directory subtree with fzy and open using xdg-open
#
-# Shell: generic
+# Shell: POSIX compliant
# Author: Arun Prakash Jana
-# bash, zsh
-xdg-open $(find -type f | fzy) >/dev/null 2>&1
-
-# fish
-# xdg-open (find -type f | fzy) >/dev/null 2>&1
+xdg-open `find -type f | fzy` >/dev/null 2>&1
diff --git a/user-scripts/hexview b/user-scripts/hexview
new file mode 100755
index 0000000..5125fa3
--- /dev/null
+++ b/user-scripts/hexview
@@ -0,0 +1,11 @@
+#!/usr/bin/env sh
+
+# Description: View a file in hex
+# Requires: xxd and $PAGER
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if ! [ -z "$1" ]; then
+ xxd "$1" | "$PAGER"
+fi
diff --git a/user-scripts/imgresize b/user-scripts/imgresize
new file mode 100755
index 0000000..6d016f1
--- /dev/null
+++ b/user-scripts/imgresize
@@ -0,0 +1,32 @@
+#!/usr/bin/env sh
+
+# Description: Resize images in a directory to screen resolution with imgp
+# imgp homepage: https://github.com/jarun/imgp
+#
+# Notes:
+# 1. Set res if you don't want to be prompted for desktop resolution every time
+# 2. minsize is set to 1MB by default, adjust it if you want
+# 3. imgp options used:
+# a - adaptive mode
+# c - convert PNG to JPG
+# k - skip images matching specified hres/vres
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+# set resolution (e.g. 1920x1080)
+res=
+
+# set minimum image size (in bytes) to resize (default: 1MB)
+minsize=1048576
+
+if [ -z "$res" ]; then
+ echo -n "desktop resolution (hxv): "
+ read res
+fi
+
+if ! [ -z "$res" ]; then
+ if ! [ -z "$minsize" ]; then
+ imgp -ackx "$res" -s "$minsize"
+ fi
+fi
diff --git a/user-scripts/imgur.sh b/user-scripts/imgur
index 0a660fc..0a660fc 100755
--- a/user-scripts/imgur.sh
+++ b/user-scripts/imgur
diff --git a/user-scripts/kdeconnect b/user-scripts/kdeconnect
index 56d6d06..0a3f3a2 100755
--- a/user-scripts/kdeconnect
+++ b/user-scripts/kdeconnect
@@ -3,6 +3,7 @@
# Description: Send the selected files to your Android device using kdeconnect-cli. You must have installed and configured kdeconnect both on the Android device and on the PC.
#
# Shell: POSIX compliant
+
# Author: juacq97
id=$(kdeconnect-cli -a --id-only | awk '{print $1}')
diff --git a/user-scripts/ndiff b/user-scripts/ndiff
new file mode 100755
index 0000000..10af0b3
--- /dev/null
+++ b/user-scripts/ndiff
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+
+# Description: File and directory diff using vimdiff
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+vimdiff $(cat ~/.nnncp | tr '\0' '\n')
diff --git a/user-scripts/nlaunch b/user-scripts/nlaunch
index 7eee8a0..7448ca9 100755
--- a/user-scripts/nlaunch
+++ b/user-scripts/nlaunch
@@ -1,7 +1,8 @@
#!/usr/bin/env sh
-# Description: Fuzzy find executables in $PATH and launch an application
-# stdin, stdout, stderr are suppressed so CLI utilities exit silently
+# Description: Fuzzy find executables in $PATH and launch an application.
+# stdin, stdout, stderr are suppressed so CLI utilities exit silently.
+# Works as an independent app launcher.
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
diff --git a/user-scripts/paste b/user-scripts/paste
new file mode 100755
index 0000000..de130e4
--- /dev/null
+++ b/user-scripts/paste
@@ -0,0 +1,13 @@
+#!/usr/bin/env sh
+
+# Description: Paste contents of a text a file to paste.ubuntu.com using pastebinit
+#
+# pastebinit: https://launchpad.net/pastebinit
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if ! [ -z "$1" ]; then
+ pastebinit "$1"
+ read input
+fi
diff --git a/user-scripts/picker.sh b/user-scripts/picker
index cebecb1..a500435 100755
--- a/user-scripts/picker.sh
+++ b/user-scripts/picker
@@ -2,7 +2,7 @@
# Description: Pick files and pipe the newline-separated list to another utility
#
-# Shell: generic
+# Shell: POSIX compliant
# Author: Arun Prakash Jana
#
# Usage:
diff --git a/user-scripts/sxiv.sh b/user-scripts/sxiv
index 985dce7..985dce7 100755
--- a/user-scripts/sxiv.sh
+++ b/user-scripts/sxiv
diff --git a/user-scripts/transfer b/user-scripts/transfer
new file mode 100755
index 0000000..7201b0b
--- /dev/null
+++ b/user-scripts/transfer
@@ -0,0 +1,16 @@
+#!/usr/bin/env sh
+
+# Description: Upload a file to transfer.sh
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+if ! [ -z "$1" ]; then
+ # Upload the file, show the download link and wait till user presses any key
+ curl -s --upload-file "$1" https://transfer.sh/`basename "$1"`
+ echo
+ read input
+
+ # To write download link to "$1".loc and exit
+ # curl -s --upload-file "$1" https://transfer.sh/`basename "$1"` -o `basename "$1"`.loc
+fi
diff --git a/user-scripts/upgrade.sh b/user-scripts/upgrade
index fa044ee..858a6a0 100755
--- a/user-scripts/upgrade.sh
+++ b/user-scripts/upgrade
@@ -18,7 +18,7 @@ fi
wget "https://github.com/jarun/nnn/releases/download/v$new/nnn_$new-1_debian9.amd64.deb"
# install it
-dpkg -i nnn_$new-1_debian9.amd64.deb
+sudo dpkg -i nnn_$new-1_debian9.amd64.deb
# remove the file
rm -rf nnn_$new-1_debian9.amd64.deb