by sandreas · 5y ago · 0 comments
function ..() {
for i in $(seq 1 $1); do cd ..; done
}
which enables .. # up 1 dir
.. 2 # up 2 dirs
.. 42 # up 42 dirs
Here are some more: https://pilabor.com/blog/2021/03/unix-shell-tricks/ # Expand ... to ../..
function vbe-expand-dot-to-parent-directory-path() {
case $LBUFFER in
(./..|* ./..) LBUFFER+='.' ;; # In Go: "go list ./..."
(..|*[ /=]..) LBUFFER+='/..' ;;
(*) LBUFFER+='.' ;;
esac
}
zle -N vbe-expand-dot-to-parent-directory-path
bindkey "." vbe-expand-dot-to-parent-directory-path
bindkey -M isearch "." self-insert function ..() {
cd $(printf '../%.0s' $(seq 1 $1))
}If you are on
/home/user/projects/app/src/handlers/
and you want to go to `app/`, you'll do: > up src
Or give name of any other child folder/file of `app/`. So if `.git` exists in `app/`, > up .git
would work too.I made it for Fish shell: https://gist.github.com/ajitid/81a4993be410586c038f8b3fc140b...