V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Coder89757
V2EX  ›  程序员

还在遇事不决?🙃试试这个抛硬币 jio 本吧 🌝

  •  
  •   Coder89757 ·
    Lucien-X · 2019-03-25 17:25:26 +08:00 · 4543 次点击
    这是一个创建于 1830 天前的主题,其中的信息可能已经有所发展或是发生改变。

    之前摸鱼写的 jio 本🌝,

    可以放在 ~/.zshrc 文件的末尾,注入终端的上下文

    预览效果如下:

    coin_bash_preview

    脚本正文如下:

    
    # 抛硬币脚本
    # Author: Lucien-X
    # LastModified: 2019-02-22
    
    coin() {
      # Define backspace char
      local BACKSPACE='\b\b'
      # Loop animation for about 1s
      local i="0"
      while [ $i -lt 24 ]
      do
        for COIN in '🌝' '🌖' '🌗' '🌘' '🌚' '🌒' '🌓' '🌔'
        do
          echo -en "$BACKSPACE$COIN"
          sleep 0.0417; # Insure 24 fps (1/24 ≈ 0.0417)
          i=$[$i+1];
        done
      done
      # Roll the dice eventually
      echo -en $BACKSPACE
      if [[ $[ $RANDOM % 2 ] == 0 ]] then
        echo -en "🌝"
      else
        echo -en "🌚"
      fi
    }
    
    

    之前发错发到科技版块去了

    原贴戳这里

    下面是原贴的一些其他版本实现

    fish 版本 by kinghui

    python 版本 by cgsv

    灵感来自Animating URLs with Javascript and Emojis,祝各位看官玩得开心😊

    第 1 条附言  ·  2019-03-27 11:50:43 +08:00

    集中回答下评论区的问题

    终端用的zsh,使用antigen包管理器,以下是我的.zshrc配置

    # antigen zsh包管理器 http://antigen.sharats.me/
    source ~/.antigen.zsh
    # Load the oh-my-zsh's library.
    antigen use oh-my-zsh
    # Bundles from the default repo (robbyrussell's oh-my-zsh).
    antigen bundle git
    # fast cd bundle
    antigen bundle skywind3000/z.lua
    # Syntax highlighting bundle.
    antigen bundle zsh-users/zsh-syntax-highlighting
    antigen bundle mafredri/zsh-async
    antigen bundle sindresorhus/pure
    # Load the theme.
    
    # Tell Antigen that you're done.
    antigen apply
    
    

    QOTD是我自己写的,依赖中文库加持的 fortune 和输出彩色的 lolcat

    # 每日金句
    qotd() {
    local prefix='===== Quote Of The Day ======='
    local suffix='=============================='
    local quote='\n'$prefix'\n\n'$(fortune -e chinese fortunes tang300 song100)'\n\n'$suffix
    echo $quote | lolcat
    }
    qotd
    
    36 条回复    2019-11-29 14:39:47 +08:00
    HuasLeung
        1
    HuasLeung  
       2019-03-25 17:29:14 +08:00
    有点意思
    ly4572615
        2
    ly4572615  
       2019-03-25 17:31:53 +08:00
    命运金币
    Lighfer
        3
    Lighfer  
       2019-03-25 17:34:24 +08:00
    有点意思,来个微信小程序版就更通用了撒
    yanjinbin
        4
    yanjinbin  
       2019-03-25 17:34:45 +08:00 via iPhone
    6666
    designer
        5
    designer  
       2019-03-25 17:35:10 +08:00 via iPhone
    🌚
    waler
        6
    waler  
       2019-03-25 17:36:51 +08:00 via Android
    来个 PHP 版的😂
    blacklee
        7
    blacklee  
       2019-03-25 17:43:54 +08:00   ❤️ 5
    我的最简单:跑个秒表,然后看毫秒位是奇数偶数。
    tetora
        8
    tetora  
       2019-03-25 17:44:09 +08:00 via Android
    命运硬币
    shalk
        9
    shalk  
       2019-03-25 18:13:51 +08:00   ❤️ 1
    iozephyr
        10
    iozephyr  
       2019-03-25 18:21:08 +08:00   ❤️ 2
    楼主表情输出后加个 \n,不然某些 terminal 下会在最后显示%
    tomychen
        11
    tomychen  
       2019-03-25 18:22:59 +08:00
    会玩
    zhangxs1989
        12
    zhangxs1989  
       2019-03-25 18:31:52 +08:00 via Android
    都是抛真的
    ericliu001
        13
    ericliu001  
       2019-03-25 18:35:36 +08:00
    666
    ericliu001
        14
    ericliu001  
       2019-03-25 18:36:25 +08:00
    楼主你截图中的 “ Quota of the day ”是啥插件啊?
    justyy
        15
    justyy  
       2019-03-25 19:27:47 +08:00
    666666
    Kaiv2
        16
    Kaiv2  
       2019-03-25 19:33:25 +08:00 via Android
    有意思😄
    7sDream
        17
    7sDream  
       2019-03-25 20:09:26 +08:00   ❤️ 1
    https://github.com/7sDream/coin

    昨天看 Major 睡的太晚,今天无心工作。于是抽了点时间摸鱼做了一个带配置的,可以直接 fisher 安装的 fish 版本。

    带上了原帖链接,欢迎自取。
    maninfog
        18
    maninfog  
       2019-03-25 20:25:25 +08:00 via iPhone
    你的终端用的啥,还有古诗词,能分享不
    laozhoubuluo
        19
    laozhoubuluo  
       2019-03-25 22:55:46 +08:00
    maxlzz
        20
    maxlzz  
       2019-03-25 23:25:19 +08:00 via Android   ❤️ 1
    遇事不决,可问春风
    OscarUsingChen
        21
    OscarUsingChen  
       2019-03-25 23:40:29 +08:00 via iPhone
    baiyan
        22
    baiyan  
       2019-03-26 00:30:16 +08:00
    agandong4
        23
    agandong4  
       2019-03-26 00:35:48 +08:00 via Android
    ok google ,flip a coin
    inhzus
        24
    inhzus  
       2019-03-26 00:55:30 +08:00 via Android
    同问,想问一下楼主那个 Quote of the day 是什么插件,有链接提供吗? Google 了一下没搜到
    blessyou
        25
    blessyou  
       2019-03-26 01:39:03 +08:00
    ```
    安装

    npm i random-coin -g

    开始摸鱼

    rcoin

    ```
    leeUp
        26
    leeUp  
       2019-03-26 01:41:49 +08:00 via iPhone
    @maxlzz 剑来乱入
    likiwang
        27
    likiwang  
       2019-03-26 03:00:28 +08:00 via iPhone
    iPhone 可以直接 hey Siri 让她给你抛硬币
    earlzo
        28
    earlzo  
       2019-03-26 09:50:52 +08:00
    还以为是代码有问题
    d0m2o08
        29
    d0m2o08  
       2019-03-26 10:35:13 +08:00
    那么问题来了,如何让 win10 的 cmd 支持 emoji ?
    earlzo
        30
    earlzo  
       2019-03-26 11:47:15 +08:00
    集成到工具里去了,大佬们赏个光

    https://github.com/earlzo/skr
    hellowes
        31
    hellowes  
       2019-03-26 14:27:27 +08:00
    主题好看!求问是啥主题,谢谢
    Coder89757
        32
    Coder89757  
    OP
       2019-03-27 11:31:16 +08:00
    @ericliu001

    自己写的 jio 本,依赖中文库加持的 fortune 和输出彩色的 lolcat

    ```bash
    # 每日金句
    qotd() {
    local prefix='===== Quote Of The Day ======='
    local suffix='=============================='
    local quote='\n'$prefix'\n\n'$(fortune -e chinese fortunes tang300 song100)'\n\n'$suffix
    echo $quote | lolcat
    }
    qotd
    ```
    Coder89757
        33
    Coder89757  
    OP
       2019-03-27 11:51:19 +08:00
    @maninfog append 进附言了
    Coder89757
        34
    Coder89757  
    OP
       2019-03-27 13:48:48 +08:00
    @earlzo 血统鉴定已经很显而易见了,您是一位非洲人🌚
    Kobayashi
        35
    Kobayashi  
       2019-04-23 19:48:14 +08:00
    这个叫做 terminal spinner,有专门的库搜集了一系列字符动画方便使用。

    https://github.com/sindresorhus/cli-spinners

    https://github.com/ManrajGrover/py-spinners
    Coder89757
        36
    Coder89757  
    OP
       2019-11-29 14:39:47 +08:00
    @Kobayashi 赞哦~Star 了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1346 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:38 · PVG 07:38 · LAX 16:38 · JFK 19:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.