1/14/2024 0 Comments Fish shell aliasesLike other shells, a dollar sign performs variable substitution: > echo My home directory is $HOME My home directory is /home/tutorial Try hitting tab and see what fish can do! Variables Hit tab again to cycle through the possibilities.įish can also complete many commands, like git branches: > git merge pr → git merge prompt_designer > git checkout b (Branch) builtin_set_color (Branch) busted_events (Tag) If there's more than one possibility, it will list them: > ~/stuff/s (Executable, 4.8kB) ~/stuff/sources/ (Directory) Type a command once, and you can re-summon it by just typing a few letters: > r /pri → /private/ It knows about paths and options: > grep -i gnore-caseĪnd history too. Unlike other shells, stderr is redirected with a caret ^ > grep fish ~/output.txt ^ ~/errors.txt Autosuggestionsįish suggests commands as you type, and shows the suggestion to the right of the cursor, in gray. Stdin and stdout can be redirected via the familiar. You can pipe between commands with the usual vertical bar: > echo hello world | wc 1 2 12 If that directory traversal is taking a long time, you can Control - C out of it. You can include multiple wildcards: > ls l*.p* lena.png lesson.pdfĮspecially powerful is the recursive wildcard ** which searches directories recursively: > ls /var/**.log /var/log/system.log /var/run/sntp.log To list all JPEG files: > ls *.jpg lena.jpg meena.jpg santa maria.jpg Wildcardsįish supports the familiar wildcard *. These colors, and many more, can be changed by running fish_config, or by modifying variables directly. This tells you that there exists a file that starts with somefi, which is useful feedback as you type. When the command becomes valid, it is shown in a different color: > /bin/mkdirįish will underline valid file paths as you type them: > cat ~/somefi Invalid commands are colored red by default: > /bin/mkdĪ command may be invalid because it does not exist, or refers to a file that you cannot execute. You'll quickly notice that fish performs syntax highlighting as you type. > man set set - handle shell variables Synopsis. You can also ask for help with a specific command, for example, help set to open in a web browser, or man set to see it in the terminal. Run help to open help in a web browser, and man to open it in a man page. Getting Helpįish has excellent help and man pages. You can include a literal space in an argument with a backslash, or by using single or double quotes: > mkdir My\ Files > cp ~/Some\ File 'My Files' > ls "My Files" Some FileĬommands can be chained with semicolons. Spaces are separators: > echo hello world hello world Running Commandsįish runs commands like other shells: you type a command, followed by its arguments. fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure. It’s got everything you might need when working with git and save some keystrokes.Fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. I’ve found fish-git-abbr plugin to be a fantastic collection of predefined abbreviations for git usage. To me, they are superior and a clear improvement. To use the configured abbreviation, we need to type it, and either press Enter to expand and execute, or Space to only expand it, allowing us to add any arguments to the command.Ībbreviations add another touch of clarity to your own workflow. Finally, the actual command it should expand to. We use the abbr command, followed by the abbreviation we’d like to use. A separate file for abbreviations makes it easier to find the right place to configure them.īelow is the content of my file: abbr be "bundle exec"Ībbr ghb "gh browse" # Open the current repository on GitHubĪbbr ghc "hub compare" # Open the diff of the branch on GitHubĪs you can see, the syntax is similar to the alias. Any file in the ~/.config/fish/conf.d directory will be automatically loaded in a standard fish setup. We will edit the ~/.config/fish/conf.d/abbreviations.fish file. This is both useful for remembering the actual command and significant when sharing commands with others (such as in screenshots of the terminal), as they do not have to decode the aliases. One can always see the actual command behind the shorthand version. The expansion is an excellent benefit of using abbreviations. Traditionally, aliases are shown as they are typed in the shell’s history. The difference between an alias and an abbreviation is that it expands to the entire command whenever the abbreviation gets triggered. ← Home Archive Fish Shell abbreviations–what are they and how to configure them? įish Shell abbreviations are a fantastic way to configure what is commonly known as aliases for your day-to-day use. Fish Shell abbreviations–what are they and how to configure them?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |