How To Use The Shell Commands 'pushd', 'popd' and 'dirs'

Поділитися
Вставка
  • Опубліковано 11 лис 2024

КОМЕНТАРІ • 54

  • @corypollard
    @corypollard Рік тому +1

    That's an awesome command, been using linux for 20 years now and never come across it. You learn something new everyday.

  • @batboy49
    @batboy49 Рік тому +12

    Good job DT I was taught this years ago by a fellow developer, made navigating linux SO MUCH EASIER. I have found that almost nobody knows about pushd and popd. My OS does not have a man page for either one.

    • @DistroTube
      @DistroTube  Рік тому +6

      Since 'pushd' and 'popd' are shell built-ins, they may or may not be mentioned in the bash manpage. Or in the zsh manpage. If using fish, they do have a manpage for 'pushd' and 'popd.'

    • @batboy49
      @batboy49 Рік тому +1

      @@DistroTube Cool Thanks :) Makes sense. I actually just heard that they are shell build ins from your video, now I know why they may not be in the man pages with their own entry.

    • @batboy49
      @batboy49 Рік тому

      And there it is, I use zsh and it is in the man page zshbuiltins, thanks again DT.

    • @MH_VOID
      @MH_VOID Рік тому +1

      For ZSH, Check `man zshbuiltins` for a humongous manpage going over pretty much every ZSH built-in command a user would invoke interactively directly (other manpages like `man zshzle` and `man zshmodules` exist for other stuff).

    • @maxdeusphallus8974
      @maxdeusphallus8974 Рік тому +1

      I have been using popd/pushd for years. Maybe a decade. It is IMHO one of the most neglected shell commands. It really works with the worklow of doing most things on Linux.

  • @kdemetter
    @kdemetter Рік тому

    I've used pushd and popd for years, but I didn't know about dirs. Thanks, learned something

  • @carlosalbertoperalta1080
    @carlosalbertoperalta1080 Рік тому +3

    I wish I knew this waaaaaaay before, Thank You DT

  • @dendipradigta8504
    @dendipradigta8504 Рік тому +3

    more tricks like this please.

  • @ashisharya65
    @ashisharya65 10 місяців тому

    Your command prompt looks fantastic.
    Could you please share any details of how to configure mine in a similar way.

  • @edg3one
    @edg3one Рік тому +1

    wow that worked in powershell somehow!!!! but only as an alias not all the fancy stuff

  • @Rbourk252
    @Rbourk252 Рік тому

    Thanks DT another cooel post.

  • @luciengrondin5802
    @luciengrondin5802 Рік тому +3

    It's a directory stack but the directories are not static. You can still change directories, with cd, without altering the stack. So it would be more accurate to say it's a stack of *working* directories.
    Also it's a stack so it should be used as such: you typically don't need to jump deep in the stack.
    That mechanism is useful when you need to work somewhere else in the filesystem before resuming your work. If you do that recursively the stack gives you an intuitive way to track what you're doing. It's often more convenient than opening a new shell every time because if you do that you can forget the hierarchical structure of your work. With a stack, it's obvious.
    Like say you want to compile a program A and you realize it depends on B. You push a directory where to extract B's source code. You compile it, which may require you to cd into its build directory or something. Then you realize B depends on C. So you push an other directory and so on. Each time you finally manage to 'make install' you pop the directory stack and you keep going.

  • @WinterBase
    @WinterBase Рік тому +1

    Great video, learned new things. Can someone tell me which terminal application DT uses here? And how can I make my terminal look so nice?

    • @CrowsofAcheron
      @CrowsofAcheron Рік тому +1

      I believe he's using the alacritty terminal with the qtile window manager.

  • @Voshchronos
    @Voshchronos Рік тому +2

    Now that's hella interesting! Thanks

  • @aayushbajaj2260
    @aayushbajaj2260 Рік тому +1

    this is awesome content!

  • @batboy49
    @batboy49 Рік тому +1

    I checked out fish my problem with it is I do a lot of yocto and buildroot. Fish does not play nice there and it becomes a productivity problem. Zsh really fills everything I like about fish without being difficult to use for things I am constantly using in my workflow.

  • @chrissaltmarsh6777
    @chrissaltmarsh6777 Рік тому +1

    FYI it's the same in tcsh as well. ALthough I hardly use it; I'm mostly in vim so navigating is in there.

  • @overlandkltolondon
    @overlandkltolondon Рік тому

    I've been using Unix for 30+ years. How did I not know of this?

  • @theodorealenas3171
    @theodorealenas3171 Рік тому

    My body wants to refuse this, but I'm afraid it will win in the end.

  • @bubeshmohan6322
    @bubeshmohan6322 Рік тому +1

    Can anyone recommend any guide for beginners to learn about shell command

    • @micaelviana
      @micaelviana Рік тому +1

      This channel has two playlists about that, one is **Shell Scripting** and the other is **The Command Line**. I can't post the links because you will delete them anyway.

  • @AlexDBall
    @AlexDBall Рік тому +1

    As a greek (cypriot) speaker, i find myself giggling like a 12 year old everytime i hear “push d”😂

  • @Starchface
    @Starchface Рік тому +4

    I could see those being useful in scripting, but for the interactive shell I'll stick to cd. Bash has the "-" argument to go to the previous directory. Between -, .. and tab completion, they do what I need. I am a simple man.

    • @DistroTube
      @DistroTube  Рік тому

      > Bash has the "-" argument to go to the previous directory.
      While 'cd -' is neat and I use it all the time, it just changes to the last directory (not necessarily the previous in the stack). So if you 'cd -' repeatedly, you just go between your current directory and the last one. 'prevd' and 'nextd' keep going through the directory history.

    • @Starchface
      @Starchface Рік тому

      @@DistroTube Yes, whichever directory you were in last. What can I say? I'm a simple guy with simple needs. The fish "arrow traversal" feature looks great though. No need to think or count with that. It's like they were thinking of me.

  • @derrekvanee4567
    @derrekvanee4567 Рік тому

    Jeebes I've just learned df for btrfs free space when lsblk doesn't like root space left and here's a few more. Linux has so much goodies you'll never stop learning. Finally mares new user and ran the dtos script, really like it but no keybindings like arco does meta+f1-12 or am I wrong?

    • @BarafuAlbino
      @BarafuAlbino Рік тому

      For Btrfs, don't use `df` from the system, use `btrfs filesystem usage`. Normal tools don't understand CoW, and can easily show you more than 100% disk usage.

  • @aliencreation8744
    @aliencreation8744 11 місяців тому

    fish

  • @damadorpl
    @damadorpl Рік тому

    Array stacking at bash ;)

  • @MerkDolf
    @MerkDolf Рік тому +1

    😀 👌 👍

  • @danielcendales1984
    @danielcendales1984 Рік тому

    The first time I saw somebody explaining this commands (pushd and popd) on UA-cam was in the channel "Joe Collins". He's back. The video about partitioning USB's was great. Maybe you can do something in the terminal but deeper (sorry, I don't speak english well :'v)

  • @sotecluxan4221
    @sotecluxan4221 Рік тому

    Havoc!

  • @reachsancho
    @reachsancho Рік тому +1

    Is it just me or does everyone notices DT pulling his nose time and again. LOL.

  • @bufordghoons9981
    @bufordghoons9981 Рік тому

    Interesting but in my case, largely unnecessary, perhaps in a customized shell script

  • @itsfish8672
    @itsfish8672 Рік тому +1

    GVDT

  • @max_ishere
    @max_ishere Рік тому

    👀 this exists?

  • @ditchcomfort
    @ditchcomfort Рік тому

    Fish is so stupid..!

  • @bigmikeobama5314
    @bigmikeobama5314 Рік тому +2

    FIRST!

  • @washedmyhair
    @washedmyhair Рік тому +1

    wow first???????

  • @baxlash81
    @baxlash81 Рік тому

    "/usr" does not mean user. It means Unix System Resources and therefore it is incorrect to pronouce it as user.

    • @crash1985
      @crash1985 Рік тому +1

      I did some research if this is really the case, since I've also heard this before. It looks like that that acronym was invented long after /usr first appeared. It looks like decades ago on Sun workstations it was really meant to be a short for "user". Later after it's original purpose change a bit, people start calling it "Unix System Resources". So I would say both is correct.
      Fun fact its that Debian (haven't checked other distros) and the Unix Filesystem Hierarchy Standard are calling /usr "second major section of the filesytem, /usr is sharable, read-only data". So no acronym at all, so it could also mean u=user s=shared r=readonly :D
      I've also checked my Linux book from 1996 and they say its "everything related to the user".

    • @crash1985
      @crash1985 Рік тому +1

      Haha and that old book also says that /usr were /home on old Unix system, which iirc was really the case.

  • @wisnoskij
    @wisnoskij Рік тому

    "no way to supress the output" `pushd /usr/share/themes > /dev/null` You can "Alias" this with a bash function.