根据主机名更改鱼壳提示

时间:2018-08-03 19:05:03

标签: bash fish

当我通过<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <body style="background-color:rgb(218,218,218);"> <nav class="navbar navbar-dark navbar-expand-md bg-dark"> <div class="container-fluid"><a class="navbar-brand" href="#">Random Student Generator</a> </div> </nav> <section id="id-generator" style="padding:40px;"> <div class="container"> <div class="row"> <div class="col" id="title-generator"> <h1>Please create your Random ID Here</h1> </div> <div class="col-12" id="input-yourname"> <label>Input Your Name</label> <input class="form-control-lg d-block" type="text" name="yourname" required="" id="yourname" style="width:75%;"> </div> <div class="col-12" id="input-locker-id"> <label>Input Your Locker ID</label> <input class="form-control-lg d-block" type="text" name="lockerid" required="" id="lockerid" style="width:75%;"> <input type="hidden" name="secret" id="secret"> </div> <div class="col-12" id="generate" style="margin-top:20px;"> <button class="btn btn-primary" type="button" onclick="getValue()">Generate ID</button> </div> <div class="col-12" id="result-generator" style="margin-top:20px;"> <label>Your Random Student Identifier Result :</label> <input class="form-control-lg d-block" type="text" name="result" id="randomidresult" style="width:75%;" readonly> </div> <div class="col-12" id="copy-id" style="margin-top:20px;"> <button class="btn btn-dark" type="button" onClick="copy(document.getElementById('randomidresult').value)">Copy Generated ID</button> </div> <div class="col-12" id="go-back" style="margin-top:20px;"> <button class="btn btn-success" type="button" onclick="goBack()">Go Back To Previous Site</button> </div> </div> </div> </section> <script> function goBack() { window.history.back(); } function secret() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for (var i = 0; i < 5; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); } return text; } function getValue() { var randomidresult = document.getElementById("randomidresult"); var yourname = document.getElementById("yourname").value; var lockerid = document.getElementById("lockerid").value; var secretcode = secret(); randomidresult.value = yourname + "-" + lockerid + "-" + secretcode; } function copy(val){ var textArea = document.createElement("textarea"); textArea.value = val; document.body.appendChild(textArea); textArea.select(); document.execCommand("Copy"); textArea.remove(); } </script>在另一台机器上时,如何更改鱼壳提示。

我可以在提示配置的顶部运行ssh,并在需要调用set -q __fish_prompt_hostname时运行它,但是当我"$__fish_prompt_hostname"到另一台计算机时,它找不到主机名并显示它。

我知道使用bash ssh是可行的方法,但是对于fish我不确定如何获取主机名。 (我还想根据主机名更改提示的颜色,因为某些机器比其他机器更易变。)

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

您可以通过将set -x HOSTNAME (hostname)放入〜/ .config / fish / config.fish 中来模拟bash。您可能更喜欢使用set -x HOSTNAME (hostname | string split -m1 '.')[1]从中剥离域名。这就是prompt_hostname函数用来设置__fish_prompt_hostname变量的作用。

相关问题