3 ms·
Here are some of what I use: alias -- -='cd -' alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd .
by kbd 9y ago
Here are some of what I use:
alias -- -='cd -'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias l=ls
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
- msoucy 9y agoI personally have a single function that takes care of all of those dotted aliases: function up { local ups="." for((i=0;i<${1:-1};i++)); do ups="${ups}/.." done cd "$ups" }
- kbd 9y agoI appreciate the DRY-ness of it, but that requires you to type 'up ...' which is longer :( A while ago when I was bored I was thinking of golfing those aliases to say (pseudocode): for i in 2..6: alias '.'*i=cd '../'*i but I didn't know all the shell needed and just wound up leaving it as is. Edit: turns out Zsh has a 'repeat' built-in: alias $(repeat 7 echo -n '.')="cd $(repeat 7 echo -n '../')" Still, non-portable, less clear, not worth changing the aliases.
- Symbiote 9y agoI have had this in my .zshrc for years: # Quick ../../.. from https://github.com/blueyed/oh-my-zsh resolve-alias() { # Recursively resolve aliases and echo the command. typeset -a cmd cmd=(${(z)1}) while (( ${+aliases[$cmd[1]]} )) \ && [[ ${aliases[$cmd[1]]} != $cmd ]]; do cmd=(${(z)aliases[${cmd[1]}]}) done echo $cmd } rationalise-dot() { # Auto-expand "..." to "../..", "...." to "../../.." etc. # It skips certain commands (git, tig, p4). # # resolve-alias is defined in a separate function. local MATCH # keep the regex match from leaking to the environment. # Skip pasted text. if (( PENDING > 0 )); then zle self-insert return fi if [[ $LBUFFER =~ '(^|/| ||'$'\n''|\||;|&)\.\.$' ]] \ && ! [[ $(resolve-alias $LBUFFER) =~ '(git|tig|p4)' ]]; then LBUFFER+=/ zle self-insert zle self-insert else zle self-insert fi } zle -N rationalise-dot bindkey . rationalise-dot bindkey -M isearch . self-insert 2>/dev/null For doing "cd ../.." I type "cd ...", each extra "." adds a "/.." to the argument. It works for any command, cp/mv/whatever. There may be nicer versions, certainly shorter versions are there if I search "rationalise-dot" in Google.