fish

What's the equivalent to ${var:-defaultvalue} in fish?

天涯浪子 提交于 2021-01-29 17:26:05
问题 Hello I am trying to translate my .bashrc to fish format almost done, mostly is clear on the documentation but this part is giving me a headache.. is so my gnupg works with my yubikey ssh etc etc.. The fish version is latest 3.0 under Arch GNU/Linux original on BASH: # Set SSH to use gpg-agent unset SSH_AGENT_PID if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh" fi echo "UPDATESTARTUPTTY" | gpg-connect-agent > /dev/null 2&>1 Mine

How can I fix Edit cancelled, no changes made in shell

落花浮王杯 提交于 2020-12-08 06:28:05
问题 I run kubectl edit deployment to change the version of one of my pods (this commands opens a temp file in my text editor and then I usually edit and close this temp file) and even before I close this temp file in my text editor I can see the following note in my bash. Edit cancelled, no changes made. It was OK before I installed fish and I tried to switch to bash but it doesn't help either. How can I fix it? 回答1: Things like this are most likely caused by it opening an editor that forks off

Find the depth of the current path

∥☆過路亽.° 提交于 2020-08-02 05:23:50
问题 How can I write a shell script to find the depth of the current path? Assuming I am in: /home/user/test/test1/test2/test3 It should return 6. 回答1: A simple approach in fish: count (string split / $PWD) 回答2: With shell parameter expansions, no external commands: $ var=${PWD//[!\/]} $ echo ${#var} 6 The first expansion removes all characters that are not / ; the second one prints the length of var . Explanations with details for support by POSIX shell or Bash (the links in parentheses go to the

Fish shell: Shortcut for accept and run command suggestion

走远了吗. 提交于 2020-02-25 04:18:31
问题 is it possible to create a shortcut such as "Shift+Return" to accept and run the displayed suggestion? The default key-bindings require pressing the arrow keys, which involve a movement away from the keys. 回答1: Yes, to bind (example) control-y to accept and then execute: bind \cy accept-autosuggestion execute 回答2: CTRL-f should complete the displayed suggestion, after which tapping Return will run it. 来源: https://stackoverflow.com/questions/58382012/fish-shell-shortcut-for-accept-and-run

Fish shell: Shortcut for accept and run command suggestion

浪尽此生 提交于 2020-02-25 04:16:42
问题 is it possible to create a shortcut such as "Shift+Return" to accept and run the displayed suggestion? The default key-bindings require pressing the arrow keys, which involve a movement away from the keys. 回答1: Yes, to bind (example) control-y to accept and then execute: bind \cy accept-autosuggestion execute 回答2: CTRL-f should complete the displayed suggestion, after which tapping Return will run it. 来源: https://stackoverflow.com/questions/58382012/fish-shell-shortcut-for-accept-and-run

How do I handle null_glob results in fish?

一曲冷凌霜 提交于 2020-01-24 16:40:30
问题 I have a fish function that contains the following rm statement: rm ~/path/to/dir/*.log This statement works fine if there are *.log files in that path, but fails when there are no *.log files. The error is: ~/.config/fish/functions/myfunc.fish (line 5): No matches for wildcard '~/path/to/dir/*.log'. See `help expand`. rm ~/path/to/dir/*.log ^ in function 'myfunc' called on standard input ZSH has what are called Glob Qualifiers. One of them, N , handles setting the NULL_GLOB option for the

Fish shell: test: Missing argument at index 2

佐手、 提交于 2020-01-15 09:48:11
问题 I have the following function: function is_file set file $argv[1] if test ‐f $file return 0 else return 1 end end However when calling it: is_file ~/.vimrc I get: test: Missing argument at index 2 What am I missing? 回答1: The problem is the hyphen in the line if test ‐f $file It is encoded as a Unicode hyphen U+2010, but it should be the ASCII hyphen-minus (0x2D) which is Unicode character U+002D. If I delete the hyphen and retype it myself, it works fine for me. By the way, this function

How can I reset the startup directory to my HOME in Fish?

こ雲淡風輕ζ 提交于 2020-01-14 10:20:08
问题 In my desktop manager, I have bound fish to a keyboard shortcut Ctrl + ~ . On startup, fish opens the directory /usr/lib/lightdm/lightdm . This is quite annoying, because I have no business with lightdm, and I usually work on code in my $HOME directory. How can I change the directory that fish starts in? I would like to change the startup directory simply to ~/ 回答1: I had found that the config.fish file that runs at startup had been changing my default working directory. A misguided attempt