+alias _psresources='ps -wAo pid,user,%cpu,%mem,stat,start,time,args'
+if [ "$(uname)" = "Linux" ]; then
+ alias pscpu='_psresources --sort -%cpu|less -S'
+ alias psmem='_psresources --sort -%mem|less -S'
+ alias pstree='ps --forest -weo pid,user:16,args --sort start_time|less -S'
+ alias pstime='ps -wAo pid,user,lstart,args --sort start_time|less -S'
+else
+ alias pscpu='_psresources -r|less -S'
+ alias psmem='_psresources -m|less -S'
+ alias pstime='ps -wAo pid,user,lstart,args|less -S'
+fi
+
+#################
+# Other aliases #
+#################
+
+alias f='find . -iname'
+if echo x | grep -q --color=auto x &> /dev/null; then
+ alias grep='grep --color=auto'
+fi
+alias rg='rg -p'
+alias scp='scp -o ControlPath=none'
+alias bc='bc -ql'
+alias watch='watch -n1'
+alias sudo='sudo ' # ability to use aliases with sudo
+alias sudosu='sudo su -l -s /bin/bash'
+alias py='PYTHONSTARTUP=~/.pythonrc.py python'
+alias webshare='python3 -mhttp.server'
+
+if ! command -v pbcopy &> /dev/null; then
+ alias pbcopy='xsel --clipboard --input'
+ alias pbcopym='xsel --input'
+ alias pbpaste='xsel --clipboard --output'
+ alias pbpastem='xsel --output'
+fi
+
+# man with coloured headings and a terminal title
+function man {
+ echo -ne "\\033]0;man $*\\007"
+
+ env \
+ LESS_TERMCAP_md=$'\E[01;38;5;74m' \
+ LESS_TERMCAP_me=$'\E[0m' \
+ LESS_TERMCAP_us=$'\E[04;38;5;146m' \
+ LESS_TERMCAP_ue=$'\E[0m' \
+ man --encoding ascii "$@"
+}
+
+# Creates the directory if it doesn't exist, and changes into it
+function mcd {
+ # shellcheck disable=SC2164
+ mkdir -p "$1" && cd "$1"
+}
+
+# Sets the nice and ionice priorities for the current shell to the lowest values
+function slowshell {
+ ionice -c 3 -p $$
+ renice -n 19 -p $$
+}
+
+# SSH to an unknown host and print the new known_hosts entry
+function ssh_new {
+ local new_known_hosts_file
+ new_known_hosts_file="$(mktemp)"
+ ssh -o UserKnownHostsFile="$new_known_hosts_file" "$@" echo 'Connection ok'
+ cat "$new_known_hosts_file"
+ rm -f "$new_known_hosts_file"
+}
+
+# SSH without verifying host key
+function ssh_unsafe {
+ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$@"
+}