Hot answers tagged

65

Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||). Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly: command1 and command2 command1 or command2 Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other: ...


32

I have used zsh and fish. Both offer many more user-friendly features than bash. And, I know that zsh advertises itself as a shell, versus a scripting language. And, I have to agree completely. If I'm going to write a script, I always use bash. However, for my CLI, I prefer fish. While zsh is pretty, fish, is phenomenal! I do agree with some of the ...


21

This article explains a lot of fish's advantages over bash and zsh. Fish has one great weakness though - even if it has great features, it has next to no user base or community around it. The development is not that active either - the last version is over a year old. In my personal experience zsh offers everything that fish has offer(after some ...


17

fish shell 2.1.0 is now officially supported in Cygwin, it's possible to install it using the default installer.


17

Unfortunately, the assumption that stderr is only used for error output isn't always correct. Rather, stderr is often used for any and all interactive output and diagnostics, i.e. output intended for the user to read in an interactive prompt1. wget and dd are well-known examples. Some commands will provide a flag (e.g. -quiet or -silent) to suppress non-...


17

TL;DR: Make sure RVM is up-to-date to at least 1.26.11 by re-installing or issuing the command rvm get head, and is only being initialized once per terminal environment. Result Eventually I was able to fix my environment. I will post some information pertaining to my specific problem in an effort to help some, even though others may have the same symptom ...


16

I've never used fish myself but a cursory google search brought up this page which states that Powerful History Mechanism Modern shells save previous commands in a command history. You can view earlier commands by using the up and down arrows. Fish extends this concept by integrating the history search functionality. To search the history, simply ...


13

@endolith: Yes, it only seems to affect fish. I had the same problem, the issue is caused by the sudo option "tty_tickets". Disabling this on your /etc/sudoers file will solve the problem. The following will disable tty_tickets: Defaults env_reset,!tty_tickets


13

Here's how I managed to compile fish in Cygwin. Step 1: Check that all dependencies are installed First, make sure we have the following cygwin packages: libncurses-devel libiconv autoconf (not a really a dependency of fish, but we need it for a later step) Step 2: Download and extract the latest source Next, download the latest source from http://...


13

Alt-Up arrow gives you the last argument from the previous command. Subsequent pushes cycle throught prior arguments. I haven't found a satisfactory equivalent to !!, except Up then Ctrl-A


12

Unix utilities send general messages to stdout, and error messages to stderr, so if we only want to see error messages, then it will be sufficient to suppress stdout so only stderr gets output to the console. The way to do this (in both bash and fish) is to append >/dev/null to the command. This pipes stdout into nothingness, but stderr (with your error ...


9

My current solution (see here for a maybe more recent version): egrep "^export " ~/.profile | while read e set var (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\1/") set value (echo $e | sed -E "s/^export ([A-Z_]+)=(.*)\$/\2/") # remove surrounding quotes if existing set value (echo $value | sed -E "s/^\"(.*)\"\$/\1/") if test $var = "...


9

Did you remember to mark $GOPATH in fish as exported? set -x GOPATH /home/<me>/workspace/go-workspace It's not sufficient to test with echo $GOPATH since that will work regardless of whether the variable is exported. Check with bash -c 'echo $GOPATH' which will only print the value of GOPATH if it has been exported. In bash, you export ...


7

sudo !! (or sudo bang bang) is one of my most oft used commands. I'm still using just plain old bash that has it just fine. Sorry to hear that fish doesn't implement it correctly. A little googling and I found this: function sudo if test "$argv" = !! eval command sudo $history[1] else command sudo $argv end end There are a lot ...


5

So when I run ./install.sh it should be processed by bash, right? Indeed. That's exactly what the shebang is for. Troubleshooting Save the following as test.sh and try to run it from fish. #!/bin/bash true && true It works on my computer, and it should on yours. Check if the first line of install.sh contains only the characters #!/bin/bash. ...


5

solution: choose if you want a system wide setting or an user config and edit the appropriate configuration file, don't use path_helper with fish. more fish doesn't source /etc/profile, for system wide and user config it'll read /etc/fish/config.fish and ~/.config/fish/config.fish respectively [1]. path_helper is meant for using for shells that source a ...


5

I had to be dragged kicking and screaming to use zsh at a previous job after many years of bash. But when I saw the features available in zsh and the compatibility with bash I was hooked. Now I've had to revert to bash and I miss many of the advanced features of zsh. I'd head towards zsh for the following reasons: As Bozhidar pointed out, pick a shell ...


5

Below is what I have in ~/.config/fish/config.fish for your specific example. set -gx HOSTNAME (hostname) if status --is-interactive; keychain --nogui --clear ~/.ssh/id_rsa [ -e $HOME/.keychain/$HOSTNAME-fish ]; and . $HOME/.keychain/$HOSTNAME-fish end The source command is ., which also works in bash.


5

If nothing else works, try sudo -i (by itself). That'll give you a root shell after one password.


5

In fish, $ is used only for variable expansion. Omit the $ from the command and you should be good. Say: ls -l (which vim) You might also want to refer to the documentation: Command Substitutions


5

I too had the same problem. Later I found that there is already an issue present in rvm repo for this. And they have fixed it in one of the pull requests. To fix this either upgrade the rvm to the latest version or point it to the current development revision. rvm get head For more details refer to this post.


4

It looks like you want: set -xg PATH /opt/local/bin /opt/local/sbin $PATH Edit: I see what you mean, this syntax takes some getting used to. It wants spaces instead of colons, and it can't be in quotes, and all the paths in your current PATH must actually exist (in my case, I had /usr/local/sbin in my PATH even though it didn't actually exist, and that ...


4

This is the canonical way to do so set -Ux EDITOR pico U for universal variable x to export it


4

Bash uses readline for interactive input, so syntax highlighting would need to be implemented in that program. I found a Google Groups discussion about how to code such a feature. The fish shell uses its own line editor that is specific to that program, and can not be directly ported. You may find that zsh is very similar to bash, and its line editor is ...


4

From the documentation: The and builtin is used to execute a command if the current exit status (as set by the last previous command) is 0. COMMAND1; and COMMAND2 So you'd call: make; and make install


4

Edit /etc/passwd with your favorite editor and change the last column (ie. where you see /bin/bash now) with /bin/fish. This is basically what chsh does at the end of the day, but done manually.


4

POSIX-compatible Shells (dash ksh bash zsh and many more) There's a built-in method for that. Use $(()) construction to do it: echo $((4 * 5)) It does not call any functions, so it's faster. Let's compare the ways (zsh): $ time ( echo "4 * 5" | bc ) 20 ( echo "4 * 5" | bc; ) 0.00s user 0.00s system 61% cpu 0.007 total $ time ( echo $((4 * 5)) ) 20 ( ...


4

In fish the alias command just creates a trivial function. For example, alias cmd 'cd ~/user' Is simply shorthand for function cmd cd ~/user end Because it's a function in fish you can't expand the body in the command line as you type the alias. For your situation I recommend an abbreviation; e.g., abbr cmd 'cd ~/user'.


3

~/.config/fish/config.fish is empty by default. To create a custom prompt create a file ~/.config/fish/functions/fish_prompt.fish and fill it with your prompt. Basic example function fish_prompt echo (pwd) '> ' end


3

Thanks to Aaron for responding and for all those who answered other similar questions on the stackexchange sites. For posterity's sake, here is what I figured out: path_helper is called from /etc/profile, by the syntax eval '/usr/libexec/path_helper -s' (where the apostrophes are actually backticks). Like a dummy, I didn't know how backticks worked, and so ...



Only top voted, non community-wiki answers of a minimum length are eligible