2020年12月24日 星期四

nnn - text file browser

1. 下載:
    nnn
    和
    icons-in-terminal 

2. 編譯:
    a. icons-in-terminal:
        $ cd your_path/icons-in-terminal
        $ ./install.sh
    b. nnn:
        $ sudo apt-get install libreadline-dev
        $ cd your_path/nnn
        $ make O_ICONS=1
        $ sudo make install


3. 修改 ~/.bashrc
#for nnn (text file browser)
export EDITOR=/usr/bin/vim
export VISUAL=/home/nice/.config/nnn/plugins/detached_text.sh
export NNN_PLUG='f:finder;o:fzopen;p:mocplay;d:diffs;t:treeview;v:imgview'
export NNN_OPTS="cEnrx"
export NNN_ARCHIVE="\\.(7z|bz2|gz|tar|tgz|zip)$"
export NNN_COLORS='1234'
export NNN_FCOLORS='c1e2272e006033f7c6d6abc4'
export NNN_RCLONE='rclone mount --read-only'
export NNN_SEL='/tmp/.sel'
export NNN_FIFO='/tmp/nnn.fifo'
export NNN_LOCKER='saidar -c'
export NO_COLOR=1
#enter nn to start up nnn
nn ()  
{
    # 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 -de "$@"

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


cp & mv:
    follow the article
   
    select file and press <space>:
    .move file press v
    .copy file press p
    .delete file press x
    

plugin:
    $ cp -r your_path/nnn/plugins/* $HOME/.config/nnn/plugins
    export NNN_PLUG='f:finder;d:diffs;t:treeview' (可自已增減), 壓;f, ;d, ...動作 


啟動 plugin 功能:
    1. 壓 ; 下方會有 list
    2. 壓 f/d/t ( $NNN_PLUG)


基本使用:
1. cd on quit (離開 nnn 後,會切換到最後的目錄)
2. search:
    壓 / (像vim)
3. edit:
    在檔案上壓 e 會進入 vim ($EDITOR=/usr/bin/vim)
4. cp:
    在檔案上壓space,會出現個+,切換到其它目錄後再壓 p
5. mv:
    在檔案上壓space,會出現個+,切換到其它目錄後再壓 v
6. delete
     在檔案上壓space,會出現個+,壓x
     a. 一個一個問是否刪除: 選s後enter
     b. 直接刪除:選s後y
7. rename
    在檔案上壓ctrl+r, 左下角修改檔名

treeview
tmux split-window -h "tree -ps | $EDITOR -"


6. mmore keyboard map

沒有留言:

張貼留言