Added aliases separate file
This commit is contained in:
parent
8fee0aaf97
commit
66fe714e73
2 changed files with 106 additions and 91 deletions
105
config/aliases.sh
Normal file
105
config/aliases.sh
Normal file
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# ~/.config/aliases.sh
|
||||
#
|
||||
# A list of aliases and functions
|
||||
|
||||
# =======
|
||||
# Aliases
|
||||
# =======
|
||||
|
||||
alias cp="cp -i" # Confirm before overwriting something
|
||||
alias df='df -h' # Human-readable sizes
|
||||
alias free='free -m' # Show sizes in MB
|
||||
alias np='nano -w PKGBUILD'
|
||||
alias more=less
|
||||
alias hgrep='history | grep' # Search in history
|
||||
# Move to directory with personal files.
|
||||
alias Personal='cd ~/Documents/synchronisatie/Personal/_PERSOONLIJK/'
|
||||
# Move to directory with uni files.
|
||||
alias UGent='cd ~/Documents/synchronisatie/UGent/Informatica\ J1\ 2021-2022/'
|
||||
alias vol='~/.scripts/vol.sh' # Shortcut to volume setter script
|
||||
|
||||
# =========
|
||||
# Functions
|
||||
# =========
|
||||
|
||||
# Run git commands with a specific SSH-key more easily
|
||||
# Usage: sshgit <path-to-key> <command(s)>
|
||||
sshgit () {
|
||||
|
||||
# Check arguments
|
||||
if [[ $# -lt 2 ]] ; then
|
||||
echo "Requires at least two arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh_key="$1"
|
||||
shift
|
||||
GIT_SSH_COMMAND="ssh -i ${ssh_key}" git $@
|
||||
|
||||
}
|
||||
|
||||
# Copy a directory (to a non-existing destination), interactively
|
||||
# Usage: cpdir <source> <destination>
|
||||
cpdir () {
|
||||
|
||||
# Check arguments
|
||||
if [[ $# == 2 ]] ; then
|
||||
from=$(dirname $1)
|
||||
fromfile=$(basename $1)
|
||||
to=$(dirname $2)
|
||||
tofile=$(basename $2)
|
||||
else
|
||||
echo "cpdir: Not enough arguments"
|
||||
echo "cpdir: Syntaxis: cpdir <source> <destination>"
|
||||
return
|
||||
fi
|
||||
|
||||
# Check file
|
||||
if [[ ! -f $1 ]] ; then
|
||||
echo "cpdir: Source does not exist: $1"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Move ${fromfile} from ${from} to ${to} as ${tofile}?"
|
||||
echo -n "y/n > "
|
||||
read answer
|
||||
|
||||
if [[ ${answer} == "y" ]] ; then
|
||||
mkdir -pv $to
|
||||
cp $1 $2
|
||||
echo "Done"
|
||||
elif [[ ${answer} == "n" ]] ; then
|
||||
echo "Not copying..."
|
||||
else
|
||||
echo "Invalid option"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
# ex - arrchive extractor
|
||||
# Usage: ex <file>
|
||||
ex () {
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1 ;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*)
|
||||
echo "'$1' cannot be extracted via ex()"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
92
config/zshrc
92
config/zshrc
|
@ -84,95 +84,5 @@ fi
|
|||
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
|
||||
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
||||
# For a full list of active aliases, run `alias`.
|
||||
#
|
||||
# Example aliases
|
||||
alias cp="cp -i" # confirm before overwriting something
|
||||
alias df='df -h' # human-readable sizes
|
||||
alias free='free -m' # show sizes in MB
|
||||
alias np='nano -w PKGBUILD'
|
||||
alias more=less
|
||||
alias hgrep='history | grep'
|
||||
alias psql='psql -U postgres'
|
||||
alias rmou='rclone mount OneDriveUGent: ~/Documents/OneDriveUGent/'
|
||||
alias rmop='rclone mount OneDrivePersonal: ~/Documents/OneDrivePersonal'
|
||||
alias helios='ssh tdpeuter@helios.ugent.be'
|
||||
alias resblue='systemctl restart bluetooth'
|
||||
alias Personal='cd ~/Documents/synchronisatie/Personal/_PERSOONLIJK/'
|
||||
alias UGent='cd ~/Documents/synchronisatie/UGent/Informatica\ J1\ 2021-2022/'
|
||||
alias vol='~/.scripts/vol.sh'
|
||||
source ~/.config/aliases.sh
|
||||
|
||||
sshgit () {
|
||||
|
||||
# Check arguments
|
||||
if [[ $# -lt 2 ]] ; then
|
||||
echo "Requires at least two arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh_key="$1"
|
||||
shift
|
||||
GIT_SSH_COMMAND="ssh -i ${ssh_key}" git $@
|
||||
|
||||
}
|
||||
|
||||
cpdir () {
|
||||
|
||||
# Check arguments
|
||||
if [[ $# == 2 ]] ; then
|
||||
from=$(dirname $1)
|
||||
fromfile=$(basename $1)
|
||||
to=$(dirname $2)
|
||||
tofile=$(basename $2)
|
||||
else
|
||||
echo "cpdir: Not enough arguments"
|
||||
echo "cpdir: Syntaxis: cpdir <source> <destination>"
|
||||
return
|
||||
fi
|
||||
|
||||
# Check file
|
||||
if [[ ! -f $1 ]] ; then
|
||||
echo "cpdir: Source does not exist: $1"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Move ${fromfile} from ${from} to ${to} as ${tofile}?"
|
||||
echo -n "y/n > "
|
||||
read answer
|
||||
|
||||
if [[ ${answer} == "y" ]] ; then
|
||||
mkdir -pv $to
|
||||
cp $1 $2
|
||||
echo "Done"
|
||||
elif [[ ${answer} == "n" ]] ; then
|
||||
echo "Not copying..."
|
||||
else
|
||||
echo "Invalid option"
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# ex - arrchive extractor
|
||||
# usage: ex <file>
|
||||
ex () {
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1 ;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*)
|
||||
echo "'$1' cannot be extracted via ex()"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue