all 21 comments

sorted by: hot top controversial new old
[–] 14 points 2 years ago (6 children)

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.

  • source
  • hideshow 12 child comments
  • [–] 4 points 2 years ago (2 children)

    Oh I really like this. I never had an alias for this since I need to do multiple backwards cds very rarely, but I might just copy this

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 2 years ago (1 child)

    Look into zoxide.

    z direc

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

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (1 child)

    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

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 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!

  • source
  • parent
  • [–] 1 point 2 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)

  • source
  • parent
  • [–] 7 points 2 years ago (1 child)

    Is there a community for people that actually know and use linux or is this just like 'programmer'humor where morons can't exit vim, use a debugger, or RTFM?

  • source
  • hideshow 2 child comments
  • [–] 3 points 2 years ago (1 child)

    How would you define "knowing" and "using" linux? Many people here don't use Linux professionally and only on the desktop, so they probably aren't too familiar with all the features of different cli programs.

    Reading a blog post is more accessible than reading a man page. I didn't know cd -, so reading the post was worth it I'd say.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (2 children)

    Reading a blog post is more accessible than reading a man page.

    I don't agree with that assessment at all. People should learn to read manpages, instead of being spoon-fed pieces of manpages in inferior form.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 2 years ago

    Any program should have a man page, even if it only lists all options. My point is that a blog post helps some people to learn about a program. For example a post often highlights the most important options of a software.

  • source
  • parent
  • manpages aren't guides though - they don't help much in learning new tools, especially complicated ones. They're comprehensive references, some can literally span hundreds of pages. Useful when you know what you're doing and what you're looking for, not great for learning new tools.

  • source
  • parent
  • [–] 3 points 2 years ago

    Great stuff! Didn't know about lf

  • source
  • [–] 3 points 2 years ago*

    Some of these tips are dangerous. You generally don't want cause insensitivity in your shell. Also, ls should never be used as a subshell to find files as a part of commands.

  • source
  • [–] 2 points 2 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.

  • source
  • Thanks for these tips.

  • source