Linux commands you NEED to know! FZF && cat

Поделиться
HTML-код
  • Опубликовано: 11 май 2024
  • X: / typecraft_dev
    Let me show you some cool ways to use FZF. fzf is an amazing tool and when used with neovim and cat, its a GREAT combo
  • НаукаНаука

Комментарии • 225

  • @amineabdz
    @amineabdz Месяц назад +401

    Please avoid using this tool at all costs, I have become so dependant on it that I no longer remember the file tree of the main project I'm working on.

    • @cesarHPM91
      @cesarHPM91 12 дней назад +2

      Felt 😂, cannot remember last time I pisted files in my projects folder

    • @harveyhans
      @harveyhans 10 дней назад

      that's what the tree command is for...

    • @oscarlove4394
      @oscarlove4394 8 дней назад

      not (yet) a linux user but i feel you, ctrl+t is how i find files and scripts in VS/VScode, and after maintaining a codebase for 3 years i to this day do not know which subfolder contains exporter.cs

  • @rantophantom3310
    @rantophantom3310 Месяц назад +338

    I used to cd around like a mad man whenever I want to move around projects, but with a simple zsh function I can just search and open any projects I want using fzf. God tier command

    • @Sir_Trollman
      @Sir_Trollman Месяц назад

      I also want to know what his ternmal is

    • @hackcraft_
      @hackcraft_ Месяц назад +5

      Try z_oxide

    • @Sir_Trollman
      @Sir_Trollman Месяц назад

      Still want to know what the terminal is

    • @GavinBogie
      @GavinBogie Месяц назад

      @@Sir_Trollmanare you asking about his ZHS theme? It’s probably PowerLevel10k.

    • @X3zbeth
      @X3zbeth Месяц назад +3

      @@Sir_Trollman zsh (z shell) probs

  • @dudududududududddududududu3899
    @dudududududududddududududu3899 24 дня назад +5

    Made my own alias variants based on this vid, super helpful thanks!
    Fuzzy - fuzzy find and open with nvim, using xargs to open the file only if one is selected (prevent nvim creating a blank file if you try to ESC out)
    SuperCD - navigate to the directory of the file selected inside the CLI.
    alias fuzzy='fzf --preview="cat {}" | xargs -r nvim'
    alias supercd='cd "$(fzf --preview="if [ -d {} ]; then ls -la {}; else cat {}; fi" | xargs -r dirname)"'

    • @rando_42
      @rando_42 18 дней назад

      I used chatGPT to help update your supercd to account for file paths with spaces in the name. I noticed it wasn't handling it correctly. Here's the full command:
      cd "$(fzf --preview="if [ -d '{}' ]; then ls -la '{}'; else bat '{}'; fi" | xargs -r -I {} dirname "{}")"
      According to chatGPT, xargs -r -I {} dirname "{}" ensures that xargs correctly handles paths with spaces.
      -I {} tells xargs to replace {} with the input, preserving spaces.
      dirname "{}" uses the replaced input in a way that handles spaces correctly.

  • @gusthomas6872
    @gusthomas6872 Месяц назад +78

    you have totally aced the art of turning boring tutorials into interesting shorts. very cool!

  • @JohnSmith-yk4zt
    @JohnSmith-yk4zt Месяц назад +20

    Jaw dropped.. cant believe I didnt know this command already. Thank you

  • @robkam643400
    @robkam643400 22 дня назад +1

    I've been using Linux since 2006, and my eyes got absolutely huge watching this video.

  • @auraSinhue
    @auraSinhue Месяц назад +12

    I love this short content, full of great examples

  • @temesgenataro9502
    @temesgenataro9502 Месяц назад +5

    Very happy to see a fellow `setxkbmap -option ctrl:nocaps` enjoyer!

  • @PalashBackup
    @PalashBackup 11 дней назад +1

    This channel is a blessing for new linux users.

  • @NateInTech
    @NateInTech Месяц назад +7

    Myy man! Thanks for sharing this just added some new commands in my arsenal of FZF.

  • @Oi-mj6dv
    @Oi-mj6dv 11 дней назад

    These tutorials are a godsent. The populace demands MOAR

  • @fn_frisbees
    @fn_frisbees Месяц назад +4

    Your content is top notch, glad I stumbled across your channel.

  • @Kyle-Jade
    @Kyle-Jade Месяц назад +4

    Thats an awesome tip! Installing fzf now

  • @jcarman
    @jcarman 18 дней назад +1

    Earned a sub just based on this alone!

  • @mixxxer
    @mixxxer Месяц назад +2

    Im slightly more interested in the sound of that sweet keyboard sound 😂

  • @dudemanperson100
    @dudemanperson100 26 дней назад

    Commenting to get more of these shorts. This would help so much with navigating project files

  • @sickcallranger2590
    @sickcallranger2590 28 дней назад

    Thank you. I’m pretty new to Linux so this makes CTF a lot easier.

  • @darlonhenrisouza8555
    @darlonhenrisouza8555 Месяц назад +9

    You can use the "bat" instead of cat, is just a super power version of cat with colors

    • @XxZeldaxXXxLinkxX
      @XxZeldaxXXxLinkxX 18 дней назад

      Then there's 'exa' which is better 'ls'. Then 'zoxide' which let's you jump around your most/recently used dirs.
      If I had to pick one, zoxide is the one I would pick out of all of them

    • @konstantink07
      @konstantink07 13 дней назад

      ​@@XxZeldaxXXxLinkxXexa is deprecated, use eza

    • @XxZeldaxXXxLinkxX
      @XxZeldaxXXxLinkxX 13 дней назад

      @@konstantink07 u right, I have it aliased to ls so I can never remember whether eza or exa was the deprecated one 😂

  • @Allysroadtorecovery
    @Allysroadtorecovery 8 часов назад

    This is a neat tool thank you for sharing

  • @ianlondon2888
    @ianlondon2888 23 дня назад

    Dude this made more sense than the 30 min tutorial I watched.

  • @otrava88
    @otrava88 Месяц назад +9

    i use fzf-tab plugin for zsh, it provides better autocomplete

  • @sahilyadav3782
    @sahilyadav3782 Месяц назад +13

    thanks nerd

  • @devnol
    @devnol 20 дней назад

    Never heard of this before and I can never remember the syntax of regular find. Learn something new every day I guess.

  •  4 дня назад

    You can also pipe other outputs through fzf, like git commands. I have “git cof”, which gives me a fuzzy search for branch names, and then checks out that branch . Also “cofr”, which fetches remote first and then lets me fuzzy search that for branch names 🤩

  • @jordsRSAint
    @jordsRSAint Месяц назад +1

    This one is a banger!

  • @rbgtk
    @rbgtk 4 дня назад +1

    Can I upvote this more than once?

  • @DougiePeart
    @DougiePeart Месяц назад +1

    My man, this is a great tip!

  • @aeebeecee3737
    @aeebeecee3737 27 дней назад

    linux ecosystem always full of amazing new free stuff

  • @mrjed
    @mrjed Месяц назад +2

    this is a super big hell ya moment

  • @pablogeovany8961
    @pablogeovany8961 2 дня назад

    This is really cool! Although, one tiny "problem" I found with this is that, if you don't find the file you're looking for and exit with control+c or esc, the vim command runs anyway and it puts you on an empty file.
    I wrote a small bash script to solve that:
    #!/bin/bash
    FILE=$(fzf --preview='cat {}')
    # Check if fzf exited successfully and if the file exists
    if [ $? -eq 0 ] && [ -n "$FILE" ]
    then
    vim "$FILE"
    fi

  • @ytfeelslikenorthkorea
    @ytfeelslikenorthkorea Месяц назад

    that's nerdy :) loving it!

  • @chrsolr
    @chrsolr Месяц назад

    I had a friend do this for me about 4 years before I used nvim. Now I use it all the time

  • @hlubradio2318
    @hlubradio2318 14 дней назад

    Nice never heard of it before

  • @444limm
    @444limm Месяц назад

    I made a wrapper around fd + fzf to navigate through my files xor my directories. It's really an amazing tool.

  • @up2tech
    @up2tech Месяц назад

    Good God, you’re my hero 😮

  • @trizedlyza
    @trizedlyza 28 дней назад

    here I am building an index in /tmp using find, then egrep'ing through it like a caveman on my ancient boxes

  • @enkiimuto1041
    @enkiimuto1041 16 дней назад

    this is great

  • @knifefest
    @knifefest 22 дня назад

    At least with Fish shell, ctrl-w will immediately open fzf and stick the path where your cursor is. It'll also accept a prefix if your cursor is on a space-delimited word, cutting down the search space.

  • @MosesMinja
    @MosesMinja Месяц назад +1

    I think Telescope's fuzzy search is much more convenient when trying to search and open files

  • @pcfreak1992
    @pcfreak1992 Месяц назад +2

    Cool but if you cancel fzf neovim still opens. You could fix this by piping fzf’s output into xargs -r … instead.

  • @core36
    @core36 Месяц назад +3

    that *IS* cool

  • @titoriano1
    @titoriano1 13 дней назад

    Add the cli completions with the eval command in your zshrc

  • @d2d2505
    @d2d2505 11 дней назад

    mind blown

  • @makkusaiko
    @makkusaiko 15 дней назад

    Better than windows search

  • @willstikken5619
    @willstikken5619 25 дней назад

    You know someone has drunk all the koolaide when they use any vim variant.

  • @VictorZamanian
    @VictorZamanian 14 дней назад

    The problem with doing `nvim $(fzf)` is that if you cancel the search/kill fzf, nvim still opens. I would use `fzf --bind "enter:become($EDITOR {})"` instead. 👍 That opens the editor only if you press enter on a file.

  • @AutisticOverflow
    @AutisticOverflow Месяц назад +1

    Thanks bro, also, nice mustache

  • @SamFigueroa
    @SamFigueroa Месяц назад

    It’s so underrated

  • @PikaRyan
    @PikaRyan Месяц назад +5

    Is the bar with your username and time from the shell or the terminal emulator? That looks real nice.

    • @poetranoegraha6641
      @poetranoegraha6641 Месяц назад +1

      you could try zsh with omz for that

    • @PikaRyan
      @PikaRyan Месяц назад

      @@poetranoegraha6641 thank you!

    • @Swagseneyer
      @Swagseneyer 15 дней назад

      Is there a Theme for it or is it customized?

    • @poetranoegraha6641
      @poetranoegraha6641 13 дней назад

      @@Swagseneyer there's a theme for it, but you could try to customize it as well

  • @oglothenerd
    @oglothenerd 20 дней назад +1

    I ran FZF in my home directory in a video on RUclips, and people found my... uh... secret folders...

  • @blakejohnson4004
    @blakejohnson4004 22 дня назад

    neovim's telescope plugin does this for you also

  • @cdspiele
    @cdspiele 7 дней назад

    so finally a "search everything", but not for windows and dependant on NTFS journal?
    🥰

  • @tylergamingofficial182
    @tylergamingofficial182 27 дней назад

    What terminal is that? It looks VERY beautiful!

  • @mohamedabdul633
    @mohamedabdul633 28 дней назад

    What is your keyboard brand, and what keys do you use?

  • @ArchaicCreationsbp
    @ArchaicCreationsbp Месяц назад +1

    Hi typecraft! Are you using a topre keyboard?

  • @oldcmputer
    @oldcmputer Месяц назад

    What keyboard are you using in this video?

  • @TheDyingPlant
    @TheDyingPlant Месяц назад +5

    can you then save that command to a keyboard shortcut somehow?

    • @VOID_4487
      @VOID_4487 Месяц назад +5

      Nano ~/.bashrc
      Save this line of code to it then :
      alias bashedit="nvim $(fzf --preview='cat {}')"
      Press Ctrl + O to write buffer
      Enter to save
      And Ctrl + X to quit nano
      Then update terminal configuration by source ~/.bashrc
      Then you could also recheck if your bashrc is modified successfully by using
      cat ~/.bashrc
      If setup properly , you should also consider restarting your terminal and a new command would be added named bashedit , you can ofcourse make more commands sets off this etc.

    • @coaql
      @coaql Месяц назад

      ​@@VOID_4487!nano🙅, vim🤙

  • @pietraderdetective8953
    @pietraderdetective8953 Месяц назад +3

    nice, i made it a custom function so I can just type fzfnv to trigger the command. Cheers nerds!

    • @flowingcode8069
      @flowingcode8069 Месяц назад

      How?

    • @pietraderdetective8953
      @pietraderdetective8953 Месяц назад

      @@flowingcode8069 add this to your zshrc or bashrc:
      fzfnv() {
      nvim $(fzf --preview='cat {}')
      }

    • @muhwyndham
      @muhwyndham Месяц назад

      @@flowingcode8069 if you're on mac you can edit (or create) ~/.zshrc to create custom bash / zsh command.
      if you're on ubuntu derivatives it usually ~/.bashrc or ~/.bash_profile

  • @SeeJayPlayGames
    @SeeJayPlayGames 26 дней назад

    subscribed

  • @TheJoYo
    @TheJoYo 26 дней назад

    broot is pretty cool too, content search.

  • @MoneyGrab
    @MoneyGrab 29 дней назад

    What's your ZSH theme? I like it

  • @florinpandele5205
    @florinpandele5205 Месяц назад

    Or use windows and you no longer need to remember exactly and to the letter command lines and switches. Right-click open and search the opened folder. From ui, in an intuitive and easy to remember way.
    And it works on system folders as well FROM THE GUI.

    • @sickcallranger2590
      @sickcallranger2590 28 дней назад

      But you’re trading away fine controls and granularity while taking on a shit ton of bloatware. Windows is a fantastic generalist OS for everyday casual computer users. The people who this is meant for are generally not that and are probably very comfortable with running a CLI.

  • @chess_ramone
    @chess_ramone Месяц назад +3

    why are you 'losing' files on your system?

    • @markarkron8443
      @markarkron8443 Месяц назад

      I suppose it helps devops when they configurate servers

    • @NergusFlame
      @NergusFlame Месяц назад +1

      trust me, when you're working on large codebases or with multiple machines, stuff like this can be very useful

  • @rodypar317
    @rodypar317 Месяц назад

    Omg thanks

  • @alexbezdicek
    @alexbezdicek 6 дней назад

    More commands like these pleease

  • @KevinNitro
    @KevinNitro Месяц назад +1

    Hi my nerd lord ❤ Do you use i3 or sth else like,.. Hyprland?

  • @TS-po3fg
    @TS-po3fg 29 дней назад

    What are some good beginner projects for someone who just got into bash and only knows the basics?

  • @user-ti9mv9hb3g
    @user-ti9mv9hb3g Месяц назад +2

    Thanks nerd, nice tool! How I can install fzf, any docs or guides?

    • @Ziggurat1
      @Ziggurat1 Месяц назад +4

      sudo pacman -Suy fzf

    • @user-ti9mv9hb3g
      @user-ti9mv9hb3g Месяц назад +1

      @@Ziggurat1 thank you, on Ubuntu should be same way I guess

  • @SamSepiol127
    @SamSepiol127 Месяц назад

    Maybe someone can find this useful: in order to have constant fzf preview without having to type that every time, I added this in the .bashrc ` export FZF_DEFAULT_OPTS="--preview 'batcat --color=always {}'" `. So everytime you open fzf you have your nice preview by default

  • @diynevala
    @diynevala 12 дней назад

    whenever I eat something I should have, I think about vi and vim related programs. it is like when cats eat house plants.

  • @jeffreyepiscopo
    @jeffreyepiscopo 26 дней назад

    How’d you get that colored bit with the time there 👀

  • @paultapping9510
    @paultapping9510 Месяц назад

    How have you dropped your command line below the status line?

  • @Link-channel
    @Link-channel Месяц назад

    Now put it in a while loop, and if it's a directory, cd into it 🤓 it works!

  • @jacobcohen6379
    @jacobcohen6379 Месяц назад +1

    Does anyone know what PS1 variable that is? Or is it not even bash?

  • @Sama_09
    @Sama_09 Месяц назад

    What command prompt are you using

  • @sandworm9528
    @sandworm9528 27 дней назад

    There was a comment that suggested using windows instead.
    I reported it for promoting terrorism

  • @roideus
    @roideus 29 дней назад +1

    What's your keyboard?

  • @chotabomjvonychi3485
    @chotabomjvonychi3485 26 дней назад

    I've made some aliases that cd or edit the file that I'm searching for. I called them fcd and fed for home directory and FED/FCD for root directory

  • @felipoto
    @felipoto 20 дней назад

    comment for the Algo

  • @wizardadmin
    @wizardadmin 4 дня назад

    what if I want entries of my bash history to not suddenly disappear?

  • @Maclah
    @Maclah 15 часов назад

    What OS terminal makes it look like that?

  • @alexandergollihar3215
    @alexandergollihar3215 Месяц назад +1

    Just subbed. This is cool

  • @Herbus2142
    @Herbus2142 29 дней назад +1

    What is your keyboard/key switch

    • @typecraft_dev
      @typecraft_dev  29 дней назад

      Happy hacking keyboard (topre switches)

  • @spottedmahn
    @spottedmahn 21 день назад

    Regarding neovim, I thought piping was the SOP in Unix? Shouldn’t it be fzf blah | neovim 🤔

  • @Viken43
    @Viken43 Месяц назад +13

    Jeez make it an alias 😊

    • @typecraft_dev
      @typecraft_dev  Месяц назад +6

      Of course!!! I’m just showing off what you’d put in the alias :)

    • @Viken43
      @Viken43 Месяц назад +1

      @@typecraft_dev❤

  • @jonnyspeed8974
    @jonnyspeed8974 16 дней назад

    literal, 100% literally, literal. wow. literally.

  • @AnxulJyoti
    @AnxulJyoti 29 дней назад

    Holyyyyy thanks to fkin youtube recommendation
    Insta subd

  • @LordBaileyDev
    @LordBaileyDev 16 дней назад

    i can click folder, it's right there.

  • @MatthewKennedyUK
    @MatthewKennedyUK Месяц назад

    In Sublime Text I can organise a set of repositories into a project, so I might have infrastructure, gitops, apps…
    This is useful management how can I recreate this functionality in neovim?

  • @maxwebstudio
    @maxwebstudio 26 дней назад

    When I have to write again and again slugs or project id, i like to have a slugs.txt file.
    I would 'cat' the file then pipe into fzf in order to search between each line, then pipe into clipboard.
    For me it look like this
    `cat filename | fzf | clip`
    In a complex project structure I would also use fzf to open a file inside my current VSCode instance, using the -r flag.
    `code -r $(fzf)`
    😊

  • @aumbhatt5339
    @aumbhatt5339 25 дней назад

    I feel like a caveman after watching this 😮

  • @megaxlrful
    @megaxlrful 17 дней назад

    I have been using fzf all the time. I have fv in my terminal aliassed to nvim $(fzf --preview="bat {}")

  • @hlubradio2318
    @hlubradio2318 14 дней назад

    I'll scribe

  • @reflex6588
    @reflex6588 Месяц назад +2

    what about telescope?

    • @darknessraider624
      @darknessraider624 Месяц назад +1

      Yeah... thats what i was wondering

    • @cthecheese1620
      @cthecheese1620 Месяц назад +2

      @@darknessraider624 what about it? Telescope is nvim related, you were just shown how it’s done beyond nvim.

  • @erradicado
    @erradicado Месяц назад +1

    Thanks nerd 🤓

  • @jimwagner7817
    @jimwagner7817 Месяц назад +1

    Whoaaa what

  • @seandougan8593
    @seandougan8593 Месяц назад +2

    What was wrong with cat, file globbing and grep?

    • @prateekkarn9277
      @prateekkarn9277 Месяц назад

      I wanna know too so I'm leaving a comment here so I can get notification if there's an answer.

    • @colin0516
      @colin0516 Месяц назад

      @@prateekkarn9277 Answer: The clown who made this youtube short that has grossed over 100k+ hits in less than 3 days is telling you, prateek, this short is just recycled dog-water XD

  • @maudjito
    @maudjito 27 дней назад

    Why not just pipe to nvim? Works better if you interrupt fzf

  • @paladine4life
    @paladine4life 29 дней назад

    what if... i wanted to click everything?

  • @JulianAndresGuarinReyes
    @JulianAndresGuarinReyes 22 дня назад

    Telescope find_files?