zsh: Move {,un}bkp from aliases to functions
Since both were functions already their place seems more appropriate in
functions.zsh. This also fixes the completion of both, since they did
not complete files before.
Other changes in `unbkp`:
- Use `mv` instead of `cp`
- Fix little typo (forgotten quote) and support specifying the
original name instead of only the backup.
- Do not "rename" the file if there is no change in name
(Leading to the prompt if the file should be overwritten)
This commit is contained in:
@@ -99,10 +99,6 @@
|
|||||||
alias lowres='() {
|
alias lowres='() {
|
||||||
xrandr -s 1920x1080; $1 "${@[2,-1]}"; xrandr -s 3200x1800
|
xrandr -s 1920x1080; $1 "${@[2,-1]}"; xrandr -s 3200x1800
|
||||||
}'
|
}'
|
||||||
# Create copy with .bkp extension
|
|
||||||
alias bkp='() { for f; do command cp -i "$f"{,.bkp}; done }'
|
|
||||||
# Reverse bkp()
|
|
||||||
alias unbkp='() { for f; do command cp -i "$f" "${f%.bkp}; done }'
|
|
||||||
# Grep in history file
|
# Grep in history file
|
||||||
alias histgrep='() { grep "$@" "${HISTFILE:-$HOME/.zsh_history}" }'
|
alias histgrep='() { grep "$@" "${HISTFILE:-$HOME/.zsh_history}" }'
|
||||||
# URL-encode
|
# URL-encode
|
||||||
|
|||||||
@@ -432,3 +432,21 @@ git-rebase-add-stash() {
|
|||||||
git add -u &&
|
git add -u &&
|
||||||
git rebase --continue
|
git rebase --continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create copy with a .bkp extension
|
||||||
|
bkp() {
|
||||||
|
for f; do
|
||||||
|
command cp -i "$f"{,.bkp}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reverse bkp()
|
||||||
|
unbkp() {
|
||||||
|
for f; do
|
||||||
|
if [[ ${f%.bkp} != $f ]]; then
|
||||||
|
command mv -i "$f" "${f%.bkp}"
|
||||||
|
elif [[ -e $f.bkp ]]; then
|
||||||
|
command mv -i "$f.bkp" "$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user