aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/auto-completion/bash/nnn-completion.bash44
-rw-r--r--misc/auto-completion/fish/nnn.fish18
-rw-r--r--misc/auto-completion/zsh/_nnn25
-rwxr-xr-xmisc/clipboard-copier/copier20
-rwxr-xr-xmisc/natool/natool45
-rw-r--r--misc/nlaunch/README.md7
-rwxr-xr-xmisc/nlaunch/nlaunch29
-rw-r--r--misc/nlay/README.md31
-rwxr-xr-xmisc/nlay/nlay105
-rw-r--r--misc/nlay/nlay.137
-rw-r--r--misc/quitcd/quitcd.bash11
-rw-r--r--misc/quitcd/quitcd.csh3
-rw-r--r--misc/quitcd/quitcd.fish15
-rw-r--r--misc/quitcd/quitcd.zsh11
-rwxr-xr-xmisc/test/mktest.sh55
15 files changed, 456 insertions, 0 deletions
diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash
new file mode 100644
index 0000000..4c81e77
--- /dev/null
+++ b/misc/auto-completion/bash/nnn-completion.bash
@@ -0,0 +1,44 @@
+#
+# Rudimentary Bash completion definition for nnn.
+#
+# Author:
+# Arun Prakash Jana <engineerarun@gmail.com>
+#
+
+_nnn () {
+ COMPREPLY=()
+ local IFS=$' \n'
+ local cur=$2 prev=$3
+ local -a opts opts_with_args
+ opts=(
+ -b
+ -d
+ -e
+ -h
+ -i
+ -l
+ -p
+ -s
+ -S
+ -v
+ -w
+ )
+ opts_with_arg=(
+ -b
+ -p
+ )
+
+ # Do not complete non option names
+ [[ $cur == -* ]] || return 1
+
+ # Do not complete when the previous arg is an option expecting an argument
+ for opt in "${opts_with_arg[@]}"; do
+ [[ $opt == $prev ]] && return 1
+ done
+
+ # Complete option names
+ COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
+ return 0
+}
+
+complete -F _nnn nnn
diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish
new file mode 100644
index 0000000..c0a6b1f
--- /dev/null
+++ b/misc/auto-completion/fish/nnn.fish
@@ -0,0 +1,18 @@
+#
+# Fish completion definition for nnn.
+#
+# Author:
+# Arun Prakash Jana <engineerarun@gmail.com>
+#
+
+complete -c nnn -s b -r -d 'bookmark key to open'
+complete -c nnn -s d -d 'show hidden files'
+complete -c nnn -s e -d 'use exiftool instead of mediainfo'
+complete -c nnn -s h -d 'show this help and exit'
+complete -c nnn -s i -d 'start in navigate-as-you-type mode'
+complete -c nnn -s l -d 'start in light mode (fewer details)'
+complete -c nnn -s p -r -d 'copy selection to file'
+complete -c nnn -s s -d 'use substring match for filters'
+complete -c nnn -s S -d 'start in disk usage analyzer mode'
+complete -c nnn -s v -d 'show program version and exit'
+complete -c nnn -s w -d 'wild load'
diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn
new file mode 100644
index 0000000..17d1c1a
--- /dev/null
+++ b/misc/auto-completion/zsh/_nnn
@@ -0,0 +1,25 @@
+#compdef nnn
+#
+# Completion definition for nnn.
+#
+# Author:
+# Arun Prakash Jana <engineerarun@gmail.com>
+#
+
+setopt localoptions noshwordsplit noksharrays
+local -a args
+args=(
+ '(-b)-b[bookmark key to open]:key char'
+ '(-d)-d[show hidden files]'
+ '(-e)-e[use exiftool instead of mediainfo]'
+ '(-h)-h[show this help and exit]'
+ '(-i)-i[start in navigate-as-you-type mode]'
+ '(-l)-l[start in light mode (fewer details)]'
+ '(-p)-p[copy selection to file]:file name'
+ '(-s)-s[use substring match for filters]'
+ '(-S)-S[start in disk usage analyzer mode]'
+ '(-v)-v[show program version and exit]'
+ '(-w)-w[wild load]'
+ '*:filename:_files'
+)
+_arguments -S -s $args
diff --git a/misc/clipboard-copier/copier b/misc/clipboard-copier/copier
new file mode 100755
index 0000000..e20dcf4
--- /dev/null
+++ b/misc/clipboard-copier/copier
@@ -0,0 +1,20 @@
+#!/usr/bin/env sh
+
+# Description: Copy selection to clipboard
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+SELECTION=~/.config/nnn/.selection
+
+# Linux
+cat "$SELECTION" | xargs -0 | xsel -bi
+
+# macOS
+# cat "$SELECTION" | xargs -0 | pbcopy
+
+# Termux
+# cat "$SELECTION" | xargs -0 | termux-clipboard-set
+
+# Cygwin
+# cat "$SELECTION" | xargs -0 | clip
diff --git a/misc/natool/natool b/misc/natool/natool
new file mode 100755
index 0000000..0b00066
--- /dev/null
+++ b/misc/natool/natool
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+
+# #############################################################################
+# natool: a wrapper script to patool to list, extract and create archives
+#
+# usage: natool [-a] [-l] [-x] [archive] [file/dir]
+#
+# Examples:
+# - create archive : natool -a archive.7z archive_dir
+# - list archive : natool -l archive.7z
+# - extract archive: natool -x archive.7z
+#
+# Brief:
+# natool is written to integrate patool (instead of the default atool) with nnn
+# A copies of this file should be dropped somewhere in $PATH as atool
+#
+# Author: Arun Prakash Jana
+# Email: engineerarun@gmail.com
+# Homepage: https://github.com/jarun/nnn
+# Copyright © 2019 Arun Prakash Jana
+# #############################################################################
+
+import sys
+from subprocess import Popen, PIPE, DEVNULL
+
+if len(sys.argv) < 3:
+ print('usage: natool [-a] [-l] [-x] [archive] [file/dir]')
+ sys.exit(0)
+
+if sys.argv[1] == '-a':
+ cmd = ['patool', '--non-interactive', 'create', sys.argv[2]]
+ cmd.extend(sys.argv[3:])
+elif sys.argv[1] == '-l':
+ cmd = ['patool', '--non-interactive', 'list']
+ cmd.extend(sys.argv[2:])
+elif sys.argv[1] == '-x':
+ cmd = ['patool', '--non-interactive', 'extract']
+ cmd.extend(sys.argv[2:])
+else:
+ sys.exit(0)
+
+pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+out, err = pipe.communicate()
+print(out.decode())
+print(err.decode())
diff --git a/misc/nlaunch/README.md b/misc/nlaunch/README.md
new file mode 100644
index 0000000..2b267ee
--- /dev/null
+++ b/misc/nlaunch/README.md
@@ -0,0 +1,7 @@
+`nlaunch` is an independent POSIX-compliant GUI application launcher shell script. To use it with `nnn` you need to mark the file executable and drop it somewhere in your `$PATH`.
+
+It requires [`fzy`](https://github.com/jhawthorn/fzy) to show a fuzzy drop-down menu.
+
+To use `nlaunch` as an independent launcher add a keybind to open `nlaunch` in a terminal e.g.
+
+ xfce4-terminal -e nlaunch
diff --git a/misc/nlaunch/nlaunch b/misc/nlaunch/nlaunch
new file mode 100755
index 0000000..123e62d
--- /dev/null
+++ b/misc/nlaunch/nlaunch
@@ -0,0 +1,29 @@
+#!/usr/bin/env sh
+
+# 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.
+#
+# Requires fzy.
+#
+# Usage: nlaunch [delay]
+# delay is in seconds, if omitted nlaunch waits for 1 sec
+#
+# Shell: POSIX compliant
+# Author: Arun Prakash Jana
+
+IFS=':'
+
+get_selection() {
+ ls -H $PATH | sort | fzy
+}
+
+if selection=$( get_selection ); then
+ setsid "$selection" 2>/dev/null 1>/dev/null &
+
+ if ! [ -z "$1" ]; then
+ sleep "$1"
+ else
+ sleep 1
+ fi
+fi
diff --git a/misc/nlay/README.md b/misc/nlay/README.md
new file mode 100644
index 0000000..4671eec
--- /dev/null
+++ b/misc/nlay/README.md
@@ -0,0 +1,31 @@
+## nlay
+
+`nlay` (*NnnpLAY*) is a customizable media type or action handler
+
+### Usage
+
+`nlay` is not used by `nnn` now. However, the bash script can be used to run desktop search utility or screensaver:
+
+ nlay file type
+ file: absolute path to file ("" for an action)
+ type: type of media or action
+
+### Default apps
+
+* gnome-search-tool, catfish - file search
+* vlock - terminal screensaver (alternatives - cmatrix, termsaver)
+
+### Perks
+
+- simple to modify (extensive in-file notes, comments and indicative code)
+- handle files by category (e.g. plaintext, search, screensaver)
+- support for multiple apps by order of preference
+- run app in the foreground or silently detached in the background
+- optionally add app arguments
+
+### Tips to modify
+
+- set `app=` in any category to change the player
+- set `opts=` to use app options
+- toggle `bg=` to enable or disable running app silently (`stdout` and `stderr` redirected to `/dev/null`) in background. E.g., vim (CLI) should be verbose and in the foreground while Sublime Text (GUI) can be started silently in the background.
+- enable the commented out code under `ENABLE_FILE_TYPE_HANDLING` to handle specific file extensions e.g. use a different app than the one used for the category.
diff --git a/misc/nlay/nlay b/misc/nlay/nlay
new file mode 100755
index 0000000..b3d587f
--- /dev/null
+++ b/misc/nlay/nlay
@@ -0,0 +1,105 @@
+#!/usr/bin/env bash
+
+# #############################################################################
+# nlay: a customizable script to play files in different apps by file type
+#
+# usage: nlay file/path type/action
+#
+# MUST READ:
+#
+# 1. Feel free to change the default apps to your favourite ones.
+# If you change the app for a group you may also need to modify the opts and
+# bg settings. If bg is set the app is detached and started in the background
+# in silent mode.
+#
+# The bg setting depends on personal preferences and type of utility, e.g., I
+# would start vi (CLI) in the foreground but Sublime Text (GUI) in background.
+#
+# Check (and TOGGLE as you wish) the default bg settings.
+#
+# 2. Detached apps are not killed when nnn exits. Use kill(1) or killall(1) to
+# stop console based background apps.
+#
+# 3. nlay is OVERWRITTEN during nnn upgrade. You can store your custom nlay in a
+# location other than the default and have an alias with nnn option '-p' to
+# invoke it. Remember it might break or lack new capabilities added to nlay
+# in future releases. Check the file diff once in a while.
+#
+# Author: Arun Prakash Jana
+# Email: engineerarun@gmail.com
+# Homepage: https://github.com/jarun/nnn
+# Copyright © 2016-2019 Arun Prakash Jana
+# #############################################################################
+
+
+# Enable the lines below to handle file by extension
+# This is provided for using a custom player for specific files
+# $ext holds the extension
+<<ENABLE_FILE_TYPE_HANDLING
+fname=$(basename "$1")
+if [[ $fname != *"."* ]]; then
+ exit 1
+fi
+
+ext="${fname##*.}"
+if [ -z "$ext" ]; then
+ exit 1
+fi
+
+# bash 4.0 way to switch to lowercase
+ext="${ext,,}"
+
+# handle this extension and exit
+ENABLE_FILE_TYPE_HANDLING
+
+
+#------------ PLAINTEXT (UNUSED) ------------
+if [ "$2" == "text" ]; then
+ app=("vi")
+
+ opts=("")
+
+ bg=("")
+
+#----------------- SEARCH -------------------
+elif [ "$2" == "search" ]; then
+ app=("gnome-search-tool"
+ "catfish")
+
+ opts=("--path"
+ "--path")
+
+ bg=(">/dev/null 2>&1 &"
+ ">/dev/null 2>&1 &")
+
+#------------------ LOCKER ------------------
+elif [ "$2" == "locker" ]; then
+ app=("vlock"
+ "bashlock"
+ "lock")
+
+for index in ${!app[@]}
+do
+ type -P ${app[$index]} &>/dev/null &&
+ eval ${app[$index]} &&
+ exit 0
+done
+
+#------------------ SCRIPT ------------------
+elif [ "$2" == "script" ]; then
+ # add commands or a custom script below
+
+ # echo "my commands or custom script"
+ # sh "path_to_script.sh"
+ $SHELL "$1"
+
+ exit 0
+fi
+
+#----------------- RUN APP ------------------
+for index in ${!app[@]}
+do
+ type -P ${app[$index]} &>/dev/null &&
+ eval ${app[$index]} ${opts[$index]} "\"$1\"" ${bg[$index]} &&
+ break
+done
diff --git a/misc/nlay/nlay.1 b/misc/nlay/nlay.1
new file mode 100644
index 0000000..0a6a7b5
--- /dev/null
+++ b/misc/nlay/nlay.1
@@ -0,0 +1,37 @@
+.Dd Mar 14, 2018
+.Dt NLAY 1
+.Os
+.Sh NAME
+.Nm nlay
+.Nd a bash script to play files in different apps by file type or run some actions.
+.Sh SYNOPSIS
+.Nm
+file/path type/action
+.Sh DESCRIPTION
+.Nm
+is shipped with \fInnn\fR to deliver a level of flexibility to users to choose their own apps when running some actions, run some commands or custom scripts. It has provisions to handle text files too. However, the capability is not used in the latest releases. Now
+.Nm
+is invoked to run a desktop search (\fIgnome-search-tool\fR or \fIcatfish\fR) or screen locker (\fIvlock\fR or \fIbashlock\fR or \fIlock\fR) utility. However,
+.Nm
+can run independently and can be highly customized for personal usage.
+.Pp
+.Nm
+supports the following options:
+.Pp
+"file/path"
+ The first argument can be the file or path to pass as an argument to the app. It can also be an empty string e.g., while locking the terminal.
+.Pp
+"type/action"
+ This can be any of the strings \fItext\fR, \fIsearch\fR, \fIscript\fR or \fIlocker\fR.
+.Sh USAGE
+.Pp
+.Bd -literal
+$ nlay info.txt text
+$ nlay . search
+$ nlay ~/script.sh script
+$ nlay "" locker
+.Ed
+.Sh AUTHOR
+.An Arun Prakash Jana Aq Mt engineerarun@gmail.com .
+.Sh HOME
+.Em https://github.com/jarun/nnn
diff --git a/misc/quitcd/quitcd.bash b/misc/quitcd/quitcd.bash
new file mode 100644
index 0000000..3f9f7fc
--- /dev/null
+++ b/misc/quitcd/quitcd.bash
@@ -0,0 +1,11 @@
+n()
+{
+ nnn "$@"
+
+ NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd
+
+ if [ -f $NNN_TMPFILE ]; then
+ . $NNN_TMPFILE
+ rm -f $NNN_TMPFILE > /dev/null
+ fi
+}
diff --git a/misc/quitcd/quitcd.csh b/misc/quitcd/quitcd.csh
new file mode 100644
index 0000000..9ea952d
--- /dev/null
+++ b/misc/quitcd/quitcd.csh
@@ -0,0 +1,3 @@
+# NOTE: set NNN_TMPFILE correctly if you use 'XDG_CONFIG_HOME'
+set NNN_TMPFILE=~/.config/nnn/.lastd
+alias n 'nnn; source "$NNN_TMPFILE"; rm "$NNN_TMPFILE"'
diff --git a/misc/quitcd/quitcd.fish b/misc/quitcd/quitcd.fish
new file mode 100644
index 0000000..6743386
--- /dev/null
+++ b/misc/quitcd/quitcd.fish
@@ -0,0 +1,15 @@
+# Rename this file to match the name of the function
+# e.g. ~/.config/fish/functions/n.fish
+# or, add the lines to the 'config.fish' file.
+
+function n --description 'support nnn quit and change directory'
+ nnn $argv
+
+ # NOTE: set NNN_TMPFILE correctly if you use 'XDG_CONFIG_HOME'
+ set NNN_TMPFILE ~/.config/nnn/.lastd
+
+ if test -e $NNN_TMPFILE
+ source $NNN_TMPFILE
+ rm $NNN_TMPFILE
+ end
+end
diff --git a/misc/quitcd/quitcd.zsh b/misc/quitcd/quitcd.zsh
new file mode 100644
index 0000000..24860ac
--- /dev/null
+++ b/misc/quitcd/quitcd.zsh
@@ -0,0 +1,11 @@
+n()
+{
+ nnn "$@"
+
+ NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd
+
+ if [ -f $NNN_TMPFILE ]; then
+ . $NNN_TMPFILE
+ rm $NNN_TMPFILE
+ fi
+}
diff --git a/misc/test/mktest.sh b/misc/test/mktest.sh
new file mode 100755
index 0000000..2d1decf
--- /dev/null
+++ b/misc/test/mktest.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# Create test files and directories
+
+test -e outdir && {
+ echo "Remove 'outdir' and try again"
+ exit 1
+}
+
+mkdir -p outdir && cd outdir
+
+echo 'It works!' > normal.txt
+echo 'Με δουλέβει;' > 'κοινό.txt'
+ln -sf normal.txt ln-normal.txt
+ln -sf normal.txt ln-normal
+mkdir -p normal-dir
+ln -sf normal-dir ln-normal-dir
+ln -sf nowhere ln-nowhere
+mkfifo mk-fifo
+touch no-access && chmod 000 no-access
+mkdir -p no-access-dir && chmod 000 no-access-dir
+ln -sf ../normal.txt normal-dir/ln-normal.txt
+ln -sf ../normal.txt normal-dir/ln-normal
+echo 'int main(void) { *((char *)0) = 0; }' > ill.c
+make ill > /dev/null
+echo 'test/ill' > ill.sh
+mkdir -p empty-dir
+mkdir -p cage
+echo 'chmod 000 test/cage' > cage/lock.sh
+echo 'chmod 755 test/cage' > cage-unlock.sh
+mkdir -p cage/lion
+echo 'chmod 000 test/cage' > cage/lion/lock.sh
+mkdir -p korean
+touch 'korean/[ENG sub] PRODUCE48 울림ㅣ김채원ㅣ행복 나눠주는 천사소녀 @자기소개_1분 PR 180615 EP.0-Cgnmr6Fd82'
+touch 'korean/[ENG sub] PRODUCE48 [48스페셜] 윙크요정, 내꺼야!ㅣ김채원(울림) 180615 EP.0-K7ulTiuJZK8.mp4'
+touch 'korean/[FULL ENG SUB] 181008 SALEWA x IZ_ONE Long Padding Photoshoot Behind Film-[오늘의 시구] 아이즈원 (IZONE) 장원영&미야와키 사쿠라! 시구 시타! (10.06)-VmDl5eBJ3x0.mkv'
+touch 'korean/IZ_ONE (아이즈원) - 1st Mini Album [COLOR_IZ] Highlight Medley-w9V2xFrYIgk.web'
+touch 'korean/IZ_ONE (아이즈원) - 1st Mini Album [COLOR_IZ] MV TEASER 1-uhnJLBNBNto.mkv'
+touch 'korean/IZ_ONE CHU [1회] ′순도 100%′ 우리즈원 숙소 생활 ★최초 공개★ 181025 EP.1-pcutrQN1Sbg.mkv'
+touch 'korean/IZ_ONE CHU [1회_예고] 아이즈원 데뷔 준비 과정 ★독점 공개★ 아이즈원 츄 이번주 (목) 밤 11시 첫방송 181025'
+touch 'korean/IZ_ONE CHU [1회] 도치기현 1호 이모 팬과의 만남! 181025 EP.1-5kYoReT5x44.mp4'
+touch 'korean/IZ_ONE CHU [1회] ′12명 소녀들의 새로운 시작′ 앞으로 아이즈원 잘 부탁해♥ 181025 EP.1-RVNvgbdLQLQ'
+touch 'korean/IZ_ONE CHU [1회] ′앗..그것만은!′ 자비없는 합숙생활 폭로전 181025 EP.1-AmP5KzpoI38.mkv'
+touch 'korean/IZ_ONE CHU [1회] 휴게소 간식 내기 노래 맞히기 게임 181025 EP.1-LyNDKflpWYE.mp4'
+touch 'korean/IZ_ONE CHU [1회] 2018 아이즈원 걸크러시능력시험 (feat. 치타쌤) 181025 EP.1-9qHWpbo0eB8.mp4'
+touch 'korean/IZ_ONE CHU [1회] ′돼지요′ 아니죠, ′되지요′ 맞습니다! (feat. 꾸라먹방) 181025EP.1-WDLFqMWiKn'
+touch 'korean/IZ_ONE CHU [1회] ′두근두근′ 첫 MT를 앞둔 비글력 만렙의 아이즈원 181025 EP.1'
+mkdir -p unicode
+touch 'unicode/Malgudi Days - मालगुडी डेज - E05. Swami and Friends - स्वामी और उसके दोस्त (Part 1)'
+touch 'unicode/Malgudi Days - मालगुडी डेज - E05. Swami and Friends - स्वामी और उसके दोस्त (Part 2)'
+touch 'unicode/Malgudi Days - मालगुडी डेज - E05. Swami and Friends - स्वामी और उसके दोस्त (Part 3)'
+chmod +x 'unicode/Malgudi Days - मालगुडी डेज - E05. Swami and Friends - स्वामी और उसके दोस्त (Part 2)'
+touch 'unicode/Führer'
+touch 'unicode/Eso eso aamar ghare eso ♫ এসো এসো আমার ঘরে এসো ♫ Swagatalakshmi Dasgupta'
+touch 'max_chars_filename_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'