1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-13 14:18:44 +00:00

Use a link

Spenser Truex 2021-01-25 15:33:32 +00:00
parent 98b1f23dee
commit cfa6e37cd2
2 changed files with 1 additions and 45 deletions

@ -1,45 +0,0 @@
Thefuck takes longer to generate aliases than it takes hell to freeze over:
```sh
time thefuck --alias
thefuck --alias 0.12s user 0.04s system 92% cpu 0.172 total
# What the fuck?
```
This can be cached in your shell's startup script `.bashrc` or whatever:
```sh
[ -n "$XDG_RUNTIME_DIR" ] && thefuck_cache="$XDG_RUNTIME_DIR"/thefuck_cache
[ -z "$XDG_RUNTIME_DIR" ] && thefuck_cache="$HOME"/.local/share/runtime/thefuck_cache
if [ ! -f "$thefuck_cache" ]; then
thefuck --alias k | tee -a "$thefuck_cache"
thefuck --alias fk | tee -a "$thefuck_cache"
thefuck --alias fcuk | tee -a "$thefuck_cache"
thefuck --alias fuc | tee -a "$thefuck_cache"
thefuck --alias fcu | tee -a "$thefuck_cache"
thefuck --alias fuck | tee -a "$thefuck_cache"
thefuck --alias fuk | tee -a "$thefuck_cache"
fi
source "$thefuck_cache"
unset thefuck_cache
```
Doing this with `--enable-experimental-instant-mode` requires some care, because doing it wrong will cause thefuck to run infinite processes until it fills up your memory and crashes your computer!
This is a zsh script. To check for the login shell in bash, use `shopt -q login_shell` instead of setopt.
```zsh
#!/bin/zsh
THEFUCK_EXPERIMENTAL_LOCK_KLUDGE="$XDG_RUNTIME_DIR"/thefuck_experimental_lock_kludge
experimentallyinstantlylockkludginglyverylongname () {
printf %s " $$ " >>"$THEFUCK_EXPERIMENTAL_LOCK_KLUDGE"
eval "$(thefuck --enable-experimental-instant-mode --alias noop)"
}
[[ ! -e "$THEFUCK_EXPERIMENTAL_LOCK_KLUDGE" ]] \
|| touch "$THEFUCK_EXPERIMENTAL_LOCK_KLUDGE"
if [[ -z "$(setopt | grep -i login)" ]]; then
[[ ! $(grep -qF -- " $$ " $THEFUCK_EXPERIMENTAL_LOCK_KLUDGE) ]] \
&& experimentallyinstantlylockkludginglyverylongname
# so here it is, not cached.
else
# Delete this file on startup so it doesn't grow indefinitely.
rm "$THEFUCK_EXPERIMENTAL_LOCK_KLUDGE"
fi
```

@ -0,0 +1 @@
[Cache aliases Startup](https://github.com/nvbn/thefuck/wiki/Cache-aliases-Startup)