date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,297,916,768,000
I regularly ssh on several different servers, some of which don't have fish installed, but many do. I'd like to get fish as shell if available (changing midway is always tedious, and you lose the history of what you already typed), but changing the default shell is not a good idea, as: there are many different machin...
After some experiments, I put together the fissh script: #!/bin/sh ssh "$@" -t "sh -c 'if which fish >/dev/null ; then exec fish -li; else exec \$SHELL -li; fi'" "$@" forwards all arguments passed to ssh -t forces the allocation of a tty (otherwise ssh defaults to no tty when a command is specified) sh -c is require...
How to use fish on remote servers that have it installed without changing login shell?
1,297,916,768,000
I'm trying to test in a fish shell script for the existence of the figlet binary. Since I use Linux and OS X I cannot rely on the file being in the same location and need to resolve it dynamically. I'm used to doing this with $(which) in bash, which works. With fish though this does not work properly. Why? function pr...
Use type in fish like in Bourne-like shell: if type -q figlet hostname | figlet end Or to limit to executables in $PATH (ignoring functions, builtins): if command -s figlet > /dev/null hostname | figlet end See also Why not use “which”? What to use then?
Fish shell testing for existence of file in $PATH
1,297,916,768,000
I am working on my fish.config for using the fish shell. I am trying to compare strings using bash syntax but fish doesn't accept the syntax. There is clearly another way to do it. Any suggestions for a solution as clean as the bash solution below? if [[ $STRING == *"other_string"* ]]; then echo "It contains the ...
It looks to me like there's a string function for that purpose: $ set STRING something here $ string match -q "other_string" $STRING; and echo yes $ set STRING some other_string here $ string match -q "other_string" $STRING; and echo yes yes Or: if string match -q "other_string" $STRING echo it matches else echo ...
Does one string contain another in fish shell?
1,297,916,768,000
I would like to have Ubuntu's MOTD in the fish shell. Ubuntu's default is as follows: That is essentially what I would like to see when open up my terminal (terminator, which loads fishfish) As far as I can make out (Based on the information here), the default shell executes pam_motd, which in turn executes a bunch o...
Put this in your ~/.config/fish/config.fish: function fish_greeting status --is-login if [ $status != 0 ] cat /run/motd.dynamic end end This will make sure that you don't get the double motd when logging in remotely.
Get default ubuntu motd in fish shell
1,297,916,768,000
As is, the code below is invalid, because the brackets can not be used like that. if we remove them, it runs fine, and outputs: true true code: #!/usr/bin/fish if ( false ; and true ) ; or true echo "true" else echo "false" end if false ; and ( true ; or true ) echo "true" else echo "false" end How...
You can use begin and end for conditionals as well: From fish tutorial: For even more complex conditions, use begin and end to group parts of them. For a simpler example, you can take a look at this answer from stackoverflow. For your code, you just have to replace the ( with begin ; and the ) with ; end. #!/usr/bin...
How to group multiple conditions in an if statement in fish
1,297,916,768,000
I switched to fish shell and quite happy with it. I didn't get how can I handle booleans. I managed to write config.fish that executes tmux on ssh (see: How can I start tmux automatically in fish shell while connecting to remote server via ssh) connection but I'm not happy with code readability and want to learn more ...
You can structure this as an if/else chain. It's possible (though unwieldy) to use begin/end to put a compound statement as an if condition: if begin ; tmux has-session -t remote; and tmux attach-session -t remote; end # We're attached! else if begin; tmux new-session -s remote; and kill %self; end # We create...
How to use booleans in fish shell?
1,297,916,768,000
When I write a command that does not exist in the fish shell (let's say l instead of ls), fish takes some time before responding that the command does not exist. I don't know if it looks for package to install or something else, but it is a bit annoying and I need to hit Ctrl-C to avoid waiting a few seconds. Is there...
Since the other answer does not work anymore, I found another solution which consists of adding this function in config.fish: function __fish_command_not_found_handler --on-event fish_command_not_found echo "fish: Unknown command '$argv'" end
Fish shell slow to respond when command does not exist
1,297,916,768,000
I am trying to alias an executable in a directory with a space in it. For example: alias myfile="/home/ben/test case/myfile" Now, this is not expanded the way I want (it thinks /home/ben/test is the executable). In bash you can add extra quotes: alias myfile="'/home/ben/test case/myfile'" Sadly, in fish this does no...
alias in fish is just a wrapper for function builtin, it existed for backward compatible with POSIX shell. alias in fish didn't work as POSIX alias. If you want the equivalent of POSIX alias, you must use abbr, which was added in fish 2.2.0: abbr -a myfile "'/home/ben/test case/myfile'" or: abbr -a myfile "/home/ben/...
fish: whitespace in alias
1,297,916,768,000
I'm trying to add the following bash scripts to fish, yet am having trouble getting the syntax in fish right. Here is the original script: export MINION_INSTALL=$HOME/minion export NOTES_HOME=$HOME/Notes export INBOX=$NOTES_HOME/inbox if [ -d "$MINION_INSTALL" ] ; then export PATH="$MINION_INSTALL:$PATH" fi sour...
Here's some examples of what this would look like in fish: set -x INBOX $NOTES_HOME/inbox if [ -d "$MINION_INSTALL" ] set -x PATH $MINION_INSTALL $PATH end Note the absence of the quotes, which is especially important in the line that sets PATH. Quoting it would collapse all of the paths in the list to a single e...
Converting bash script to fish
1,297,916,768,000
I just recently switched to the fish shell from bash and I am having trouble sourcing my dircolors template file to get custom colors to appear for certain file extensions. In bash, I was sourcing a template from ~/.dircolors/dircolors.256dark. The dircolors.256dark template has different file types mapped to differe...
The solution was actually pretty simple. Within my ~/.config/fish/config.fish file, I just needed to drop the "$" from the eval statement. So it would look like this: # uses dircolors template eval (gdircolors ~/.dircolors/dircolors.256dark) # Aliases alias ls='gls --color=auto'
Using ~/.dircolors in fish shell
1,297,916,768,000
I switched from bash to fish shell. I liked it and decided to use it on my servers also. How can I start tmux automatically on ssh connection? I followed this instruction for bash but fish shell is different and this recipe doesn't work without cardinal rewriting.
Byobu, a terminal multiplexer, based on tmux, offers an autostart feature.
How can I start tmux automatically in fish shell while connecting to remote server via ssh
1,470,216,637,000
This is kind of a followup to another question. I use a custom command in my gnome-terminal profile (/usr/bin/fish). When using Ubuntu 14.04 a Ctrl-Shift-N opened a new gnome-terminal window in the same directory as the current terminal. With 16.04 this changed and now it always opens in $HOME. I want the old behavior...
As Gilles mentioned in a comment, setting the SHELL variable works as well. It does not have downside of my other answer. Here are the details: Create .xsessionrc in your home directory with contents: SHELL=/usr/bin/fish Disable custom command in gnome-terminal profile options. Log out and in again. Gnome-terminal ...
Gnome-terminal custom command and dynamic working directory
1,470,216,637,000
Readline and therefore Bash have a very useful command called operate-and-get-next, bound by default to Ctrl-O, that executes the current line, after selecting it from the history, and advances the history pointer by one, instead of clearing the command line prompt, as Enter would do. So if you wish to repeat a number...
Fish does not have the concept of a "history pointer", which points at the currently selected history entry, so the answer is: No.
Fish equivalent of Bash / readline's Ctrl-O "operate-and-get-next"
1,470,216,637,000
I have recently moved to fish from bash. I'm immediately in love with the out-of-the-box functionality, but I'm a little bit at a loss when it comes to configuring the shell. I've read through the documentation, particularly the section about initialization, and it states: On startup, Fish evaluates a number of confi...
As far as purpose, I'd say there are several good reasons to support both. First, and probably most importantly, as @Zanchey points out in the comments, conf.d support came about in release 2.3.0, so getting rid of config.fish at that point would have been a breaking change. Second, as you said, freedom for the users ...
What is the purpose of (and possibly the convention of using) multiple locations for user configuration in fish shell
1,470,216,637,000
In the zsh shell, I can write something into the command line history like so: #!/bin/zsh cmd="cd /special/dir" print -s $cmd" # save command in history for reuse How may I do that in the fish shell?
AFAICT, only the read builtin and the shell command line reader can add entry to the history, but only when stdin is a tty device, so that's not easily scriptable. But you could add the entry by hand with something like: function add_history_entry begin flock 1 and echo -- '- cmd:' ( string replace -- ...
How to write a command to history in fish shell?
1,470,216,637,000
I decided to try fish shell, and I'm having trouble with some aliases. So I guess the painless way of doing the things would be executing the bash commands inside fish shell functions. Something like that : function fish_function start bash ... bash commands ... stop bash end Is that possible? e.g: the command ...
Apparently fish uses ; and for && and () for command substitutions. So just changing the command to pacman -Qtdq; and sudo pacman -Rns (pacman -Qtdq) should work. Answering the actual question, normally you can get a statement to be executed in Bash simply by redirecting the statement to a bash command's STDIN by an...
Execute bash command inside fish function
1,470,216,637,000
This is Bash. The behavior is similar in fish. $ which python /usr/bin/python $ alias py=python $ type py py is aliased to `python' ​And then, running type -P py prints nothing, where as I expected to print /usr/bin/pyton in a similar fashion to what is seen below.​ $ type ls ls is aliased to `ls --color=auto' $ type...
This: force a PATH search for each NAME, even if it is an alias, does not mean that bash will expand the alias and then search for the expanded command. It means that, if there were a command foo, and also an alias foo, the type -P foo will still look for the command named foo, even though there's an alias masking i...
Issue with type force PATH search
1,470,216,637,000
I ran into an issue trying to dynamically set some variables based on output of a program, in a fish function. I narrowed my issues down to a MWE: function example eval (echo 'set -x FOO 1;') end calling: >example >echo $FOO results in no output -- ie the FOO environment variable has not been set. How should I ...
The same thing happens in a simpler form: function trythis set -x foo bar end If you now run trythis and echo $foo, it is not set either. That's because fish's -x by itself doesn't change the scope of the variable, which is by default local to the function unless it exists globally or universally already. Try: ...
Why doesn't set -x work within eval within a function in fish?
1,470,216,637,000
I want to define a function, and call that function every n seconds. As an example: function h echo hello end Calling h works: david@f5 ~> h hello But when using watch, it doesn't... watch -n 60 "h" ...and I get: Every 60.0s: h f5: Wed Oct 10 21:04:15 2018 sh: 1: h: not fou...
Another way would be to save the function, then ask watch to invoke fish: bash$ fish fish$ function h echo hello end fish$ funcsave h fish-or-bash$ watch -n 60 "fish -c h" funcsave saves the named function definition into a file in the path ~/.config/fish/functions/, so ~/.config/fish/function/h.fish in the above...
Define function in fish, use it with watch
1,470,216,637,000
In fish, when I type history | less I see the following for example: history | less export HISTTIMEFORMAT="%h/%d - %H:%M:%S " bash in bash I see this: 491 18/04/16 14:31:02 cd 492 18/04/16 14:31:02 ls -l 493 18/04/16 14:31:02 less .bashrc so I can execute the command again with !491 for example and I also ...
fish tracks but does not yet surface the history timestamps. See issue #677 - there's some contributed scripts in there to parse the history file. fish does not support exclamation mark history expansion, because the syntax is hard to remember and it's often invoked by mistake. You can follow the discussion in #288. W...
Why there isn't a number of the command and a timestamp for fish?
1,470,216,637,000
Is it possible to set environment variables with export in Fish Shell? I am working on a project that configures variables this way and it does not make sense to maintain a separate configuration file just for fish. Consider this example in bash: echo -e "foo=1\nfoobar=2\n" > foo; export $(cat foo | xargs); env | gr...
Your example almost works perfectly - it's not export that's the problem, but the use of xargs. Try: echo -e "foo=3\nfoobar=4" > .env; export (cat .env); env | grep foo The reason is that a command substitution separates arguments on newlines, and xargs removes them: > count (cat .env | xargs) 1 > count (cat .env) 2...
Fish Shell: How to set multiple environment variables from a file using export
1,470,216,637,000
I want to check a condition if a variable is null in fish(friendly interactive shell). if test "$argv" = null # do something... else # do something else...
I don't know "fish" specifically, but I do know the standard "test". Try: test "$argv" = "" or test "x$argv" = x or test -z "$argv" This assumes you are wanting to test for it being unset or empty. If you only want one of those two cases, you will need shell specific variable expansion modifiers. Note that the second ...
check if variable is null in fish
1,470,216,637,000
I often start a long running command that is bound to either CPU, Disk, RAM or Internet connection. While that is running, I find that I want to run a similar command. Let's say downloading something big. Then I start a shell with wget ...1 and let it run. I could open another shell and run the other wget ...2, but no...
If you have already running wget http://first in foreground you can pause it with CTRL+z and then return it back to work with another command right after it: fg ; wget http://second It should work in most cases. If that way is not acceptable, you should go with lockfile. Or even just to monitor the process via ps (lo...
Queue a task in a running shell
1,470,216,637,000
I'm trying to set the fish history pager to be bat -l fish for syntax highlighting. (i.e. set the PAGER environment variable bat -l fish just for the history command). I tried: # 1: alias history "PAGER='bat -l fish' history" # results in "The function “history” calls itself immediately, which would result in an infi...
Two things are happening here: fish's alias actually creates a function. fish ships with a default history function already. So when you write alias history "PAGER='bat -l fish' history" what you actually have is the recursive function function history PAGER='bat -l fish' history $argv end Some solutions: us...
how to alias the `history` function in fish shell
1,470,216,637,000
if you curl https://www.toptal.com/developers/gitignore/api/python you see the file as expected, with newlines. But if I set response (curl https://www.toptal.com/developers/gitignore/api/python) echo $response in fish the newlines are gone. I've looked at fish read but url $gitignoreurlbase/python | read response #...
Replace set var (command) with set var (command | string split0) Explanation: command substition splits on newlines by default. The $response variable is a list of lines of the output. This is documented $ set var (seq 10) $ set --show var $var: not set in local scope $var: set in global scope, unexported, with 10 ele...
fish shell : capture multi-line output to a variable with piping or read
1,470,216,637,000
I've been trying to learn to use jq and for bash it uses the <<< operator which I cannot understand after reading the bash documentation, what is this operator for? Besides that, I use the fish shell instead. How can I translate jq . <<< '{"some": "xyz"}' (works in bash) to the fish shell?
The <<< operator is a here-string 3.6.7 Here Strings Given: [n]<<< word The word undergoes brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal. Pathname expansion and word splitting are not performed. The result is supplied as a single str...
Bash operator translation to fish
1,470,216,637,000
I'm using fish shell. Let's say that I have a directory named books, containing files title-1, title-2 and title-3: $ tree books books/ ├── title-1 ├── title-2 └── title-3 0 directories, 3 files If I type git add boo and press tab, fish will automatically complete to git add books/title- . I can press tab multiple t...
You don't. Fish's git completions print the entire path and there is no configuration option to disable this. You can press ctrl-w to delete back to the last "/".
When pressing tab, how can I make fish complete to directory/ instead of directory/prefix?
1,470,216,637,000
After doing an OS upgrade (opensuse leap 15.2 -> 15.3), my XDG setup broke. Among other things, my XDG_DATA_DIR env var uses two different value separators: : and . Current XDG_DATA_DIRS value: /home/bernard/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/d...
I don't know about the dot: I think you'll have to dig into which process is adding that. The last directory element separated by a space is telling though. It seems you're adding a directory to XDG_DATA_DIRS in fish and expecting subprocess to get a colon-separated value. fish does that automatically only for PATH va...
XDG_DATA_DIRS env variable using two separator types in fish shell
1,470,216,637,000
So I'm trying to change my fish shell terminal prompt but every time I change anything too complicated (beyond colour changes and rearranging the prompt), it just turns up blank. I'm running Arch Linux. I've tried lots of terminal emulators. termite, kitty, konsole, simple terminal, rxvt-u, terminology. None of the no...
This is a bug in fish triggered by using non-ASCII chars with a non-unicode capable locale. Set your locale to something that can handle UTF-8 (i.e. not the default "C")
Terminal fish prompt blank
1,470,216,637,000
I have a bit complicated question. I am using Windows 10 Anniversary Update with Bash for Ubuntu. I am connecting to server via ssh. This server uses fish shell. And when I press arrows it just prints some symbols instead of showing me command history or guessing my next command. Here is what I see: arrow up prints [...
The Windows 10 Anniversary Update with Bash for Ubuntu is essentially running bash in a console window, whose escape sequences (including input such as arrow keys) are documented in MSDN: Console Virtual Terminal Sequences By itself, ssh is largely irrelevant (it passes characters to/from the remote machine unchange...
Windows bash takes arrows as symbols via ssh and fish shell on server
1,470,216,637,000
this is my fish configuration: set -x CGO_CPPFLAGS 'llvm-config --cppflags' set -x CGO_LDFLAGS 'llvm-config --ldflags --libs --system-libs all' set -x CGO_CXXFLAGS '-std=c++11' I've tried running make on my LLVM-based project, but I get the following error: clang: error: unsupported option '--cppflags' clang: error: ...
Try setting the variables to the output of llvm-config using command substitutions, rather than the raw commands themselves: set -x CGO_CPPFLAGS (llvm-config --cppflags | tr -s ' ' \n) set -x CGO_LDFLAGS (llvm-config --ldflags --libs --system-libs all | tr -s ' ' \n) set -x CGO_CXXFLAGS '-std=c++11' The pipe through ...
Can't seem to set environmental variables in fish correctly?
1,470,216,637,000
I've been using terminator, and recently started using fish. When terminator starts (bash) I can use, for example, node just fine. If I then start fish I can still run node just fine. I set terminator to "Run a custom command instead of my shell", in this case fish, but then I can no longer just run node. Terminal say...
Given your description of the symptoms, you've evidently installed node in a location which is not on your system's default command search path. There's nothing wrong with that, you just need to add that location to the PATH environment variable. That's what you did wrong: you did that in the wrong file. Unfortunately...
Start bash then autostart fish with terminator
1,470,216,637,000
I gather that bash has a "magic space" function, where if I do e.g. sudo !!<space> it will blow in sudo ./my_last_command. Does something similar exist in fish?
From the FAQ in the source (I can't find any documentation online): Why doesn't history substitution ("!$" etc.) work? Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Fish drops it in favor of perfecting the interactive history rec...
Does Fish have a "magic space"?
1,470,216,637,000
I am trying to write some completions for an in-house tool. We'll call it thetool. Lots of the commands to thetool do not take a 'file' as an argument. I thought that --no-files and/or --exclusive would do this for me but I don't seem to be able to get it to work. In other words how can I write completions so that the...
You have no call that ever tells fish to disable files if it has seen non-file-command. Let's go through them: complete --command thetool --no-files --condition "not __fish_seen_subcommand_from file-command non-file-command" --arguments "file-command" --description "file-command" fish has seen non-file-command, the c...
Fish Completions - How to prevent file completions?
1,470,216,637,000
I was trying to learn and write some fish scripts, but I encountered a strange issue. # a.fish # this is a fish script set temp (getopt -o abc -l ace,bad,correct -- $argv) echo $temp When I ran fish ./a.fish -a -b --correct it worked fine and output -a -b --correct -- However, when I changed the $argv to "$argv" a...
Yes, different shells are different. strace as always can help show what exactly is sent through an execve(2) call. $ cat fecho /usr/bin/echo $argv $ cat fechoquoted /usr/bin/echo "$argv" $ fish ./fecho a b c a b c $ fish ./fechoquoted a b c a b c $ Yet these two are actually rather different under the strace-scope...
Is $argv in fish shell different from $@ in bash?
1,470,216,637,000
Situation: Need to login to multiple remote servers with some of them having fish shell Requirement: Default shell is bash. If I login to a server and fish is present, switch to fish shell, otherwise stay on bash. Tried .bashrc: # .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc f...
To exit the bashrc file when the shell session that is sourcing it is not interactive, you may do the following at the top (or in a convenient location) of the file: case "$-" in *i*) ;; *) return ;; esac The value in $- is a string of letters denoting the currently set shell options. If the i chara...
Issues with scp if I use bashrc to open fish if present
1,470,216,637,000
I have downloaded fish shell on my centos, but when I switch command to /bin/fish or even try to run xterm -e /bin/fish I am getting following error: Standard input: echo $_ " "; __fish_pwd ^ in command substitution called on standard input, Standard input: __fish_pwd ...
The issue here is that fish cannot find its function directory. The rpm you downloaded has been built with a certain $fish_function_path, and those values aren't valid. What you'd need to do is adjust those to where you actually placed the files - something like set fish_function_path ~/.config/fish/functions /etc/fis...
launching fish shell to new terminal of tcsh on centos
1,470,216,637,000
The fish documentation gives the following way to run a for loop. for i in 1 2 3 4 5; echo $i end Let us say I want to run a command 1000 times, How can I do it?
Same documentation, https://fishshell.com/docs/current/language.html#loops-and-blocks : for i in (seq 1 5) echo $i end replace seq 1 5 with the numbers you want to get, e.g., seq 14 1000 to get the numbers from 14 to 1000; if you want to start at 1, it's OK to omit the starting point, i.e., write seq 1000. This, ...
How to run a command n times in the fish shell?
1,470,216,637,000
How can I use sed to replace new line character with any other character? Input: I cannot conceive that anybody will require multiplications at the rate of 40,000 or even 4,000 per hour ... -- F. H. Wales (1936) Desired output: I cannot conceive that anybody will require multiplicat...
tr is probably a better tool for this job. Try the following pbpaste | tr '\n' ' ' With your input, I get the following output. I cannot conceive that anybody will require multiplications at the rate of 40,000 or even 4,000 per hour ... -- F. H. Wales (1936)
sed replace newline character with space
1,470,216,637,000
I'm trying to shift to fish from zsh. As I've seen, load time of fish increases if I use alias. So I'd like to convert all of my alias into functions, but the thing is creating a function script for every alias is a bit hectic. So how do I add those alias in a single function script?
Based this Stack Overflow example by ridiculous_fish, I would suggest creating a file under ~/.config/fish/ with the functions defined in them, then add a line to source that file in your ~/.config/fish/config.fish file. Example contents of ~/.config/fish/all-my-functions.fish: function example-function1 ls -l $argv...
How do I add multiple fish functions in a single script?
1,470,216,637,000
I have tool that is able to create a completion file for bash, zsh and fish. I normally use zsh, but i cannot get this completion file to work on zsh. So as a test i installed fish and created the completion file for fish. Also that one i cannot get to work. All other completions are working fine in zsh and in fish, s...
My answer addresses zsh (with the “new” completion system, i.e. after calling compinit) and bash. For fish, see NotTheDr01ds's answer. If there is a syntax error in the completion file, you'll see an error message when the completion code is loaded. In bash, this happens when /etc/bash_completion is loaded. In zsh, th...
Is there a way to validate a completion file?
1,470,216,637,000
I recently started using the Fish shell. echo $EDITOR returns vim But yet, when using programs that need to launch an editor and look for it in the EDITOR environment variable they don't seem to find anything. As an example when using pass edit (from https://www.passwordstore.org/) it returns vi: command not found (it...
Note that a few programs look for the $VISUAL environment variable before the $EDITOR environment variable, so if you have both set, $VISUAL will take precedence. Also note that shell variables are just that, variables in the shell language. You'd need to call commands with EDITOR=preferred-editor in their environment...
Fish EDITOR environment variable does not seem to work
1,470,216,637,000
I'd like to take the csearch output and color it. It looks like so: /home/bp/whatever.txt:1:foo And this works: csearch -n -- $term \ | env GREP_COLORS='mt=02;35' grep --color=always -P '^[^:]+:[^:]+:' \ | grep -P --color=always -- $term \ | less -RFX However, it waits for the full output of csearch to be com...
I was using fish, which means I wasn't actually using grep, but: function grep command grep --color=auto $argv end and fish code blocks do not stream their output. This wasn't a problem in the first grep since it was already wrapped by env, so it ignored this function. Changing grep to /bin/grep fixed it.
Output pipe waits for EOF in fish [closed]
1,470,216,637,000
A quick google search says I could enable auto logout (for text consoles) by setting a TMOUT parameter. However, I discovered later that this would only work with the bash shell. Is there a way I could set a timer for auto logout if my default shell was fish? What is the purpose? Security, of course. I want it to lock...
While Fish itself doesn't include support for TMOUT directly, there are a few alternatives that might work for you. Given the fact that my two approaches are so radically different, I'm going to include them in two separate answers. First (and not my preferred approach, but it's closest to the Bash functionality), de...
How to enable auto logout in fish shell?
1,621,502,663,000
I'm already scratching my head for a while because of this: > cat file line1 line2 > set tst (cat file) > echo "$tst" line1 line2 > set tst "(cat file)" > echo "$tst" (cat file) In bash I can get it done like so: $ cat file line1 line2 $ tst=$(cat file) $ echo "$tst" line1 line2
By default, fish splits command substitutions ((command)) on newlines. To override that behavior, you can use the special string subcommands like string split (which allows you to define what to split on), string split0 (which splits on NUL bytes) and string collect (which doesn't split at all[0]). So the answer is: s...
How to preserve formatting in fish shell command substitution output stored in the var?
1,621,502,663,000
I have a function that is setup to send status updates to anybar. function e --description 'Run command' \ --argument-names command anybar yellow; eval $command; anybar green; end I am trying to find a way wrap all of my commands that I give through cli to fish in this function. Does anyone know if this ...
Instead of this method, try adding the following to your config.fish: function my_preexec --on-event fish_preexec anybar yellow end function my_postexec --on-event fish_postexec anybar green end This will run these functions before and after every command, without requiring the potentially-explosive eval.
Fish Wrap all commands in a function
1,621,502,663,000
I noticed the error this morning, but I don't think I have changed anything last night, so I am very confused right now. Perhaps I updated some utilities on my system and it somehow broke the back compatibility. Basically I got a math: Error: Missing operator error when using tab completion. Say I type fish, and hit T...
The error goes away after I remove the line set -px PATH $PLAN9/bin. I guess it was because I accidentally shadowed some system utilities with its counterpart in Plan 9 from User Space. Another workaround is to use set -ax PATH $PLAN9/bin instead. By using -a, the directory $PLAN9/bin is appended to $PATH (as opposed ...
Fish shell reports "math: Error: Missing operator" on tab completion
1,621,502,663,000
Oh-my-zsh has the take command which creates a directory and enters into it in one step. Is there an equivalent command for the fish shell? I do know that I can do it with mkdir newDir && cd newDir, but I like the shorter, more convenient version that Oh-my-zsh provides.
Not built-in, but very easy to reproduce: function take mkdir -p "$argv[1]"; and cd "$argv[1]" end funcsave take This will create a lazy-load function in $HOME/.config/fish/functions/take.fish. By "lazy-load", we mean that the function isn't loaded when Fish starts, but only the first time you run the take comm...
Oh-my-zsh "take" command - Is there an equivalent in Fish?
1,621,502,663,000
I am using fish and am working on a project with a script that's frequently invoked for build tasks called x.py. I'd like to create an alias that maps x to ./x.py. However, I only want this to apply inside that specific directory. The fish documentation gives a fairly detailed explanation on how to make various kinds ...
Three possibilities that I can think of (other than the ones that Damir suggested). First, if at all possible, I'd just test whether or not you are in the directory in a "lazy-load" function. This is similar to what Damir recommended, but it avoids the overhead of being in your startup config or in an executable scr...
fish shell alias only in specific directory
1,621,502,663,000
I'm pretty certain this is some foible of my SSH client (RoyalTS for Windows) but, having just installed and changed to fish shell, my prompt is preceded by two dark-grey ⎠characters. It doesn't seem to do it in PuTTY, just in this particular client, which uses a Rebex plugin. The fish FAQ talks about random charact...
I'm sure they are just some sort of mis-encoded control characters, but I'm just trying to work out what these two characters are, ⎠is what happens when one displays the transmitted octets \xc2 \x8e decoded with Windows code page 1252. Your terminal emulator is using a single-byte character set. Decoded as UTF-8...
Fish shell shows dark-grey "âŽ" characters in prompt
1,621,502,663,000
I'm running Fish version 3.7.0, and I want to write a function to remove elements from lists, based on their index. For instance, I want to remove the element from PATH environment variable at index 2: set -l variable_name PATH set -l index 2 set -e $variable_name[$index] However, the follow statement does not work, ...
The issue is that fish takes $var[$foo] as "the footh element of $var", where you want "expand $var, expand $foo, and attach both together". You can use a variety of ways to express what you want, the cleanest is probably: set -e $variable_name[1][$index] This will expand the first element of $variable_name ("PATH"),...
Fish needs a lazy evulation to remove an element from a list
1,621,502,663,000
I was wondering if there is an easy way to configure ZSH (I am using oh-my-zsh) and/or FISH (just started fiddling with this) to not keep the cursor/promt at the bottom of the terminal as soon an the buffer exceeds the number of displayable lines but rather at the middle of the screen. The reason for this is that I ke...
A quick trial shows this seems to work in ZSH: PS1=$'\n\n\n\n\n\n\n\n\e[8A'"$PS1" This has the prompt print 8 newlines, then moves the cursor back up 8 lines with the \e[8A escape code, before printing the actual prompt. You can add more newlines and increase the scroll-up to match, depending how far off the bottom y...
Keep cursor/prompt vertically centered in ZSH/FISH
1,621,502,663,000
To improve compile times, the Arch wiki states, Users with multi-core/multi-processor systems can specify the number of jobs to run simultaneously. This can be accomplished with the use of nproc to determine the number of available processors, e.g. MAKEFLAGS="-j$(nproc)". If I set this in Fish shell via set -Ux MAKE...
Neither. In fish, command substitution cannot be quoted. set arg "-J(nproc)" set -S arg $arg: set in global scope, unexported, with 1 elements $arg[1]: |-J(nproc)| Use set -Ux MAKEFLAGS "-J"(nproc)
What's the correct format for MAKEFLAGS when using Fish shell?
1,621,502,663,000
I am using iTerm2 on my mac pro, and using fish as my shell. Every time I have a process running and I break it by pressing ctrl+c, the arrow keys stops working after and starts emitting ^[[A etc. Attached a screenshot to my iTerm2 preferences > Profiles [Default] > Terminal
The program has switched to application mode for the cursor-keys (and does not cleanup when interrupted). You can manually switch back using this command: tput rmkx Some terminal emulators have a setting in a dialog which lets you do the same thing.
MacOS/iTerm2/fish arrow keys stops working after terminating a process with ctrl+c
1,621,502,663,000
I changed the default shell with chsh -s `which fish` but my terminal still launches with bash. If I run chsh again, it says chsh: Shell not changed. I'm using Manjaro x86_64 20.2.1 with XFCE (4.16). This is a mainly clean install (like 4 days old), only really having neofetch, and fish.
Fixed the problem by rebooting. I feel silly now
xfce terminal ignores set default shell
1,621,502,663,000
I made fish function in ~/.config/fish/functions/confgit.fish: function confgit /home/john/Projects/confgit $argv end But when I run this function it just says: fish: The file “/home/john/Projects/./confgit” is not executable by this user /home/john/Projects/./confgit $argv ^ in function 'confgit' ...
I worked to reproduce your problem, and the closest thing I could emulate was this: # file: ~/bin/janstest echo $argv # file: ~/bin/janstest2 function janstest ~/bin/janstest $argv end janstest It works! and file permissions as: stew@stewbian ~> ls -l ~/bin/jans* -rwxr-xr-x /home/stew/bin/janstest* -rwxr-xr-x /ho...
Fish: The file is not executable by this user
1,621,502,663,000
I am using the fish shell and try to log stdout and stderr into two separate files and printing them in the terminal at the same time (e.g., by piping each stream to tee). In bash I would do (see https://stackoverflow.com/a/692407/5082444): command > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2) How can I achieve ...
You can do something similar with begin; command | tee -a stdout.log ; end ^| tee -a stderr.log >&2 with the proviso that if the first tee writes anything to stderr, it will also get logged, which is not the case with the bash version.
Print and log stdout and stderr in fish shell
1,621,502,663,000
Is this even possible? I'd like to run a command but capture its stdout and stderr as separate variables. Currently I'm using set -l var (cmd), which leaves stderr untouched. I can do set -l var (cmd ^&1) which will merge stdout and stderr into var, but then I can't easily separate them again. Is there any way to get ...
begin; cmd ^|read -z err; end |read -z out From fish-shell/fish-shell #2463, An issue in your fish example is that it redirects [stdout] of both [cmd] and [read], so if the latter prints anything, it'll be carried through the pipe. But I don't think read should ever print anything (especially to stdout) in the norm...
Capture stdout and stderr as separate variables in fish shell
1,621,502,663,000
The fish shell uses many escape sequences as you type, especially if you ever make a mistake or use completion. 'script' just captures them literally, making quite a mess. More of a mess than col -b can repair. Is there some other way to record command lines and their results (other than just using an emacs shell buff...
You'll lose many of the nice features of fish - colourisation, autosuggestions, etc., but you can start script with the environment variable TERM set to dumb. This will result in a much cleaner output. script really is a dumb terminal - the manpage suggests that it is supposed to emulate an old-style hardcopy terminal...
fish + script -> chaos, what options?
1,621,502,663,000
First of all, I'm on OSX10. My default shell is BASH, which I have set up (through .profile and .bashrc) to automatically run the FISH shell when I open my terminal emulator. This allows me to set up variables etc. in BASH before I load up FISH. Sometimes, however, I want to run scripts which are written for BASH, fro...
You could set a variable in the script which starts fish to note that you're "in fish": export IN_FISH=yes Then, before that, you check whether it's already set: if [ "${IN_FISH}" != "yes" ]; then export IN_FISH=yes fish # replace with the command you use to start fish fi Thus, in your first bash, IN_FISH i...
Custom bash 'context' when running from FISH
1,621,502,663,000
In bash, you can pipe the same output to two commands using {}, i.e. in the following: cmd0 | { cmd1 ; cmd2 ;} | cmd3 cmd1 and cmd2 get the output of cmd0 in their stdin, and cmd3 gets the output of cmd2 appended to output of cmd2 in its stdin. What's the name of this {} feature and is there an equivalent in fish?
The feature is called command grouping. In the fish shell, it appears to be provided by using begin and end in place of bash's { and } braces - a feature I only discovered from a bug report: begin-end command grouping isn't discoverable/documented prominently enough #6415 Note that regardless of shell, the first com...
fish equivalent for sequence of commands -- { cmd1 ; cmd2; }
1,621,502,663,000
I've added a command to start fish terminal from bashrc and so far it was working ok. I've just added this line at the end of bashrc fish But after I quit fish to default shell current input isn't displayed anymore, although pressing enter will interpret whatever was typed. Is there any other way to start fish automa...
When you exit the fish shell session, the bash shell that was starting up but that was "put on hold" while fish was running, continues to run. For whatever reason, it leaves the terminal in a confused state (try reset or stty sane to fix that). If you always want to run the fish shell instead of bash, then it would b...
Starting Fish terminal from bashrc breaks standard terminal input
1,621,502,663,000
So, I recently downloaded a cli which shares a lot of commands similar to linux. Like mega-login : login & mega-logout :logout and I am too tired of writing mega every time I need to use the cli. I thought of using alias but I don't want to screw some other program that use the some other command I don't know of. Like...
Not a bad first (and second) attempt. It can be tricky to get it just right. How about: function m set -l mega_cmd "mega-$argv[1]" set -l mega_args $argv[2..] if type -q "$mega_cmd" echo "Executing $mega_cmd $mega_args" "$mega_cmd" $mega_args end end Of course, that's for readability ...
How do I extract variables from a list in fish?
1,621,502,663,000
I've written the following script, intended to start a daemon and display a Zenity window, then stop the daemon when the window is closed: #!/usr/bin/fish if not ps aux | grep [s]erviio > /dev/null set -x JAVA "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" ~/Programs/serviio/bin/serviio.sh & zenity --...
I found out why by redirecting the output of the ps command to a file. If I run the script from a launcher, grep finds the script itself (which has "serviio" in its name) and so it doesn't execute the code inside "if". I fixed it by making what grep looks for more specific. The main cause seems to be that if the scrip...
Why does this fish script does not run from a launcher?
1,621,502,663,000
I'm using Fish shell on Urxvt terminal. I want to map Ctrl+E as auto-completion key, what is done by pressing Right arrow key by default. I'm not sure if it's shell's or terminal's feature to do so, but it's clearly not the same as what is done by Tab, and also, I could not find myself such function name in manual of...
The binding your looking for is forward-char. Normally the → (right arrow) key and Ctrl-F are bound to it and will accept a fish's suggestion. Note that this is different from an auto-completion, corresponding to complete-and-search and bound to Tab by default. To add Ctrl-E to this list, you can do: bind \ce forwar...
Remap Ctrl+E to autocomplete file names in fish
1,621,502,663,000
I often find myself piping a command's output into less because less is far superior for studying the output than the normal terminal. While I can always append | less to every command, I was wondering if there is a more concise way of doing this requiring fewer keystrokes. One option would be to alias less allowing m...
One way is a custom key binding. Example: bind \el "commandline --insert '| less'" now pressing alt-L or option-L will insert | less at your cursor.
How to display stdout of command in `less` with as few keystrokes as possible?
1,621,502,663,000
I want to customize my fish shell using the Web UI mode, but when running fish_config colors, the following error is shown. surface@Surface ~> fish_config starting-colors Web config started at file:///tmp/web_configoafehdco.html Hit ENTER to stop. Start : This command cannot be run due to the error: The system cannot ...
After going through some articles and not finding the correct answer, I found that when running 'help' it opens the browser and points to file://wsl%24/Ubuntu-20.04/usr/share/doc/fish/index.html#variables-for-changing-highlighting-colors and when we're trying to run fish_config, it points to "file://wsl%24/Ubuntu/tmp...
Error starting the fish_config web ui in WSL
1,621,502,663,000
I use fish shell mainly from Rider IDE and iTerm2. I've noticed that every task that implies saving something for future sessions will not operate transparently between the two aforementioned contexts. More precisely if I define a universal exported variable, or an alias, they'll be preserved from the "context" where ...
The Jetbrains IDEs run fish with a specific environment in order to add their own integrations. They do this by setting $XDG_CONFIG_HOME, which is where fish finds its universal variables. This is broken in a variety of ways. See https://youtrack.jetbrains.com/issue/IDEA-169111 You might want to disable the shell inte...
fish shell: universal variables and alias not shared between "contexts"
1,621,502,663,000
I was using fish-shell when reading about kill command. The output of kill -l command for fish is HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM .... When invoking same command in bash I had 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP .... I checked kill with whereis, and ...
It can still be a shell built-in even when not documented: ~ (101) bash tom@vmw-debian7-64:~$ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 1...
Why 'kill -l' gives different output in fish and bash
1,621,502,663,000
I recently switched from bash to fish. I like it, but I don't know how to exit, when I enter history. How do I do that?
The history function will show your history in your pager program. This can changed by setting the $PAGER variable, but usually it's a program called less. And to quit that one, press q. Pressing h will show you the help screen. If it's not less or something similar (most pagers quit with q, to be honest), then it dep...
Exit 'history' in fish
1,621,502,663,000
With my fish shell, I have defined the alias alias black='command black -l 110' When I type black in my shell and start to tab-complete, I get the error complete: maximum recursion depth reached The same thing happens with similar aliases such as alias readelf='command readelf -W'
If I enter alias readelf='command readelf -W' into a fish shell, this is what fish does with it: $ type -a readelf readelf is a function with definition # Defined via `source` function readelf --wraps='command readelf -W' --description 'alias readelf=command readelf -W' command readelf -W $argv; end The --wraps ar...
fish - Maximum recursion depth reached with tab-complete
1,621,502,663,000
I have a script that prints a string to terminal, and I want to check value of myScript output.(in this case resultString) I tried with this method, but it didn't worked. (for simplicty i replaced my script with echo something so the output is 'something' in this cases. ) echo something | if test - = something ...
test and set do not understand that - means "read from standard input". Use read instead: echo something | read x if test "$x" = something echo true else echo false end
test standard output with fish
1,621,502,663,000
Basically, I'd like to create a file .cd-reminder with an announcement/message inside a specific directory. It will be displayed every time someone 'cd' into that specific directory. There is a shell script for that already and I'm currently using Fish and not familiar on how to convert it; any help appreciated! remin...
function cd builtin cd $argv and test -f .cd-reminder and cat .cd-reminder end I just realized this will return a non-success exit status when the .cd-reminder file does not exist in a directory. use this instead so the function will only return non-success if you can't cd to the given dir. function cd ...
Bash to Fish Conversion: Display custom message when CD'ing into a specific directory
1,621,502,663,000
How can I access the non-aliased version of a command from within the alias for that command? In bash, I can do something like alias ls='\ls -l' to access the non-aliased ls inside this alias for ls. How can I do this in fish? Right now I'm using env to get the executable for the command, but is there a better way? al...
For simple cases, fish's alias will figure it out itself. You can just do alias ls='ls -l' and it will result in the following function: function ls --description 'alias ls=ls -l' command ls -l $argv end because fish's alias is a cheesy wrapper that defines functions the way to call a command by name, skippin...
Fish access non-aliased command from alias
1,637,322,023,000
I can't seem to find any information on how to navigate tab completion or how to bind keys in tab completion in fish shell. This is what I am trying to achieve but in fish shell rather than zsh. Fish-like argument completion search in ZSH Please help...
The tab completion pager uses the same keys as the rest of the command-line editor, so to bind h to move in the pager (and stay as inserting h when writing a command) use: bind h 'if commandline --paging-mode; commandline --function backward-char; else; commandline --insert h; end' Similar lines can be added for j, k...
How to use hjkl to navigate menu select in fish shell
1,637,322,023,000
I installed Garuda Linux today. The default shell emulator is Alacritty and the default shell, fish. However, after the update to the system, its constantly giving a warning: Config error: shell: data did not match any variant of untagged enum Program What is this error and what is causing it?
This seems to be a bug in the latest update of alacritty. The issue is still unknown as of today (1st Jan 2021). However, to fix the problem, you simply have to roll-back the alacritty config file located at ~/.config/alacritty/alacritty.yml.
Error in terminal emulator: Alacritty
1,637,322,023,000
I have some video files in source/ to encode and I want the output to be saved in the local directory, therefore removing source/ in the filename. I accomplished this by using the following command in fish shell: $ for file in source/*.mkv ffmpeg -i "$file" -c:v copy -c:a copy (echo "$file" | sed -e "s/source\//...
You're removing a (fixed) directory name from the string here. In standard shell, you can do that with the ${parameter#pattern} expansion, it removes pattern from the start of the string in parameter, so ${file#source/} would remove the prefix source/. Also in ksh/Bash/zsh ${parameter/pattern} removes the match anywh...
Processing local variable with regular expressions
1,637,322,023,000
I installed debian stretch yesterday. I installed fish shell . I change the default shell to fish by the following su chsh -s 'which fish' Then again enter the this command su chsh -s `which fish` Now after I restart the PC I encountered the following error while using "su" sathish@localhost ~> su Password: Cannot ...
(Since I'm unable to comment. So posting here) Change user to su $ su (Then enter password) Type # chsh [username] In your case: # chsh root Enter login shell /usr/bin/fish That's it. Logout and login again. Should work
debian 9 terminal cannot change to su
1,637,322,023,000
I'm trying to understand why the gradle completion isn't applying. Since gw seems to be a keyword for the completion, I created an alias: alias gw='./gradlew' (My project uses gradle wrapper. I don't have gradle installed globally.) When I type gw <tab> it just does the standard file system completion. I'm expectin...
Instead of an alias, use a function, and declare that it wraps gradle function gw --wraps gradlew ./gradlew $argv end See https://fishshell.com/docs/current/cmds/function.html
Completion for gradle not applying
1,637,322,023,000
i'm trying to set an environment variable EDITOR and change it from default which is /usr/bin/nano but i can't use set -Ux due to this behavior fish FAQ How to find out which setting fish inherits from? (so i can change it) Edit: /etc/environment is empty set -S EDITOR $EDITOR: set in global scope, exported, with 1 el...
In fish, since version 3.6.0, you can ask set --show variable and it will tell you what value fish originally inherited. For example: > set --show foo $foo: set in global scope, exported, with 1 elements $foo[1]: |banana| $foo: originally inherited as |bar| This will help you figure out if the value was what fish alr...
where a variable inherit from, Fishshell
1,637,322,023,000
I'm studying the RBENV codebase, and I see that on line 116 of the rbenv-init file, a function is created which contains a switch statement. My hypothesis is that we check whether the value of the command variable is one of the members of the array of values in the commands (plural) variable. If it is, we execute br...
The bash code in there is: commands=(`rbenv-commands --sh`) That's split+glob applied to the output of rbenv-commands --sh and the resulting words assigned to elements of the $commands bash array case "$shell" in fish ) cat <<EOS function rbenv set command \$argv[1] set -e argv[1] switch "\$command" case...
Fish shell - syntax for creating a switch statement which checks against an array of values
1,637,322,023,000
I have a few abbreviations that I want to run on one command. Let's say given this config: abbr command1 "echo 1" abbr command2 "echo 2" abbr command3 "echo 3" I want another abbr that runs all of them together: abbr allCommands "command1; command2; command3" But I get fish: Unknown command: command1 How could I r...
Fish abbreviations are expanded only at the commandline when pressing Space or Enter. It sounds like you want an alias. Just replace abbr with alias in each of your commands above, and it should work as you expect.
fish - Run multiple abbreviations with another abbreviation
1,637,322,023,000
I'm working on a completion script for a command, and I'm stuck. The docs and various websites I find don't fit what I need. The main command is pacstall and it has the flags: -I -S -R -C -U -V -L -Up -Qd -Qi. For most of the flags, I need the completions to be the output of a command (if I ran pacstall -I, then tabbe...
The -n flag of the complete command allows you to specify a condition for the completion to occur. In this case, you can use the __fish_seen_subcommand_from function to specify whether the subcommand -I has been seen already. After this, you can specify with the -a flag the command you want to run in (). complete -f -...
Fish completion script
1,637,322,023,000
Trying fish, I am stuck on equivalents for some of the variable expansions from bash: x=${this:-$that} x=${this:-that} How do I do that in fish?
Nothing so short as that posix shell variable expansion: if set -q this; or test -z $this set x $that else set x $this end or the "terse" version begin; set -q this; or test -z $this; end; and set x $that; or set x $this (I'll be happy to be proven wrong about this one)
fish equivalent of ${this:-that} expansion and similar
1,637,322,023,000
In bash I can do: foo() { echo bar; } export -f foo perl -e 'system "bash -c foo"' I can also access the function definition: perl -e 'print "foo".$ENV{"BASH_FUNC_foo%%"}' How do I do the same in fish? Edit: With this I can get the function definition: functions -n | perl -pe 's/,/\n/g' | while read d; functions $d;...
Ugly as hell, but works: function foo echo bar; end setenv funcdefs (functions -n | perl -pe 's/,/\n/g' | while read d; functions $d; end|perl -pe 's/\n/\001/') perl -e '$ENV{"funcdefs"}=~s/\001/\n/g;system ("fish", "-c", $ENV{funcdefs}."foo")'
Accessing fish functions from perl
1,637,322,023,000
At work we use the Environment Modules package (and hence modulecmd) extensively. man module includes the sentence “The sh, csh, tcsh, bash, ksh, and zsh shells are supported by modulecmd.” This is confirmed by hgs15624@pc0072 /d/w/c/m/m/mml> modulecmd fish load matlab init.c(379):ERROR:109: Unknown shell type 'fish'...
It looks like Modules needs to be extended to support fish; none of the existing shells are close enough to easily apply to fish.
Can I use modulecmd with fish shell?
1,637,322,023,000
In bash you would do touch "foo bar" rm "$(echo foo bar)" How would you do that in fish? This doesn't work for obvious reasons: touch "foo bar" rm "(echo foo bar)"
Seems that without the quotes produces the desired output: touch "foo bar" rm (echo foo bar) A test: echo "foo bar" > foo touch "foo bar" rm (cat foo)
Quoting command substituted value
1,637,322,023,000
I would like to use systemd to accomplish this if possible. This is what I have done so far. Wrote a script in fish that will stage, commit and push files to a repository. Script made executable with chmod u+x <script>.fish. Wrote a service unit. Reloaded with systemctl --user daemon-reload, enabled with systemctl --...
TL;DR, try this simplified version: [Unit] Description=Backup obsidian notes before shutdown After=network-online.target Wants=network-online.target [Service] Type=oneshot RemainAfterExit=yes ExecStop=fish /home/yjh/scripts/backup.fish [Install] WantedBy=default.target Running this as a user service, my test script...
Unable to run git commands before shutdown
1,637,322,023,000
I'm using complete -c cl -o editz -f -xa '(cl -autocomplete 15 | sed "s/:/\\t/" | sed -r "s/^(.{60}).*/\1/")' to dynamically feed the latest 15 entires in a log program to fish for tab-completion. It works very well but I'd like to style how fish presents them. I'd like to avoid the two columns and left-align the desc...
I'd like to avoid the two columns and left-align the description text. Neither of these are configurable in fish. I assume there is a function that defines how complete -xa handles the incoming list. There isn't a script function that defines how this is handled. It's all hard-coded in C++. Should be in https://gi...
Where is the default fish completion style defined or how do I style the fish completion options listing?
1,637,322,023,000
If I try to get the output (stdout) of a python program into a variable I do this: set zpath (python something.py "$argv") But if the program spawns a curses interface, it won't show. The program displays a curses interface temporarily to select something, it exits the curses before the program ends. It prints someth...
I read that I can I add 2>&1 >/dev/tty to the end of the command. This redirects stdout to the terminal (and stderr to where stdout originally went - the command substitution buffer). If that shows the interface, and running it without redirections doesn't, that means the program uses stdout to display it. That mean...
Get output of a command that uses curses
1,637,322,023,000
So I am running terminator 0.98. I like fish shell but for some task it is handy to have bash (like for virtualenvwrapper). So I now have two windows that open when I start terminator. But I would like to have one that opens with fish and one with bash. Is this possible, if so: how? I start terminator with my custom ...
You need to add a command to the relevant pane. If your default shell is bash, just have one pane run fish: [layouts] [[default]] [[[child0]]] fullscreen = False last_active_window = True maximised = True order = 0 parent = "" size = 1280, 985 type = Window [[[child...
Can I open terminator with one windows with bash and another with fish? [duplicate]
1,637,322,023,000
I am using fish as shell, ssh shortcut function as following: function sshec2 ssh -i $HOME/.ssh/key.pem -t -t "ubuntu@$argv[1]" end To ssh into specific AWS EC2 instance, I wrote command pipe flow: ec2-describe-instances --region us-west-2 --filter "tag:Name=test-box" | grep 'INSTANCE' | grep -E -m 1 -o '[0-9]{1,3}...
If I understand correctly, you have a pipeline that generates a list of host names (ec2-describe-instances … | grep … | grep …), you take the first line (head -1), and you want to use that as the host name to connect to. You're passing the host name on the standard input of the sshec2 function and calling the function...
Scripting SSH function getting `Connection refused` error
1,637,322,023,000
Before switching to fish shell, I frequently used various commands in zsh with which some_command. An example might be: $ file `which zsh` /opt/local/bin/zsh: Mach-O 64-bit executable arm64 /bin/zsh: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64 - Mach-O 64-bit executa...
fish does not use backticks for command substitutions. Instead one can use parens: file (which zsh) or (in release 3.4.0 and later) file $(which zsh). These mean the same thing. Check out fish for bash users for other differences.
fish shell: why does `file `which command`` work in zsh and bash, but not fish?
1,637,322,023,000
I have a bunch of dotfiles that allow me to have a pretty theme on my terminal and tmux on my local host. I use kitty, fish and tmux. To properly define colors and have a global coherence, I use the following files : .Xresoures kitty.conf fish_prompt.fish .tmux.conf On my local host, everything looks really clean : ...
Managed to fix it! It was a combination of all the answers given, with one important extra variable. Required steps : Ensuring the TERM variables used are the same on every host and inside every tmux (I ended up using xterm-kitty on the hosts directly and tlux-256color inside the TMUX sessions). Thanks to Nicholas Ma...
TMUX and terminal colors are not the same locally and over ssh
1,637,322,023,000
Following on from my previous question I tried to run ls -l; and grep html; which did what I wanted however the command didn't exit back to the prompt. Instead it appeared to be waiting for something else to happen and I had to Ctrl+C to end the process. Can anyone explain why this happened and what the correct syntax...
You probably wanted to pipe ls -l into grep, for which fish uses a pipe character the same as other shells (for once): ls -l | grep html This is the same thing you would have written in Bash. Otherwise, grep is filtering your input from the terminal instead.
Why does the command not exit smoothly?
1,637,322,023,000
I have a bash script which cats a heredoc string, and I'm running it inside a fish shell and then piping it to a source call, like so: ~/foo/baz: 1 #!/usr/bin/env bash 2 3 cat << EOS 4 function bar 5 echo 'Hello world' 6 end 7 EOS From the fish shell: richiethomas@richie ~/foo (master) [126]> ....
Variables ($myVar) get expanded in heredocs, unless you quote it: cat << 'EOS' # .....^...^ Ref 3.6.6 Here Documents
Fish shell - what's wrong with this syntax?
1,637,322,023,000
When I start fish, it prints: Welcome to fish, the friendly interactive shell Type `help` for instructions on how to use fish And then the prompt. I've actually used fish for a while so I don't need this welcome message. How can I disable it?
this has already been answered here but tldr youll want to use the command set -U fish_greeting "" you can customise the welcome prompt too by typing what you want in the double quotes e.g set -U fish_greeting "üêü"
Fish shell: How to disable help message?
1,637,322,023,000
as above. basically I want to implement something like if not match then do these things else do these other things fi Thanks
It depends on what you mean by match, but if you mean "exactly match", you can use the string match builtin with a plain argument. if not string match --quiet -- "some_string" $some_argument echo no match else echo match end To match within a string, you can use a glob in some_string, or a regular expression ...
Fish 3.3.1 shell: how do I negate the results of a string match?
1,637,322,023,000
I am currently trying to install fish on a new CentOS 7 machine. Followed the very straightforward guide which was: cd /etc/yum.repos.d/ wget https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo yum install fish But when I run yum install fish I get the output: No pac...
I would suggest you install fish from the EPEL repository for CentOS/Redhat instead. sudo yum install epel-release Then if you try sudo yum list fish you should see it. I know this isn't the answer to what you're asking, but I think it's the way to do what you're trying to accomplish.
Yum not finding packages from added repo [CentOS 7]
1,637,322,023,000
I have 3 files Original.js Original.vue Original.css How can I easily copy them to Copy.js Copy.vue Copy.css Until now, i always just copied one by one, but if I could use something like copy Original.* Copy.*, that would be awesome. I use the fish shell, if that changes anything.
Using string replace for file in Original.* cp $file (string replace Original Copy $file) end
Copy files with different extensions to different basename with same extensions