fish

Cannot understand command substitution in Fish shell

依然范特西╮ 提交于 2019-12-01 02:22:17
问题 In sh: ~$ `echo ls` bin/ Desktop/ But in fish: fish: Illegal command name “(echo ls)” ~% (echo ls) (Note that the error message appears above the command line.) ~% echo (echo ls) ls ~% eval (echo ls) bin/ Desktop/ fish: Illegal command name “(echo ls)” exec (echo ls) ^ ~% exec (echo ls) It seems that command substitution only works as parameters of a command, not as a command itself? Why? Well, the help doc does say If a parameter contains a set of parenthesis, the text enclosed by the

Bash (or other shell): wrap all commands with function/script

孤街醉人 提交于 2019-12-01 00:55:03
问题 Edit: This question was originally bash specific. I'd still rather have a bash solution, but if there's a good way to do this in another shell then that would be useful to know as well! Okay, top level description of the problem. I would like to be able to add a hook to bash such that, when a user enters, for example $cat foo | sort -n | less , this is intercepted and translated into wrapper 'cat foo | sort -n | less' . I've seen ways to run commands before and after each command (using DEBUG

Brace expansion with range in fish shell

雨燕双飞 提交于 2019-11-30 06:24:06
In bash, I can do the following $ echo bunny{1..6} bunny1 bunny2 bunny3 bunny4 bunny5 bunny6 Is there a way to achieve the same result in fish? The short answer is echo bunny(seq 6) Longer answer: In keeping with fish's philosophy of replacing magical syntax with concrete commands, we should hunt for a Unix command that substitutes for the syntactic construct {1..6} . seq fits the bill; it outputs numbers in some range, and in this case, integers from 1 to 6. fish (to its shame) omits a help page for seq , but it is a standard Unix/Linux command. Once we have found such a command, we can

How do I redirect a string in Fish?

冷暖自知 提交于 2019-11-30 02:37:09
问题 I want to redirect a string into the STDIN of a command. I would do it using something like cmd <<< "my string" in Bash, or even cmd <<EOF ... EOF . But I can't seem to do either in Fish. What am I supposed to do here? Are pipes the only way? 回答1: Yes, you would use pipes for this, e.g. echo "my string" | cmd . fish has no equivalent to the <<< operator in bash. 来源: https://stackoverflow.com/questions/25043743/how-do-i-redirect-a-string-in-fish

Open a folder in Sublime Text 3 using command line

可紊 提交于 2019-11-29 19:58:08
I'm trying to open a directory in sublime Text 3. I can launch sublime from the command line using the subl command. The help text show the following: Sublime Text build 3059 Usage: subl [arguments] [files] edit the given files or: subl [arguments] [directories] open the given directories or: subl [arguments] - edit stdin Arguments: --project <project>: Load the given project --command <command>: Run the given command -n or --new-window: Open a new window -a or --add: Add folders to the current window -w or --wait: Wait for the files to be closed before returning -b or --background: Don't

Brace expansion with range in fish shell

橙三吉。 提交于 2019-11-29 01:45:50
问题 In bash, I can do the following $ echo bunny{1..6} bunny1 bunny2 bunny3 bunny4 bunny5 bunny6 Is there a way to achieve the same result in fish? 回答1: The short answer is echo bunny(seq 6) Longer answer: In keeping with fish's philosophy of replacing magical syntax with concrete commands, we should hunt for a Unix command that substitutes for the syntactic construct {1..6} . seq fits the bill; it outputs numbers in some range, and in this case, integers from 1 to 6. fish (to its shame) omits a

Convert bash function to fish's [closed]

折月煮酒 提交于 2019-11-28 20:38:24
问题 Can someone help me convert this bash function to fish? It would also be nice if you could explain what these do like "${@%%.app}” , 's/ /.*/g’ , "$@\” etc. bid() { local shortname location # combine all args as regex # (and remove ".app" from the end if it exists due to autocomplete) shortname=$(echo "${@%%.app}"|sed 's/ /.*/g') # if the file is a full match in apps folder, roll with it if [ -d "/Applications/$shortname.app" ]; then location="/Applications/$shortname.app" else # otherwise,

Modifying PATH with fish shell

情到浓时终转凉″ 提交于 2019-11-28 17:13:17
I'm currently playing around with the fish shell and I'm having some trouble wrapping my head around how the PATH variable is set. For what it's worth, I'm also using oh-my-fish . If I echo my current path I get: ➜ fish echo $PATH /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin /opt/X11/bin /usr/texbin /Users/myname/.opam/system/bin Looking at ~/.config/fish/config.fish I see the following line set PATH /usr/local/bin $PATH /Users/myname/.opam/system/bin My question is (and this phrasing will probably reflect my lack of knowledge on the subject): prior to config.fish being

Open a folder in Sublime Text 3 using command line

对着背影说爱祢 提交于 2019-11-28 15:37:19
问题 I'm trying to open a directory in sublime Text 3. I can launch sublime from the command line using the subl command. The help text show the following: Sublime Text build 3059 Usage: subl [arguments] [files] edit the given files or: subl [arguments] [directories] open the given directories or: subl [arguments] - edit stdin Arguments: --project <project>: Load the given project --command <command>: Run the given command -n or --new-window: Open a new window -a or --add: Add folders to the

How to define an alias in fish shell?

一笑奈何 提交于 2019-11-28 13:17:50
问题 I would like to define some aliases in fish. Apparently it should be possible to define them in ~/.config/fish/functions but they don't get auto loaded when I restart the shell. Any ideas? 回答1: Just use alias . Here's a basic example: # Define alias in shell alias rmi "rm -i" # Define alias in config file alias rmi="rm -i" # This is equivalent to entering the following function: function rmi rm -i $argv end # Then, to save it across terminal sessions: funcsave rmi This last command creates