mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-02-26 10:42:03 +01:00
feat(bash): add function for swapping two file or folder locations
This commit is contained in:
parent
0655fbf942
commit
2bd4aa4603
1 changed files with 19 additions and 0 deletions
|
|
@ -149,6 +149,25 @@ mkd () {
|
|||
mkdir -p -- "$1" && cd -P -- "$1" && l
|
||||
}
|
||||
|
||||
# Swap the location of a file or folder with another file or folder
|
||||
swp () {
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo -e "\e[0;91mExpected two arguments: swp <from> <to>\e[0m"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -e $1 ]; then
|
||||
echo -e "\e[0;91m'$1' is not a file or folder\e[0m"
|
||||
return 1
|
||||
fi
|
||||
|
||||
tmp_suffix=$RANDOM
|
||||
|
||||
mv $1 "$1.$tmp_suffix"
|
||||
mv $2 $1
|
||||
mv "$1.$tmp_suffix" $2
|
||||
}
|
||||
|
||||
# +-----+
|
||||
# | Git |
|
||||
# +-----+
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue