mirror of
https://github.com/jarun/nnn.git
synced 2024-11-27 21:31:30 +00:00
NNN_SEL: custom selection file
This commit is contained in:
parent
752bc67de0
commit
bc572df55a
|
@ -7,7 +7,7 @@
|
||||||
<a href="https://circleci.com/gh/jarun/workflows/nnn"><img src="https://img.shields.io/circleci/project/github/jarun/nnn.svg?label=circleci" alt="CircleCI Status" /></a>
|
<a href="https://circleci.com/gh/jarun/workflows/nnn"><img src="https://img.shields.io/circleci/project/github/jarun/nnn.svg?label=circleci" alt="CircleCI Status" /></a>
|
||||||
<a href="https://en.wikipedia.org/wiki/Privacy-invasive_software"><img src="https://img.shields.io/badge/privacy-✓-crimson?maxAge=2592000" alt="Privacy Awareness" /></a>
|
<a href="https://en.wikipedia.org/wiki/Privacy-invasive_software"><img src="https://img.shields.io/badge/privacy-✓-crimson?maxAge=2592000" alt="Privacy Awareness" /></a>
|
||||||
<a href="https://github.com/jarun/nnn/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-BSD%202--Clause-yellow.svg?maxAge=2592000" alt="License" /></a>
|
<a href="https://github.com/jarun/nnn/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-BSD%202--Clause-yellow.svg?maxAge=2592000" alt="License" /></a>
|
||||||
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-1eb0fc.svg" alt="Donate via PayPal!" /></a>
|
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/donate-PayPal-1eb0fc.svg" alt="Donate via PayPal!" /></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center"><a href="https://www.youtube.com/watch?v=U2n5aGqou9E"><img src="https://i.imgur.com/MPWpmos.png" /></a></p>
|
<p align="center"><a href="https://www.youtube.com/watch?v=U2n5aGqou9E"><img src="https://i.imgur.com/MPWpmos.png" /></a></p>
|
||||||
|
|
2
nnn.1
2
nnn.1
|
@ -421,6 +421,8 @@ separated by \fI;\fR:
|
||||||
NOTE: Only the first character is considered if not a \fICtrl+key\fR combo.
|
NOTE: Only the first character is considered if not a \fICtrl+key\fR combo.
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
|
\fBNNN_SEL:\fR absolute path to custom selection file.
|
||||||
|
.Pp
|
||||||
\fBnnn:\fR this is a special variable set to the hovered entry before executing
|
\fBnnn:\fR this is a special variable set to the hovered entry before executing
|
||||||
a command from the command prompt or spawning a shell.
|
a command from the command prompt or spawning a shell.
|
||||||
.Pp
|
.Pp
|
||||||
|
|
|
@ -19,27 +19,27 @@
|
||||||
|
|
||||||
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
||||||
|
|
||||||
SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
if which xsel >/dev/null 2>&1; then
|
if which xsel >/dev/null 2>&1; then
|
||||||
# Linux
|
# Linux
|
||||||
tr '\0' '\n' < "$SELECTION" | xsel -bi
|
tr '\0' '\n' < "$selection" | xsel -bi
|
||||||
elif which xclip >/dev/null 2>&1; then
|
elif which xclip >/dev/null 2>&1; then
|
||||||
# Linux
|
# Linux
|
||||||
tr '\0' '\n' < "$SELECTION" | xclip -sel clip
|
tr '\0' '\n' < "$selection" | xclip -sel clip
|
||||||
elif which pbcopy >/dev/null 2>&1; then
|
elif which pbcopy >/dev/null 2>&1; then
|
||||||
# macOS
|
# macOS
|
||||||
tr '\0' '\n' < "$SELECTION" | pbcopy
|
tr '\0' '\n' < "$selection" | pbcopy
|
||||||
elif which termux-clipboard-set >/dev/null 2>&1; then
|
elif which termux-clipboard-set >/dev/null 2>&1; then
|
||||||
# Termux
|
# Termux
|
||||||
tr '\0' '\n' < "$SELECTION" | termux-clipboard-set
|
tr '\0' '\n' < "$selection" | termux-clipboard-set
|
||||||
elif which clip.exe >/dev/null 2>&1; then
|
elif which clip.exe >/dev/null 2>&1; then
|
||||||
# WSL
|
# WSL
|
||||||
tr '\0' '\n' < "$SELECTION" | clip.exe
|
tr '\0' '\n' < "$selection" | clip.exe
|
||||||
elif which clip >/dev/null 2>&1; then
|
elif which clip >/dev/null 2>&1; then
|
||||||
# Cygwin
|
# Cygwin
|
||||||
tr '\0' '\n' < "$SELECTION" | clip
|
tr '\0' '\n' < "$selection" | clip
|
||||||
elif which wl-copy >/dev/null 2>&1; then
|
elif which wl-copy >/dev/null 2>&1; then
|
||||||
# Wayland
|
# Wayland
|
||||||
tr '\0' '\n' < "$SELECTION" | wl-copy
|
tr '\0' '\n' < "$selection" | wl-copy
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -21,7 +21,7 @@ TMPDIR="${TMPDIR:-/tmp}"
|
||||||
INCLUDE_HIDDEN="${INCLUDE_HIDDEN:-0}"
|
INCLUDE_HIDDEN="${INCLUDE_HIDDEN:-0}"
|
||||||
VERBOSE="${VERBOSE:-0}"
|
VERBOSE="${VERBOSE:-0}"
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
exit_status=0
|
exit_status=0
|
||||||
|
|
||||||
dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX")
|
dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX")
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: Anna Arad
|
# Author: Anna Arad
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
export selection
|
export selection
|
||||||
|
|
||||||
## Set CUR_CTX to 1 to open directory in current context
|
## Set CUR_CTX to 1 to open directory in current context
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: ath3, Arun Prakash Jana
|
# Author: ath3, Arun Prakash Jana
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
resp=f
|
resp=f
|
||||||
chsum=md5
|
chsum=md5
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Authors: Arun Prakash Jana, ath3
|
# Authors: Arun Prakash Jana, ath3
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
if which nvim >/dev/null 2>&1; then
|
if which nvim >/dev/null 2>&1; then
|
||||||
diffcmd="nvim -d"
|
diffcmd="nvim -d"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: 0xACE
|
# Author: 0xACE
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
resp=f
|
resp=f
|
||||||
all=
|
all=
|
||||||
if which dragon-drag-and-drop >/dev/null 2>&1; then
|
if which dragon-drag-and-drop >/dev/null 2>&1; then
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: juacq97
|
# Author: juacq97
|
||||||
|
|
||||||
SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
id=$(kdeconnect-cli -a --id-only | awk '{print $1}')
|
id=$(kdeconnect-cli -a --id-only | awk '{print $1}')
|
||||||
if [ "$(find "$SELECTION")" ]; then
|
if [ "$(find "$selection")" ]; then
|
||||||
kdeconnect-cli -d "$id" --share "$(cat "$SELECTION")"
|
kdeconnect-cli -d "$id" --share "$(cat "$selection")"
|
||||||
# If you want a system notification, uncomment the next 3 lines.
|
# If you want a system notification, uncomment the next 3 lines.
|
||||||
# notify-send -a "Kdeconnect" "Sending $(cat "$SELECTION")"
|
# notify-send -a "Kdeconnect" "Sending $(cat "$selection")"
|
||||||
#else
|
#else
|
||||||
# notify-send -a "Kdeconnect" "No file selected"
|
# notify-send -a "Kdeconnect" "No file selected"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Author: Arun Prakash Jana, ath3
|
# Author: Arun Prakash Jana, ath3
|
||||||
|
|
||||||
IFS="$(printf '\n\r')"
|
IFS="$(printf '\n\r')"
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
cmd=$(pgrep -x mocp 2>/dev/null)
|
cmd=$(pgrep -x mocp 2>/dev/null)
|
||||||
ret=$cmd
|
ret=$cmd
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Author: José Neder
|
# Author: José Neder
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
if command -v qmv >/dev/null 2>&1; then
|
if command -v qmv >/dev/null 2>&1; then
|
||||||
batchrenamesel="qmv -fdo -da"
|
batchrenamesel="qmv -fdo -da"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# Shell: POSIX compliant
|
# Shell: POSIX compliant
|
||||||
# Authors: Arun Prakash Jana, ath3
|
# Authors: Arun Prakash Jana, ath3
|
||||||
|
|
||||||
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
resp=s
|
resp=s
|
||||||
|
|
||||||
if [ -s "$selection" ]; then
|
if [ -s "$selection" ]; then
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
||||||
|
|
||||||
SELECTION=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
||||||
|
|
||||||
getclip () {
|
getclip () {
|
||||||
|
|
||||||
|
@ -54,4 +54,4 @@ for file in $CLIPBOARD ; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "%s" "$CLIPBOARD" | tr '\n' '\0' > "$SELECTION"
|
printf "%s" "$CLIPBOARD" | tr '\n' '\0' > "$selection"
|
||||||
|
|
13
src/nnn.c
13
src/nnn.c
|
@ -579,8 +579,9 @@ static const char * const messages[] = {
|
||||||
#define NNNLVL 5
|
#define NNNLVL 5
|
||||||
#define NNN_PIPE 6
|
#define NNN_PIPE 6
|
||||||
#define NNN_MCLICK 7
|
#define NNN_MCLICK 7
|
||||||
#define NNN_ARCHIVE 8 /* strings end here */
|
#define NNN_SEL 8
|
||||||
#define NNN_TRASH 9 /* flags begin here */
|
#define NNN_ARCHIVE 9 /* strings end here */
|
||||||
|
#define NNN_TRASH 10 /* flags begin here */
|
||||||
|
|
||||||
static const char * const env_cfg[] = {
|
static const char * const env_cfg[] = {
|
||||||
"NNN_OPTS",
|
"NNN_OPTS",
|
||||||
|
@ -591,6 +592,7 @@ static const char * const env_cfg[] = {
|
||||||
"NNNLVL",
|
"NNNLVL",
|
||||||
"NNN_PIPE",
|
"NNN_PIPE",
|
||||||
"NNN_MCLICK",
|
"NNN_MCLICK",
|
||||||
|
"NNN_SEL",
|
||||||
"NNN_ARCHIVE",
|
"NNN_ARCHIVE",
|
||||||
"NNN_TRASH",
|
"NNN_TRASH",
|
||||||
};
|
};
|
||||||
|
@ -6612,17 +6614,24 @@ static bool setup_config(void)
|
||||||
|
|
||||||
/* Set selection file path */
|
/* Set selection file path */
|
||||||
if (!cfg.picker) {
|
if (!cfg.picker) {
|
||||||
|
char *env_sel = xgetenv(env_cfg[NNN_SEL], NULL);
|
||||||
|
if (env_sel)
|
||||||
|
selpath = xstrdup(env_sel);
|
||||||
|
else
|
||||||
/* Length of "/.config/nnn/.selection" */
|
/* Length of "/.config/nnn/.selection" */
|
||||||
selpath = (char *)malloc(len + 3);
|
selpath = (char *)malloc(len + 3);
|
||||||
|
|
||||||
if (!selpath) {
|
if (!selpath) {
|
||||||
xerror();
|
xerror();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!env_sel) {
|
||||||
r = xstrsncpy(selpath, cfgdir, len + 3);
|
r = xstrsncpy(selpath, cfgdir, len + 3);
|
||||||
xstrsncpy(selpath + r - 1, "/.selection", 12);
|
xstrsncpy(selpath + r - 1, "/.selection", 12);
|
||||||
DPRINTF_S(selpath);
|
DPRINTF_S(selpath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue