linux 终端邪门用法

分享一些linux终端里的邪门用法

  1. 极简命令
  • alias r=ranger
  • alias n=nvim
  • c () {
    expr $(ls -l $1| wc -l) - 1
    }
  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
  1. 重写常用命令
    把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
}

剩下的好像就是常规用法了,没有太邪门的了

2 个赞

也还好吧,不至于那么邪门

补一个 十分邪门的,不要在自己电脑上面执行

:(){ :|:& };:

3 个赞

:tieba_001:嘿嘿,无论是不是邪门,我又:sweat_drops:了一贴

yes hello

蹲一下,看哪个不要命的执行

fork炸弹而已 重启就好了 :crazy_face:

常规话题软件分享