Vários scripts e outros ficheiros
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

269 lines
8.5 KiB

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# 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`.
#
# Settings/Configs Files
alias zshconfig="$EDITOR ~/.zshrc"
alias ohmyzsh="$FILEMANAGER ~/.oh-my-zsh"
alias profile='$EDITOR ~/.profile'
alias rezsh='source ~/.zshrc'
alias reprofile='source ~/.profile'
# Windows Old Alias
alias copy="cp -i"
alias move="mv -i"
alias delete="rm -I --preserve-root"
alias deltree="rm -I --preserve-root -r"
#Easier and quick way to get out of currect directory
alias ..="cd .."
alias ../..="cd ../.."
alias ../../..="cd ../../.."
alias cd..="cd .." # no more command not found
# Easier app install and system update
reinstall() { sudo pacman -S "$1" $(pacman -Qi "$1"|grep -i depend|cut -d: -f2); }
alias update="sudo pacman -Syyu --noconfirm"
alias pacallinstalled="pacman -Qe"
alias pacqet="pacman -Qett --color=always | less"
alias pacforeigninstalled="pacman -Qm"
alias pacmnative="pacman -Qn"
alias pacregex="pacman -Qs $1"
alias pacnativedep="pacman -Qent"
alias pacdev="pacman -Qq | grep -Ee '-(bzr|cvs|darcs|git|hg|svn)$'"
alias pacshow="pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'"
paconesize() {
local PACKAGE="$1"
if [[ "$PACKAGE" == "" ]]; then
echo "pacmanqlq 'package name'"
else
pacman -Qlq $1 | grep -v '/$' | xargs -r du -h | sort -h
fi
}
paciden() {
find /etc /usr /opt /var | LC_ALL=C pacman -Qqo - 2>&1 > /dev/null | cut -d ' ' -f 5-
}
pacfiles() {
pacman -Qii | awk '/^MODIFIED/ {print $2}'
}
pacdeplist() {
[[ $# == 1 ]] && LC_ALL=C pacman -Si $1 | awk -F'[:<=>]' '/^Depends/ {print $2}' | xargs -n1 | sort -u
}
paclall() {
LC_ALL=C pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h
}
# Start calculator with math support
alias bc="bc -l"
# mount output pretty and human readable
alias mount="mount|column -t"
#Set default common app names
alias browser="firejail librewolf"
alias mail="firejail claws-mail"
#Get Week date
week(){
now=$(date '+%V %B %Y');
echo "Week date:" $now
}
# Get current year and month
currentyear=$(date '+%Y');
currentmonth=$(date '+%m');
alias currentyear="echo $currentyear"
alias currentmonth="echo $currentmonth"
# Add an alert alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Short cuts to save time
alias h="history"
alias hs="history | grep"
alias hsi="history | grep -i"
alias edit="nano"
alias pm="/usr/bin/palemoon"
alias top="atop"
alias ka="killall"
alias tran="transmission-gtk"
alias trem="transmission-remote-gtk"
# Git
alias g='git'
alias ga='git add'
alias gl='git log --decorate --oneline'
alias glg='git log --decorate --oneline --graph'
alias gcom='git commit'
alias gdf='git diff'
clone() {
git clone https://github.com/"$1"/"$2".git
}
# Networking
alias ping="ping -c 5"
alias fastping="ping -c 100 -s 1"
alias ports="netstat -tulanp"
alias watch-network='sudo watch -n 1 -t lsof -P -i -n'
alias wifi='sudo iwlist wlan0 scan|grep -i ssid'
alias scanip='sudo nmap 192.168.1.0/24 -n -sP -PE -T5|grep report'
monitor() { watch -n1 -t "lsof -i -n|awk '{print \$1, \$2, \$9}'|column -t"; }
# Get external IP, IP Whois and Speed Test
myip() {
echo "O teu endereço de IP externo é:"
curl -w '\n' https://ipinfo.io/ip
}
whoisme() {
echo "IP: $(curl -s https://ipinfo.io/ip)"
echo "Hostname: $(curl -s https://ipinfo.io/hostname)"
echo "ISP: $(curl -s https://ipinfo.io/org)"
echo "Geo: $(curl -s https://ipinfo.io/city), $(curl -s https://ipinfo.io/region), $(curl -s https://ipinfo.io/country)"
echo "Timezone: $(curl -s https://ipinfo.io/timezone)"
}
alias speedtest="curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -"
# Debug web server / cdn problems with curl
alias header="curl -I" # get web server headers
alias headerc="curl -I --compress" # find out if server supports gzip / mod_deflate or not
# Safety nets
alias rm="rm -I --preserve-root" # do not delete / or prompt if deleting more than 3 files at a time
alias mv="mv -i" # Ask for confirmation
alias cp="cp -i" # Ask for confirmation
alias ln="ln -i" # Ask for confirmation
alias chown="chown --preserve-root"
alias chmod="chmod --preserve-root"
alias chgrp="chgrp --preserve-root"
#Tune sudo and su
alias root="sudo -i"
alias su="sudo -i"
# reboot / halt / poweroff
alias reboot="sudo /sbin/reboot"
alias poweroff="sudo /sbin/poweroff"
alias halt="sudo /sbin/halt"
alias shutdown="sudo /sbin/shutdown"
alias sdn="sudo shutdown -h now"
#Get systeminfo without neofetch
alias meminfo="free -m -l -t"
alias psmem="ps auxf | sort -nr -k 3"
alias psmem10="ps auxf | sort -nr -k 4 | head -10"
alias pscpu="ps auxf | sort -nr -k 3"
alias pscpu10="ps auxf | sort -nr -k 3 | head -10"
alias cpuinfo="lscpu"
alias cputemp="sensors | awk '/^temp1/ {print $2}'"
# archive extractor
extract()
{
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 extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# translate-shell (trans)
if command -v trans &>/dev/null
then
alias en2pt='trans en:pt -brief -shell -e google'
alias pt2en='trans pt:en -brief -shell -e google'
alias eipt='trans en:pt -dictionary -e google'
alias ptei='trans pt:en -dictionary -e google'
alias en2ja='trans en:ja -brief -shell -e google'
alias ja2en='trans ja:en -brief -shell -e google'
alias eiwa='trans en:ja -dictionary -e google'
alias waei='trans ja:en -dictionary -e google'
fi
# Start OpenVPN
alias vpn_start="sudo service openvpn start"
alias vpn_stop="sudo service openvpn stop"
#LSD to LS and other alias for ls
alias ls="lsd -L --group-dirs first"
alias l="ls -l"
alias la="ls -a"
alias lla="ls -la"
alias lt="ls --tree"
#Colorize when possible
# alias ls="ls -hN --color=auto --group-directories-first"
alias grep="grep --color=auto"
alias egrep="egrep --color=auto"
alias fgrep="fgrep --color=auto"
alias diff="colordiff"
alias dir="dir --color=auto"
alias vdir="vdir --color=auto"
#Upload files
transfer(){ if [ $# -eq 0 ];then echo "Nenhum argumento especificado.\nUso:\n transfer <ficheiro|diretório>\n ... | transfer <nome_ficheiro>">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: Nenhum ficheiro ou directório deste tipo">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "http://transfer.sh/$file_name"|tee /dev/null,;else cat "$file"|curl --progress-bar --upload-file "-" "http://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "http://transfer.sh/$file_name"|tee /dev/null;fi;}
# Display battery information
# To Add
#View Crypto
cryptorate() {
curl "https://eur.rate.sx/$@?qF&n=5"
}
# Password Generator
function passgen() {
readonly qtd=${1:?"Por favor especifique a quantidade."}
readonly lgt=${2:?"Por favor especifique o comprimento."}
for ((i=0;i<$qtd;i+=1)) ; do
date=$(expr $(date +%s) + $i)
echo $date | sha256sum | base64 | head -c $lgt ; echo ;
done
}
# Stopwatch
stopwatch(){
date1=`date +%s`;
while true; do
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 0.1
done
}
# Radio
alias tsf='mplayer -nocache https://directo.tsf.pt/tsfdirecto.mp3'
alias m80='mplayer -nocache http://mcrscast.mcr.iol.pt/m80'
# Basic commands
alias c='clear'
alias cls='clear'
alias mkd='mkdir -pv'
mkcd() { mkdir -p "$1" && cd "$1"; }
newfile() { mkdir -p "$(dirname "$1")" && touch "$1"; }
# other defaults
alias df="df -H"
alias du="du -ch"
# other commands
alias weather="curl 'wttr.in/Lisbon?lang=pt-br&0pq&F&q&T'"
alias process-explorer="htop"
alias map="telnet mapscii.me"
alias please='sudo $(fc -ln -1)'
alias starwars="telnet towel.blinkenlights.nl"
alias shell="echo '$(realpath $0)'"
alias mpa="mpv --no-video"