Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
learnbyexample ( learnbyexample@programming.dev )  to Linux@lemmy.mlEnglish · 3 years ago

Navigating around in your shell

blog.meain.io

external-link
message-square
10
link
fedilink
43
external-link

Navigating around in your shell

blog.meain.io

learnbyexample ( learnbyexample@programming.dev )  to Linux@lemmy.mlEnglish · 3 years ago
message-square
10
link
fedilink
alert-triangle
You must log in or # to comment.
  • Executive Chimp ( executivechimp@discuss.tchncs.de ) 
    link
    fedilink
    arrow-up
    8
    ·
    3 years ago

    Good article. Rather than aliasing `cd …/…" etc. I’ve got this function in my setup:

    up () {
    	local x='' 
    	for i in $(seq ${1:-1})
    	do
    		x="$x../" 
    	done
    	cd $x
    }
    

    This lets me do up 4 to go up 4 directories.

    • Astaroth ( Astaroth@lemm.ee ) 
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      I use Fish and have keybinds for previous and next directory, 99% of the time when going up in a directory it’s to (one of) the previous directory/ies I was in

    • PlexSheep ( PlexSheep@feddit.de ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      What I use to automatically extend stuff like ls .... to ls ../../../..

      function expand-dots() {
          local MATCH
          if [[ $LBUFFER =~ '(^| )\.\.\.+' ]]; then
              LBUFFER=$LBUFFER:fs%\.\.\.%../..%
          fi
      }
      
      function expand-dots-then-expand-or-complete() {
          zle expand-dots
          zle expand-or-complete
      }
      
      function expand-dots-then-accept-line() {
          zle expand-dots
          zle accept-line
      }
      
      zle -N expand-dots
      zle -N expand-dots-then-expand-or-complete
      zle -N expand-dots-then-accept-line
      bindkey '^I' expand-dots-then-expand-or-complete
      bindkey '^M' expand-dots-then-accept-line
      

      (for zsh)

    • Specialpatrol ( Specialpatrol@feddit.uk ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      Holy shit

    • beeng ( beeng@discuss.tchncs.de ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      Look into zoxide.

      z direc

      Will take you to the most used directory starting with “direc” eg “/home/me/random/directory”

      • Executive Chimp ( executivechimp@discuss.tchncs.de ) 
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        I’ve tried things like that before but never got on with them. I found when I had many projects with similar directory structures it was easy to end up in the wrong place and took more thought to get to the right place than just cding

        • beeng ( beeng@discuss.tchncs.de ) 
          link
          fedilink
          arrow-up
          1
          ·
          3 years ago

          The dir’s are the same names or similar? A few extra key strokes to get the fullname should be easier than cd’ing back and forth.

          There’s also z foo “space” “tab” as per docs to get interactive list for matches.

          But, just a suggestion!

  • QuazarOmega ( QuazarOmega@lemy.lol ) 
    link
    fedilink
    arrow-up
    3
    ·
    3 years ago

    Great stuff! Didn’t know about lf

  • hallettj ( hallettj@beehaw.org ) 
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    I use that r function regularly to go to the git project root. But I call it gtop. I mostly use that and zoxide to get around.

  • Mike Wooskey ( mike_wooskey@lemmy.d.thewooskeys.com ) 
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 years ago

    Thanks for these tips.

Linux@lemmy.ml

linux@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !linux@lemmy.ml

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

  • !opensource@lemmy.ml
  • !libre_culture@lemmy.ml
  • !technology@lemmy.ml
  • !libre_hardware@lemmy.ml

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 307 users / day
  • 1.04K users / week
  • 2.85K users / month
  • 6.25K users / 6 months
  • 1.31K local subscribers
  • 68K subscribers
  • 8.11K Posts
  • 108K Comments
  • Modlog
  • mods:
  • AgreeableLandscape ( AgreeableLandscape@lemmy.ml ) 
  • nooter692 ( nooter692@lemmy.ml ) 
  • MarcellusDrum ( MarcellusDrum@lemmy.ml ) 
  • Arthur Besse ( cypherpunks@lemmy.ml ) 
  • Cyclohexane ( cyclohexane@lemmy.ml ) 
  • d3Xt3r ( d3Xt3r@lemmy.nz ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code