fish

How to generate letter sequence list in fish shell

风流意气都作罢 提交于 2020-01-11 11:09:33
问题 In bash you can generate letter sequence easily as "{a..z}", for example $ echo {a..z} a b c d e f g h i j k l m n o p q r s t u v w x y z How to do that in the fish shell instead? 回答1: Fish doesn't support ranges in brace expansion, only comma-separated values: {a,b,c} . Thus, we are forced to search for a command capable of generating such sequence. For example, you can use Perl: for c in (perl -e '$,="\n"; print ("a" .. "z")') printf ">> %s\n" "$c" end where $, is the output field

Change the default find-grep command in emacs

半世苍凉 提交于 2020-01-02 04:08:06
问题 When I execute find-grep command in emacs, I got find . -type f -exec grep -nH -e {} + , since I'm using fish shell as the default shell, to make this command work I have to execute find . -type f -exec grep -nH -e \{\} + . I tried to modify the emacs source code, below are my changes: /usr/share/emacs/24.4/lisp/ldefs-boot.el line 12669: If `exec-plus' use `find -exec \{\} +'. /usr/share/emacs/24.4/lisp/loaddefs.el line 12669: If `exec-plus' use `find -exec \{\} +'. But it doesn't make any

Fish RVM Use error

戏子无情 提交于 2020-01-01 14:35:32
问题 So I installed fish and oh-my-fish, and when i want to use rvm I get this error: ➜ avalancha git:(services) ✗ rvm use 2.1.0 Using /home/matias/.rvm/gems/ruby-2.1.0 fish: The '$' character begins a variable name. The character '{', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'. /home/matias/.config/fish/functions/rvm.fish (line 2): begin;

Bash equivalent .bash_logout for FISH shell

纵然是瞬间 提交于 2019-12-25 08:29:48
问题 Generally I write my exit scripts for bash shell in .bash_logout . I recently started using fish shell. The .bashrc equivalent of fish is located in ~/.config/fish/config.fish but where do I find the equivalent for .bash_logout ? 回答1: Instead of sourcing a specific file, you define an event handler that runs when the shell exists. From http://fishshell.com/docs/current/index.html#initialization: If you want to run a set of commands when fish exits, use an event handler that is triggered by

Terminate child process as soon as the parent fish shell process terminates?

孤街醉人 提交于 2019-12-25 00:10:55
问题 I'm spawning a fish shell as a background job and from it I'm spawning inotifywait (a process that watches a specified file and returns only once it has been changed). Later on, however, at an unspecified point in time (at which point it's not guaranteed that inotifywait had returned), I'm killing the fish shell that spawned inotifywait . My goal is for inotifywait to terminate automatically as soon as the PPID that spawned it terminates. Is there any way to do this? fish -c "inotifywait -qq

How can I replace the final character in a document with a ]?

浪尽此生 提交于 2019-12-24 16:57:46
问题 How can I replace the final character of a file with a ] ? For example, if the document content looked like this: This is the first line with a full stop. This is the second line with a full stop. This is the third line with square bracket. I would want it to look like this afterwards: This is the first line with a full stop. This is the second line with a full stop. This is the third line with square bracket] 回答1: You may specify line numbers, ranges or even the last line where you want to

How to bind Ctrl-Enter in fish?

风格不统一 提交于 2019-12-24 06:23:11
问题 In order to configure a user binding (version 2.2.0), it must be in the fish_user_key_bindings function: function fish_user_key_bindings bind \n 'commandline -f accept-autosuggestion execute' end This works fine. I wanted to expand this binding to Ctrl + Enter , by using the appropriate modifier: function fish_user_key_bindings bind \c\n 'commandline -f accept-autosuggestion execute' end This does not work: Enter uses the current (up to the cursor) suggestion (which is the default) but Ctrl +

fish shell. How to check if a variable is set/empty?

折月煮酒 提交于 2019-12-22 01:25:00
问题 How can I do something like set variable (some_command_that_may_return_a_string) if [ variable is set ] do_something and inversely how do I check if the variable is empty? 回答1: set -q var (note the missing "$" - this uses the variable name ) can be used to check if a variable has been set. set -q var[1] can be used to check whether the first element of a variable has been assigned (i.e. whether it is non-empty as a list). test -n "$var" [fn0] (or [ -n "$var" ] ) can be used to check whether a

Fish shell command subsitution

牧云@^-^@ 提交于 2019-12-21 04:26:26
问题 Is there a better way to do command substitution in fish shell? In bash I can do: ~> echo $(whoami) => user ~> echo "I am: $(whoami)" = > I am: user But in fish is looks like I have to do: ~> echo (whoami) => user ~> echo "I am: (whoami)" => "I am: (whoami)" ~> set who (whoami); echo "I am: $who" => I am: user Is that the recommended way to do command substitution in fish where the substitution needs to happen inside a quoted string? 回答1: You could just pull the substitution out of the quotes

How do I translate this `for` loop for the fish shell?

为君一笑 提交于 2019-12-21 03:29:26
问题 I'm translating a script from Z shell to Fish, and I've got this one part I can't figure out how to translate: for (( i=0; i < $COLUMNS; i++ )); do printf $1 done The only documentation for for loops I can find in Fish is for this kind. How would I do this in Fish? 回答1: It appears that the Fish shell does not have that kind of for loop, but instead requires you to take a different approach. (The philosophy is apparently to rely on as few syntactic structures and operators as possible, and do