4 ms·
Interesting. Faced with the choice of punishing myself for making a mistake vs. adapting my environment to accommodate me, I'll always choose the latter. (Plu
by WalterGR 9y ago
Interesting.
Faced with the choice of punishing myself for making a mistake vs. adapting my environment to accommodate me, I'll always choose the latter.
(Plus, since you use `ls` so frequently, just make `l` an alias of it, especially if you have difficulty typing "ls"! Using a computer doesn't have to be some weird, punishing, bondage and discipline experience.)
- arbie 9y agoAgree. It's why I alias . to pwd and .. to go up a directory.
- jhauris 9y agothose are great, definitely adding those aliases.
- moehm 9y agoAnd "alias ...='cd ../../'" etc. Gotta love this feature.
- kbd 9y agoHere 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.
- firethief 9y agoWhy stop there? `shopt -s autocd`
- bakul 9y agoI’ve used these aliases since I first started using csh (below syntax for zsh): alias .=cd alias ,=pushd alias ,,=popd alias ,.='dirs -v' No need to alias .. as in zsh you can use a dir name as a command to cd to it. Setting cdpath can further cut down on typing. For example cdpath=(. .. ~/go/src ~/src ~)
- ben509 9y agoIt's a joke. I don't think anyone is mistyping it, as it's two characters on alternate hands on the home row.
- StavrosK 9y agoI've mistyped it many times, precisely because it's alternate hands. Sometimes the left hand descends first.
- cgriswald 9y agoPerhaps handedness is a contributing factor. I imagine even amongst practiced typists, the non-dominant hand tends towards more technical/physical errors than the dominant hand. Errors might include descending early, late, drifting from the center of keys, a tendency to follow the sequence of the fingers, etc.... I come to this idea because I am left-handed and if I have made this mistake, it has happened infrequently enough that I can recall neither a particular event nor the fact of such events having occurred. I would be curious about the handedness of people who make this mistake frequently (enough) and those who believe they do not.
- gowld 9y agoIt's one of the most famous mistyped commands https://man.cx/sl(6) https://man.cx/sl(6)