自从用了vim后,感觉到了终端中的应用程序也可以有类似于图形化的操作和鼠标支持。无论是谁,在使用电脑的时候总是离不开文件操作的,那么有没有什么简单易用的类似于图形化的文件管理工具呢?
视频教程: https://www.bilibili.com/video/BV1up4y1b7iJ/
ranger 安装在archlinux中安装
sudo pacman -S --noconfirm ranger
安装依赖
sudo pacman -S --noconfirm libcaca highlight atool lynx w3m elinks mediainfo
在macOS中安装 安装ranger,可以使用基本的功能
brew install ranger
安装依赖,这样可以使用一些扩展的功能,主要是预览相关的。
brew install libcaca highlight atool lynx w3m elinks poppler transmission mediainfo exiftool
在CentOS中安装 稍微麻烦一些,另开一篇文章。 《CentOS安装Ranger》 https://blog.csdn.net/lxyoucan/article/details/115699624
使用- 支持鼠标操作
- 文本文件上按回车可以直接打开vim编辑文件
- 响应非常快,非常快
vim imgcat
并写入以下内容:
#!/bin/bash
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# ST, and for all ESCs in to be replaced with ESC ESC. It
# only accepts ESC backslash for ST. We use TERM instead of TMUX because TERM
# gets passed through ssh.
function print_osc() {
if [[ $TERM == screen* ]]; then
printf "\033Ptmux;\033\033]"
else
printf "\033]"
fi
}
# More of the tmux workaround described above.
function print_st() {
if [[ $TERM == screen* ]]; then
printf "\a\033\\"
else
printf "\a"
fi
}
function load_version() {
if [ -z ${IMGCAT_BASE64_VERSION+x} ]; then
IMGCAT_BASE64_VERSION=$(base64 --version 2>&1)
export IMGCAT_BASE64_VERSION
fi
}
function b64_encode() {
load_version
if [[ $IMGCAT_BASE64_VERSION =~ GNU ]]; then
# Disable line wrap
base64 -w0
else
base64
fi
}
function b64_decode() {
load_version
if [[ $IMGCAT_BASE64_VERSION =~ fourmilab ]]; then
BASE64ARG=-d
elif [[ $IMGCAT_BASE64_VERSION =~ GNU ]]; then
BASE64ARG=-di
else
BASE64ARG=-D
fi
base64 $BASE64ARG
}
# print_image filename inline base64contents print_filename
# filename: Filename to convey to client
# inline: 0 or 1
# base64contents: Base64-encoded contents
# print_filename: If non-empty, print the filename
# before outputting the image
function print_image() {
print_osc
printf '1337;File='
if [[ -n $1 ]]; then
printf "name=%s;" "$(printf "%s" "$1" | b64_encode)"
fi
printf "%s" "$3" | b64_decode | wc -c | awk '{printf "size=%d",$1}'
printf ";inline=%s" "$2"
printf ":"
printf "%s" "$3"
print_st
printf '\n'
if [[ -n $4 ]]; then
echo "$1"
fi
}
function error() {
echo "ERROR: $*" 1>&2
}
function show_help() {
echo "Usage: imgcat [-p] filename ..." 1>&2
echo " or: cat filename | imgcat" 1>&2
}
function check_dependency() {
if ! (builtin command -V "$1" >/dev/null 2>&1); then
echo "imgcat: missing dependency: can't find $1" 1>&2
exit 1
fi
}
## Main
if [ -t 0 ]; then
has_stdin=f
else
has_stdin=t
fi
# Show help if no arguments and no stdin.
if [ $has_stdin = f ] && [ $# -eq 0 ]; then
show_help
exit
fi
check_dependency awk
check_dependency base64
check_dependency wc
# Look for command line flags.
while [ $# -gt 0 ]; do
case "$1" in
-h | --h | --help)
show_help
exit
;;
-p | --p | --print)
print_filename=1
;;
-u | --u | --url)
check_dependency curl
encoded_image=$(curl -s "$2" | b64_encode) || (
error "No such file or url $2"
exit 2
)
has_stdin=f
print_image "$2" 1 "$encoded_image" "$print_filename"
set -- "${@:1:1}" "-u" "${@:3}"
if [ "$#" -eq 2 ]; then
exit
fi
;;
-*)
error "Unknown option flag: $1"
show_help
exit 1
;;
*)
if [ -r "$1" ]; then
has_stdin=f
print_image "$1" 1 "$(b64_encode
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?