$ echo a/b/c | cut -d / -f 2-
b/c$ head -1 README.md | cut -d ' ' -f 2-
Remove one directory level of path string in shell script$ if string match -rq 'vim?' $EDITOR
echo vi or vim
end
vi or vimCalled "index range expansion". Works on whole lines.
Since fish 3.2 the end index is optional.
$ echo (seq 3)[2..]
2 3To slice within a line, use string split ' ' first.
$ echo (echo a b c | string split ' ')[2..]
b c
rsync --archive --delete <source> <destination>
The issue arises in the following directory structure:
$ tree
.
├── dir-a
│ └── dir-b
│ └── some_file
└── dir-b
└── useless_file
3 directories, 2 files
# mv errors instead of overwriting dir-b
$ mv dir-a/dir-b/ .
mv: rename dir-a/dir-b/ to ./dir-b/: Directory not empty
# explicitly passing ./dir-b just puts the files in ./dir-b, creating a nested dir-b:
$ mv dir-a/dir-b/ ./dir-b
$ tree
.
├── dir-a
└── dir-b
├── dir-b
│ └── some_file
└── useless_file
3 directories, 2 files
/\<word\> (though starting with < is usually enough)
This is so that for example eat isn't found in create.
Tell the first that it can be followed with another using -bar:
command! -bar Terminal terminalThen create a command that uses | to run multiple commands:
command! FullscreenTerminal Terminal|:only$ tree --noreport
.
└── dir
└── some_filefuncsave -d . (from man funcsave)
$ function commit
git-add-commit (echo (cat README.md | grep '###' | tail -1 | string split ' ')[2..])
end
$ funcsave -d . commit
$ git stat
## main...origin/main
?? commit.fish⌘ shift enter
Start with #!/usr/bin/env fish
(Using zoxide as an example)
$ function arg_test
argparse d/directory= -- $argv
echo $_flag_directory
end
$ arg_test -d 3
3
n/name=means that both-nand--nameare valid. It requires a value and can be used at most once. If the flag is seen then_flag_nand_flag_namewill be set with the single mandatory value associated with the flag.
git diff --color-words
$ printf %x 10
a
$ printf %02x 15
0f
nnoremap <leader>ih :call MyFunction()<cr>