shells/zsh: add mktmpunzip and mktmpclone
This commit is contained in:
parent
267eea060c
commit
34cd8add4a
1 changed files with 30 additions and 0 deletions
|
@ -48,6 +48,36 @@
|
||||||
|
|
||||||
alias "jh"="cd ~ && j"
|
alias "jh"="cd ~ && j"
|
||||||
alias "gj"="gcd && j"
|
alias "gj"="gcd && j"
|
||||||
|
|
||||||
|
mktmpunzip() {
|
||||||
|
dir=$(mktemp -t -d unzip.XXX)
|
||||||
|
if ! file=$(realpath -e "$1"); then
|
||||||
|
echo "error: file does not exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
shift 1
|
||||||
|
unzip "$file" "$@" -d "$dir"
|
||||||
|
\builtin cd $dir
|
||||||
|
mv $file .
|
||||||
|
}
|
||||||
|
|
||||||
|
mktmpclone() {
|
||||||
|
location="$1"
|
||||||
|
if [ "$2" != "" ]; then
|
||||||
|
dirspec="$2.XXX"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
dirspec="clone.XXX"
|
||||||
|
shift 1
|
||||||
|
fi
|
||||||
|
if ! dir=$(mktemp -t -d "$dirspec"); then
|
||||||
|
echo "error: couldn't create temp directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git clone "$location" "$dir" "$@"
|
||||||
|
\builtin cd "$dir"
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dotDir = ".config/zsh";
|
dotDir = ".config/zsh";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue