NNN terminal file-manager

Non release banter
User avatar
M. Eerie
Moderator
Moderator
Posts: 619
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

NNN terminal file-manager

Post#1 by M. Eerie » 22 May 2021, 10:44

From the same author of buku (terminal bookmark manager), comes nnn terminal file-manager.

At first glance, it seems pretty similar to ranger, lf and the like, but nnn is just a 125Kb binary (1,5 Mb if you want pretty icons) written in C that you can compile by yourself in no time because it has very few dependencies, or just grab a precompiled binary.

Image

The result is a full-featured and blazing fast program, extensible by simple plugins that can be written in any scripting language.

This is a Quickstart to nnn.

Watch some videos.

Even though this poses a major change in the usual file managing workflow/habits, I hope you find it useful and I'm sure once you get used to it, you won't regret it.
> Does not compute_ πŸ––

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

NNN terminal file-manager

Post#2 by Rava » 18 Nov 2021, 22:24

M. Eerie wrote: ↑
22 May 2021, 10:44
The result is a full-featured and blazing fast program, extensible by simple plugins that can be written in any scripting language.
The default colour scheme seems to go bad with xfce4-terminal: trying to read dark blue text on black background is a hard task. :(
Maybe it needs a custom setup to work better in XFCE.
I made my module from nnn-4.0-1.el8.0.centos.x86_64.rpm and it works okay in 5.0rc3:
https://filehorst.de/download.php?file=eEhekslF
md5sum 82d5c0304bb2fc91889935a1b2865ba4

Added in 7 hours 12 minutes 31 seconds:
You get lots of info with the usual -help (--help gets an error) e.g.

Code: Select all

root@porteus:/mnt/live/memory/images# nnn -help|grep color
 -C      earlier colorscheme
 -D      dirs in context color
or

Code: Select all

root@porteus:~# nnn -help|grep hidden
 -H      show hidden files
and the "?" key when you are in nnn is very helpful for nnn noobs since it shows the keybinds. :)
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 619
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

NNN terminal file-manager

Post#3 by M. Eerie » 19 Nov 2021, 08:02

Rava wrote: ↑
19 Nov 2021, 05:37
The default colour scheme seems to go bad with xfce4-terminal
There's a trick to even allow for NNN "themes" :)
You need to define 12 colors based on this table, each of which is associated with the following elements:
#BLK-CHR-DIR-EXE-REG-HARDLINK-SYMLINK-MISSING-ORPHAN-FIFO-SOCK-OTHER

Image

This is my .nnnrc under my /home/guest dir.

Code: Select all

n ()
{
# REVIEW:
# https://www.linuxlinks.com/excellent-system-tools-nnn-portable-terminal-file-manager/5/
#
    # Block nesting of nnn in subshells
    if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
        echo "nnn is already running"
        return
    fi

    # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
    # To cd on quit only on ^G, remove the "export" as in:
    #     NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
    # NOTE: NNN_TMPFILE is fixed, should not be modified
    export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

    # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
    # stty start undef
    # stty stop undef
    # stty lwrap undef
    # stty lnext undef

    nnn -Hax "$@"

    if [ -f "$NNN_TMPFILE" ]; then
            . "$NNN_TMPFILE"
            rm -f "$NNN_TMPFILE" > /dev/null
    fi
}

[ -n "$NNNLVL" ] && PS1="N$NNNLVL $PS1"
alias ncp="cat ${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} | tr '\0' '\n'"

# PLUGINS
# curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh 
#

### THEMES
#BLK-CHR-DIR-EXE-REG-HARDLINK-SYMLINK-MISSING-ORPHAN-FIFO-SOCK-OTHER
#NORD='0B0B04060006060009060B06'
#ONEDARK='0404040000000600010F0F02'
#PLAIN='00004B230000000000000000'
#DEFAULT_VARIATION='C1E2272E006033F7C6D6ABC4'
#DEFAULT_THEME='C1E24B23006033F7C6D6ABC4'
### THEMES.

export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$"
export NNN_MCLICK='^R'
export NNN_SEL='~/.config/nnn/.selection'
export NNN_RCLONE='rclone mount --read-only'
export NNN_SSHFS='sshfs -o reconnect,idmap=user'
export NNN_COLORS='#0a1b2c3d' # '5236' (/'#0a1b2c3d'/'#0a1b2c3d;1234')
export NNN_FCOLORS='C1E24B23006033F7C6D6ABC4'
export NNN_PLUG='c:fzcd;d:diffs;f:finder;o:fzopen;m:nmount;n:nuke;x:togglex;p:preview-tui;i:imgviu;t:imgthumb;v:vidthumb'
export NNN_BMS='h:~;E:~/Desktop;d:~/Documents;w:~/Downloads;p:~/Pictures/;v:~/Videos'
export EDITOR='pluma'
export NNN_USE_EDITOR="$EDITOR"
#export NNN_FIFO='/tmp/nnn.fifo'
#export NNN_OPENER=~/.config/nnn/plugins/nuke
#export NNN_TRASH=1
Also, you can use xfce4-terminal "themes". There's plenty of them.
You put them in
~/.config/xfce4/terminal/colorschemes

I.e., this is the one I'm using ~/.config/xfce4/terminal/colorschemes/my-Argonaut.theme:

Code: Select all

; ColorBoldIsBright=FALSE
[Scheme]
Name=my-Argonaut
ColorForeground=#f2f2f2
ColorBackground=#0c0c0c
ColorCursor=#f2f2f2
ColorCursorUseDefault=FALSE
ColorPalette=#232323;#cc0000;#4e9a06;#ffb900;#396bd7;#b449be;#66ccff;#cccccc;#555555;#ff2740;#abe15b;#ffd242;#709aed;#db67e6;#99eeff;#eeeeee
Greetings_
> Does not compute_ πŸ––

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

NNN terminal file-manager

Post#4 by Rava » 23 Aug 2022, 03:22

your /home/guest/.nnnrc

Code: Select all

export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$"
How could one implement handling of xzm modules via mloop and then moving to /mnt/loop ?
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 619
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

NNN terminal file-manager

Post#5 by M. Eerie » 26 Aug 2022, 09:32

Rava wrote: ↑
23 Aug 2022, 03:22
How could one implement handling of xzm modules via mloop and then moving to /mnt/loop ?
I supose you can write a tiny script for it. See the plugins section.

On the other hand, 7z handles squashfs natively, so extracting to /tmp/... would be just a matter of:

Code: Select all

7z x module.xzm
7z Supported formats (from the web page):
Packing / unpacking: 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
Unpacking only: APFS, AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VHDX, VMDK, WIM, XAR and Z.


Note: There's now linux native implementation of 7z that you can download from the project page.
> Does not compute_ πŸ––

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

NNN terminal file-manager

Post#6 by Rava » 26 Aug 2022, 10:00

M. Eerie wrote: ↑
26 Aug 2022, 09:32
7z handles squashfs natively, so extracting to /tmp/...
that runs into issues as soon as the extracted module is larger than the free space on the ramdisk, and /tmp, /home or /root (and many others) are all on the ram disk.
M. Eerie wrote: ↑
26 Aug 2022, 09:32
I supose you can write a tiny script for it. See the plugins section.
looking into it …
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 619
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

NNN terminal file-manager

Post#7 by M. Eerie » 26 Aug 2022, 10:18

Rava wrote: ↑
26 Aug 2022, 10:00
that runs into issues as soon as the extracted module is larger than the free space
How I'm suposed to mount a squashfs without prior extraction? If you wish to extract to a specific path, you can use:

Code: Select all

7z x module.xzm -o/path/to/external/drive/$(basename module.xzm .xzm)
> Does not compute_ πŸ––

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

NNN terminal file-manager

Post#8 by Rava » 26 Aug 2022, 11:34

M. Eerie wrote: ↑
26 Aug 2022, 10:18
How I'm suposed to mount a squashfs without prior extraction?
mloop mounts it.
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 619
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

NNN terminal file-manager

Post#9 by M. Eerie » 27 Aug 2022, 09:07

Rava wrote: ↑
26 Aug 2022, 11:34
mloop mounts it.
I would say that mloop is a sort of alias to mount -o loop which in turns needs to extract the iso/xzm/whatever content somewhere.

https://unix.stackexchange.com/question ... act-an-iso

Somehow you need to unpack the pack, don't you?
> Does not compute_ πŸ––

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

NNN terminal file-manager

Post#10 by Rava » 27 Aug 2022, 11:12

From the mloop code itself

Code: Select all

xmodule() {
mount -t auto -o loop $xfile $mpoint
Added in 3 hours 40 minutes 12 seconds:
I will mloop a module that contains files that are larger than the free space I have in / to demonstrate what I meant.

First I look for the largest module I have on my internal drive:

Code: Select all

root@porteus:/Porteus_modules# du -mL *.xzm|sort -nr|head
261	bluegriffon-3.1.0-x86_64-wre.xzm
209	onlyoffice-5.0rc1-alldesktops.xzm
206	LibreOffice-6.2.5.2-x86_64-de_rava.xzm
145	004-brave-browser-1.34.80-linux-amd64+night-mode.xzm
132	004-brave-browser-1.34.80-linux-amd64+night-mode2.xzm
118	nvidia-415.23-k.4.20.0-porteus-v5.0-x86_64.xzm
115	nvidia-410.73-k.4.19.8-porteus-v5.0-x86_64.xzm
112	004-brave-browser-1.34.80-linux-amd64.xzm
97	kodi-17.3-x86_64-bundle-don.xzm
79	005-chromium-ungoogled-91.0.4472.114-x86_64-en-US-1alien.xzm
none of these have been activated in this session.

For demonstration purpose I will check df -m on "/" prior the mloop, during the mloop and after umounting the module using the 261 MB module of bluegriffon-3.1.0-x86_64-wre.xzm and my alias "dx" by executing "dx /"

Code: Select all

root@porteus:/Porteus_modules# type dx
dx is a function
dx () 
{ 
    echo $(date +%d.%m.%Y\ %H:%M:%S) ____________________________________________________________;
    /bin/df -Tm $* | grep -vE 'tmpfs|/mnt/live/run|squashfs'
}
Now I use dx / to get the MB of free space in /

Code: Select all

root@porteus:/Porteus_modules# dx /
27.08.2022 16:52:31 ____________________________________________________________
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
aufs           aufs       388    88       301  23% /
According to your theory, mounting the compressed filesystem of a Porteus module means I have to extract it into the root aka "/" file system. Let's mloop it and check via "dx /"

Code: Select all

root@porteus:/Porteus_modules# mloop bluegriffon-3.1.0-x86_64-wre.xzm 
using /dev/loop11

Please wait while I gather some info ....



 #################################
 Your module has been mounted at: 
/mnt/loop

 You can unmount it by typing uloop

 Here is a list of the files:
opt  usr  var

root@porteus:/Porteus_modules# dx /
27.08.2022 16:54:18 ____________________________________________________________
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
aufs           aufs       388    88       301  23% /
As you can see, the free space on "/" is still the same. Still, /mnt/loop contains the module just like mloop said:

Code: Select all

root@porteus:/Porteus_modules# cd /mnt/loop/
root@porteus:/mnt/loop# du -scm */ .??*/ 2>/dev/null |sort -nr
367	total
367	opt/
1	var/
1	usr/
As you can see, there is 367 MB of files mounted in /mnt/loop/ - and my system had only 301 MB free on / (means also 301 MB free on /tmp) :magic:

Now let's umount the module

Code: Select all

root@porteus:/mnt/loop# cd -
/Porteus_modules
root@porteus:/Porteus_modules# uloop

nothing is mounted in /mnt/loop

root@porteus:/Porteus_modules# umount /mnt/loop/
root@porteus:/Porteus_modules# ls -a /mnt/loop/
.  ..
root@porteus:/Porteus_modules# dx /
27.08.2022 16:58:04 ____________________________________________________________
Filesystem     Type 1M-blocks  Used Available Use% Mounted on
aufs           aufs       388    88       301  23% /
A xzm module is a compressed read-only file system that gets mounted via a loop device as any other filesystem.

Using mloop or activate mounts the xzm via loop device, only xzm2dir extracts the module.
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

NNN terminal file-manager

Post#11 by Rava » 11 Sep 2022, 21:25

M. Eerie wrote: ↑
19 Nov 2021, 08:02
Also, you can use xfce4-terminal "themes". There's plenty of them.
You put them in
~/.config/xfce4/terminal/colorschemes
Unfortunately, https://mayccoll.github.io/Gogh is no longer available on github.io

But fret not! archive.org to the rescue!
It's available as https://web.archive.org/web/20211019043 ... b.io/Gogh/
and if you want to download the bash script use this:

Code: Select all

wget -qO- https://git.io/vQgMr >/PATH/TO/EXTERNAL/bash/xfce4-terminal-themes.sh
set /PATH/TO/EXTERNAL/bash/ to the path you need.
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 619
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

NNN terminal file-manager

Post#12 by M. Eerie » 12 Sep 2022, 09:16

Rava wrote: ↑
11 Sep 2022, 21:25
Unfortunately, https://mayccoll.github.io/Gogh is no longer available on github.io
The page https://github.com/mayccoll/Gogh rediretcts here >> https://github.com/Gogh-Co/Gogh

Seems like the user repository has changed.

Still, archive.org is fine because not many changes expected in color themes and anyone can experiment with the existing ones as a base :)
> Does not compute_ πŸ––

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

Post Reply