]> Sergey Matveev's repositories - nnn.git/blob - plugins/togglex
Clear less'es screen
[nnn.git] / plugins / togglex
1 #!/usr/bin/env sh
2
3 # Description: Toggles executable mode for selection
4 #
5 # Dependencies: chmod
6 #
7 # Note: Works _only_ with selection (nnn can toggle the mode for the hovered file)
8 #
9 # Shell: POSIX compliant
10 # Author: Arun Prakash Jana
11
12 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
13
14 if [ -s "$selection" ]; then
15     xargs -0 -I {} sh -c 'if [ -x "{}" ] ; then chmod -x "{}" ; else chmod +x "{}" ; fi' < "$selection"
16
17     # Clear selection
18     if [ -p "$NNN_PIPE" ]; then
19         printf "-" > "$NNN_PIPE"
20     fi
21 fi