Fix alignment

This commit is contained in:
Arun Prakash Jana 2021-06-06 18:58:13 +05:30
parent f24b82a750
commit 3b6938f782
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -230,126 +230,136 @@ Don't forget to fork in the background to avoid blocking `nnn`.
For more details on configuration and usage of the preview plugins, visit [Live Previews](https://github.com/jarun/nnn/wiki/Live-previews). For more details on configuration and usage of the preview plugins, visit [Live Previews](https://github.com/jarun/nnn/wiki/Live-previews).
#### Examples ## Examples
There are many plugins provided by `nnn` which can be used as examples. Here are a few simple selected examples. There are many plugins provided by `nnn` which can be used as examples. Here are a few simple selected examples.
- Show the git log of changes to the particular file along with the code for a quick and easy review. #### Show the git log of changes to the particular file along with the code for a quick and easy review.
```sh
#!/usr/bin/env sh
git log -p -- "$1"
```
- Change to directory in clipboard using helper script ```sh
```sh #!/usr/bin/env sh
#!/usr/bin/env sh git log -p -- "$1"
. $(dirname $0)/.nnn-plugin-helper ```
nnn_cd "$(xsel -ob)" #### Change to directory in clipboard using helper script
```
- Change directory to the location of a link using helper script with specific context (current) ```sh
```sh #!/usr/bin/env sh
#!/usr/bin/env sh . $(dirname $0)/.nnn-plugin-helper
. $(dirname $0)/.nnn-plugin-helper
nnn_cd "$(dirname $(readlink -fn $1))" 0 nnn_cd "$(xsel -ob)"
``` ```
- Change to arbitrary directory without helper script #### Change directory to the location of a link using helper script with specific context (current)
```sh
#!/usr/bin/env sh
printf "cd to: "
read -r dir
printf "%s" "0c$dir" > "$NNN_PIPE" ```sh
``` #!/usr/bin/env sh
. $(dirname $0)/.nnn-plugin-helper
- Send every hovered file to X selection nnn_cd "$(dirname $(readlink -fn $1))" 0
```sh ```
#!/usr/bin/env sh
if [ -z "$NNN_FIFO" ] ; then #### Change to arbitrary directory without helper script
```sh
#!/usr/bin/env sh
printf "cd to: "
read -r dir
printf "%s" "0c$dir" > "$NNN_PIPE"
```
#### Send every hovered file to X selection
```sh
#!/usr/bin/env sh
if [ -z "$NNN_FIFO" ] ; then
exit 1 exit 1
fi fi
while read FILE ; do while read FILE ; do
printf "%s" "$FILE" | xsel printf "%s" "$FILE" | xsel
done < "$NNN_FIFO" & done < "$NNN_FIFO" &
disown disown
``` ```
- Quick find (using `fd`) #### Quick find (using `fd`)
```sh
#!/usr/bin/env sh
. "$(dirname "$0")"/.nnn-plugin-helper ```sh
#!/usr/bin/env sh
printf "pattern: " . "$(dirname "$0")"/.nnn-plugin-helper
read -r pattern
if [ -n "$pattern" ]; then printf "pattern: "
read -r pattern
if [ -n "$pattern" ]; then
printf "%s" "+l" > "$NNN_PIPE" printf "%s" "+l" > "$NNN_PIPE"
eval "fd -HI $pattern -0" > "$NNN_PIPE" eval "fd -HI $pattern -0" > "$NNN_PIPE"
fi fi
``` ```
- Quick grep (using `rg`) #### Quick grep (using `rg`)
```sh
#!/usr/bin/env sh
. "$(dirname "$0")"/.nnn-plugin-helper ```sh
#!/usr/bin/env sh
printf "pattern: " . "$(dirname "$0")"/.nnn-plugin-helper
read -r pattern
if [ -n "$pattern" ]; then printf "pattern: "
read -r pattern
if [ -n "$pattern" ]; then
printf "%s" "+l" > "$NNN_PIPE" printf "%s" "+l" > "$NNN_PIPE"
eval "rg -l0 --hidden -S $pattern" > "$NNN_PIPE" eval "rg -l0 --hidden -S $pattern" > "$NNN_PIPE"
fi fi
``` ```
- Quick scripts for paged output
```sh
#!/usr/bin/env sh
# Show media information for hovered file #### Quick scripts for paged output
# Save as file mediainf
# m:-!mediainf
mediainfo "$1" | eval "$PAGER" ```sh
# exiftool "$1" | $PAGER #!/usr/bin/env sh
-------------------------------------------------
#!/usr/bin/env sh
# Show tree output with permissions and file size # Show media information for hovered file
# Save as file treeplug # Save as file mediainf
# t:-!treeplug # m:-!mediainf
tree -ps | $EDITOR - mediainfo "$1" | eval "$PAGER"
------------------------------------------------- # exiftool "$1" | $PAGER
#!/usr/bin/env sh -------------------------------------------------
#!/usr/bin/env sh
# List files with UID/GID # Show tree output with permissions and file size
# Save as file uidgid # Save as file treeplug
# u:-!uidgid # t:-!treeplug
ls -lah --group-directories-first | less tree -ps | $EDITOR -
------------------------------------------------- -------------------------------------------------
#!/usr/bin/env sh #!/usr/bin/env sh
# Show hovered file data in hex # List files with UID/GID
# Save as file hexview # Save as file uidgid
# x:-!hexview # u:-!uidgid
if [ -f "$1" ]; then ls -lah --group-directories-first | less
-------------------------------------------------
#!/usr/bin/env sh
# Show hovered file data in hex
# Save as file hexview
# x:-!hexview
if [ -f "$1" ]; then
xxd "$1" | $PAGER xxd "$1" | $PAGER
fi fi
------------------------------------------------- -------------------------------------------------
#!/usr/bin/env sh #!/usr/bin/env sh
# Show hovered PDF text # Show hovered PDF text
# Save as file pdftxt # Save as file pdftxt
# p:-!pdftxt # p:-!pdftxt
if [ -f "$1" ] && [ "$(head -c 4 "$1")" = "%PDF" ]; then if [ -f "$1" ] && [ "$(head -c 4 "$1")" = "%PDF" ]; then
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
# Convert using mutool # Convert using mutool
@ -358,8 +368,8 @@ There are many plugins provided by `nnn` which can be used as examples. Here are
# mutool convert -o "$txt" "$1" # mutool convert -o "$txt" "$1"
# eval $PAGER $txt # eval $PAGER $txt
# rm "$txt # rm "$txt
fi fi
``` ```
## Contributing plugins ## Contributing plugins