分享一些linux终端里的邪门用法
- 极简命令
- alias r=ranger
- alias n=nvim
- c () {
expr $(ls -l $1| wc -l) - 1
} - …
- 使用env文件代替 export
- cargo 的env文件, 使用方式为 source /path/to/cargo/env
#!/bin/sh
# rustup shell setup
# affix colons on either side of $PATH to simplify matching
case ":${PATH}:" in
*:"$HOME/.cargo/bin":*)
;;
*)
# Prepending path in case a system-installed rustc needs to be overridden
export PATH="$HOME/.cargo/bin:$PATH"
;;
esac
- 我自己写的env文件, 使用方式为 source /path/to/env a|b|c
prefix=`dirname $0`
_ver=${1:-a}
if [[ "$_ver" == "a" ]];then
export PATH=${prefix}/a12/bin/:$PATH
elif [[ "$_ver" == "b" ]];then
export PATH=${prefix}/b23/bin:$PATH
elif [[ "$_ver" == "c" ]];then
export PATH=${prefix}/c45/bin:$PATH
else
echo "Not support, do nothing!"
fi
- 重写常用命令
把source命令改写为use命令(rust影响的),使用方式为 use /path/to/file 直接为 source 命令,添加 子命令可以使用子命令里面的函数
use ()
{
local sub_command=$1
if [ -f $1 ] && [ $# -gt 1 ] ;then
source $sub_command
return
fi
case $sub_command in
"a")
__use_a ${@:2}
;;
"t")
__use_t ${@:2}
;;
"-h")
__use_usage
;;
"--help")
__use_usage
;;
"--version")
echo "v0.1"
;;
*)
return
;;
esac
}
剩下的好像就是常规用法了,没有太邪门的了