Menu
  • HOME
  • TAGS

In fish, what are the pros and cons of a function call versus sourcing a “partial” file?

function,shell,syntax,fish

Using functions gives you a few advantages over sourcing a file: You can tab-complete function names, and add custom completions to tab-complete their arguments They can be modified using funced and funcsave There's a standard place for them in ~/.config/fish/functions They can be autoloaded. The one advantage of sourcing a...

How to use vi mode in fish shell?

vim,vi,fish

Vi mode will be in the next release. If you want to use it now, do the following: Install a nightly build. If you're using Linux, you can get a nightly from here. On OS X using homebrew, use brew install fish --HEAD. You can also build from source following...

How do I get virtualfish to work on OSx

osx,fish

Yes, virtualfish is designed for the fish prompt, and so it's assumed you have it installed and are using it. If you want to use bash, you should use virtualenv instead. The fish prompt does not use .bashrc or .bash_profile, as these are of course bash-specific....

Fish command substitution doesn't work like in bash or zsh

fish

The relevant difference is called "word splitting," which is how the result of a variable expansion or command substitution is turned into multiple arguments. In bash and zsh, word splitting occurs on all whitespace. Example: > for i in $(echo 1 2 3) ; do echo $i; done 1 2...

How to terminate execution of a fish script from a sourced file?

shell,fish

It's perfectly working the way you want with bash and zsh. Still, I found a solution for fish: source b.fish; or exit 1 This will exit a.fish if b.fish exited with exit 1, and will continue otherwise....

Suppress filename/directory completion in fish shell

git,shell,tab-completion,fish

AFAIK it's not possible to totally suppress tab completions. If no command-specific completion is available, you will always get files, under the theory that something is better than nothing. What the -f flag does is prevent files from being shown alongside your options: > complete -c test_cmd -a 'alpha beta'...

Difference between `sudo su` and `sudo fish`

shell,ubuntu,root,sudo,fish

sudo su executes su as though you were the root user, Which means that the shell that is opened is the shell given in the entry of the user in /etc/passwd in the 6th field. In case of your systems root user it might be /bin/fish. That shell is...

Get current directory (without full path) in Fish Shell

prompt,fish

Taken from @Jubobs' answer: basename is just a Unix utility; it's not associated to a particular shell, and should work equally well in Bash and Fish. It appeared I was using basename in the wrong context, and without a suffix. This was solved by using the following: function fish_prompt echo...

Switching to zsh shell — `ls` ends terminal tab

bash,shell,command-line,zsh,fish

Okay, so ls is both an alias and a function. That's not gonna work because they'll recurse. On my terminal, with ls being an alias and a function, when I run ls it thinks for two seconds, then I get ls:1: maximum nested function level reached Use either a function,...

Fish Shell hangs on startup

fish

Universal variables are automatically persisted between sessions. So when you write this: set -U fish_user_paths $fish_user_paths /opt/local/bin... That the $fish_user_paths variable longer every time you start fish. Eventually it will become so big that it hangs. To fix it, you can either ensure fishd is not running and then edit...

Change the default find-grep command in emacs

linux,emacs,fish

The text you changed does not look like executable code. Probably you just changed a doc string (actually, a bit of googling reveals that this is in the documentation string for grep-find-use-xargs). But Emacs is eminently customizable; all you have to do is to set the value of grep-find-template to...

Error piping before output

shell,io-redirection,fish

You are having this problem because pipes will buffer stdout but not stderr, and therefore you are getting stderr output first. The only way to solve this is to not use pipes, and instead redirect your output to a temporary file. Then, work with that file for what you need...

fish shell -eq and -a in if statement

git,shell,tab-completion,fish,completion

In fact -eq and -a are not part of fish syntax. They are ordinary arguments! if [ (count $cmd) -eq 1 -a $cmd[1] = 'git' ] The opening square bracket here is actually a command, like cat or grep. You really do have a file /bin/[. It may be easier...

Odd text output at prompt using fish-shell

shell,ubuntu,configuration-files,fish

I think you are using nightly builds? This was a debugging line that made it into a nightly, and should have been fixed the following day. The bug tracking this is https://github.com/fish-shell/fish-shell/issues/1413 ...

fish shell: Is it possible to conveniently strip extensions?

fish

Nope. fish has a much smaller feature set than bash, relying on external commands: $ set filename foo.bar.baz $ set rootname (echo $filename | sed 's/\.[^.]*$//') $ echo $rootname foo.bar ...

Possible to change tab completion behavior in fish shell?

bash,shell,tabs,fish

I commend you for writing up this detailed and thoughtful post, and it deserves an equally detailed and thoughtful response! The tab completion behavior has been rewritten in fish top-of-tree (not yet released), and is referred to as the "new pager." You can see the design goals and discussion here....

fish shell pass argument from command

docker,fish

You are running into this issue. The short answer is that bash will further split command substitutions into separate arguments on any whitespace, while fish splits them only with newlines. Since docker-machine config dev doesn't output newlines, the outer docker command just gets one giant argument, with embedded spaces. To...

Switched my shell to fish and now rails wont load a server. How can I get it running?

ruby-on-rails,ruby,shell,fish

D-side gave this link above in a comment. https://github.com/sstephenson/rbenv/issues/195 adding these shims to my config.fish fixed the problem: set PATH $HOME/.rbenv/bin $PATH set PATH $HOME/.rbenv/shims $PATH rbenv rehash >/dev/null ^&1 ...

Use Function From Earlier in Function Path

linux,shell,fish,aliases

The usual trick is to copy the function you want to override, and then invoke the copy from within the override: functions --copy ls saved_ls function ls saved_ls end You can't do this in an autoloading ls.fish file since it would result in an infinite loop, but you can do...

Can I make an alias for `set -l` in the fish shell?

shell,fish

I'm afraid not, local variables are always local to the topmost scope, and there's no way to wrap set without creating a new scope. The best you can do is this: function def --no-scope-shadowing set $argv end This creates a variable in the calling function scope. This is subtly different...

Fish Shell - SVN log by user

shell,svn,fish

it's complaining about the line: svn log | sed -n "/$argv/,/-----$/p" | more ^here You need to escape the second $, like so: svn log | sed -n "/$argv/,/-----\$/p" | more ...

test command: difference between -n and -z

fish

It's not a bug! The command substitution (driver X) executes the driver function, and then turns each output line into an argument. In the case of (driver 0), there's no output, so you get zero arguments. So the no output case is equivalent to running test -z and test -n....

Check empty output from fish function

fish

You need to check the exit status of the test builtin. if test -n (get_ip) echo Yes else echo No end While testing, I found some inconsistency between -n and -z that I will follow up on. Try this: if test -z (get_ip) echo No else echo Yes end According...

Execute python script while open terminal

python,shell,python-2.7,terminal,fish

The fish-shell was new to me, so I read the documentation - something I really recommend. Look for the title "Initialisation Files": http://fishshell.com/docs/current/index.html#initialization So it looked like you call your python scripts from ~/.config/fish/config.fish So I installed fish on my Macbook and I had to create the config.fish file. In...

Testing command substitution output in fish

fish

This should work: if count (foo) > /dev/null ...

using virtualenv with fish shell on osx mavericks

osx,virtualenv,osx-mavericks,fish

Duplicate of How to get virtualenv to work with fish shell ? You might also try virtualfish....

Zsh global alias equivalent in fish shell

terminal,alias,fish

Zsh's global alias feature is unique to zsh. fish cannot recognize aliases except where you'd expect a command, as the first word.

Adding comments in a fish shell function file

comments,fish

The comment sign is #, as glenn jackman suggested.

How can I set PYTHONPATH in fish?

python,ubuntu,fish

Setting the variable is not sufficient, you must export it too (as you do in bash). Exporting means that subprocesses (like the Python call) will get the value too. From the fish documentation: -x or --export causes the specified environment variable to be exported to child processes So a direct...

Print list/array in columns

shell,fish

Here you go: pass in a variable name and the number of columns you want $ function columnize -a listvarname -a ncols test (count $ncols) -eq 1; or set ncols 1 printf "%s\n" $$listvarname | \ eval paste (yes - | head -n $ncols | tr '\n' " ") |...