Move bash and zsh aliases into a common file and functions to scripts.
Having two sets of aliases is hard to manage, therefore merging bash and zsh aliases prevents duplicate content. Some functions set with those aliases needs to be run with sudo and therefore keeping them as functions does not work. Hence, they have been moved into scripts located in a new dedicated "bin" folder. https://serverfault.com/questions/177699/how-can-i-execute-a-bash-function-with-sudo
This commit is contained in:
parent
1a26a0a2b1
commit
5ce82d1642
6 changed files with 79 additions and 98 deletions
34
.aliases
Normal file
34
.aliases
Normal file
|
@ -0,0 +1,34 @@
|
|||
[ "$(uname -s | tr '[:upper:]' '[:lower:]')" = 'linux' ] && alias ls='ls --color=auto'
|
||||
alias ll='ls -lihF'
|
||||
alias la='ls -A'
|
||||
alias l='ll -A'
|
||||
|
||||
alias t='tree'
|
||||
alias sudo='sudo '
|
||||
alias grep='grep -n --color=auto'
|
||||
alias j='jobs'
|
||||
alias df='df -h'
|
||||
alias du='du -ch'
|
||||
hash htop 2>/dev/null && alias top='htop'
|
||||
hash xscreensaver-command 2>/dev/null && alias lock='xscreensaver-command --lock'
|
||||
hash sqlmap 2>/dev/null && alias sqlmap='sqlmap --user-agent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"'
|
||||
hash sqlmap 2>/dev/null && alias sqlmap-tor='sqlmap --tor --tor-type=SOCKS5'
|
||||
hash steam 2>/dev/null && alias steam='find ~/.steam/root/ \( -name "libgcc_s.so*" -o -name "libstdc++.so*" -o -name "libxcb.so*" \) -print -delete; steam'
|
||||
|
||||
if hash chromium 2>/dev/null; then
|
||||
chromium-tor() {
|
||||
killall chromium
|
||||
chromium --incognito --proxy-server="socks://localhost:9050"
|
||||
}
|
||||
fi
|
||||
|
||||
if hash dig 2>/dev/null; then
|
||||
istheinternetonfire() {
|
||||
txt=$(dig +short txt istheinternetonfire.com)
|
||||
if hash cowsay 2>/dev/null; then
|
||||
echo "$txt" | cowsay
|
||||
else
|
||||
echo "$txt"
|
||||
fi
|
||||
}
|
||||
fi
|
|
@ -1,12 +0,0 @@
|
|||
[ "$(uname -s | tr '[:upper:]' '[:lower:]')" = 'linux' ] && alias ls='ls --color=auto'
|
||||
alias ll='ls -lihF'
|
||||
alias la='ls -A'
|
||||
alias l='ll -A'
|
||||
|
||||
alias t='tree'
|
||||
alias sudo='sudo '
|
||||
alias grep='grep -n --color=auto'
|
||||
alias j='jobs'
|
||||
alias df='df -h'
|
||||
alias du='du -ch'
|
||||
hash htop 2>/dev/null && alias top='htop'
|
2
.bashrc
2
.bashrc
|
@ -44,4 +44,4 @@ fi
|
|||
export GPG_TTY=$(tty)
|
||||
|
||||
# Aliases
|
||||
[ -f "$HOME/.bash_aliases" ] && . ~/.bash_aliases
|
||||
[ -f "$HOME/.aliases" ] && . "$HOME/.aliases"
|
||||
|
|
86
.zshrc
86
.zshrc
|
@ -47,88 +47,4 @@ if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
|
|||
fi
|
||||
|
||||
# Aliases
|
||||
[ "$(uname -s | tr '[:upper:]' '[:lower:]')" = 'linux' ] && alias ls='ls --color=auto'
|
||||
alias ll='ls -lihF'
|
||||
alias la='ls -A'
|
||||
alias l='ll -A'
|
||||
|
||||
alias t='tree'
|
||||
alias sudo='sudo '
|
||||
alias grep='grep -n --color=auto'
|
||||
alias j='jobs'
|
||||
alias df='df -h'
|
||||
alias du='du -ch'
|
||||
hash htop 2>/dev/null && alias top='htop'
|
||||
hash xscreensaver-command 2>/dev/null && alias lock='xscreensaver-command --lock'
|
||||
hash sqlmap 2>/dev/null && alias sqlmap='sqlmap --user-agent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"'
|
||||
hash sqlmap 2>/dev/null && alias sqlmap-tor='sqlmap --tor --tor-type=SOCKS5'
|
||||
hash steam 2>/dev/null && alias steam='find ~/.steam/root/ \( -name "libgcc_s.so*" -o -name "libstdc++.so*" -o -name "libxcb.so*" \) -print -delete; steam'
|
||||
|
||||
if hash chromium 2>/dev/null; then
|
||||
chromium-tor() {
|
||||
killall chromium
|
||||
chromium --incognito --proxy-server="socks://localhost:9050"
|
||||
}
|
||||
fi
|
||||
|
||||
if hash dig 2>/dev/null; then
|
||||
istheinternetonfire() {
|
||||
txt=$(dig +short txt istheinternetonfire.com)
|
||||
if hash cowsay 2>/dev/null; then
|
||||
echo "$txt" | cowsay
|
||||
else
|
||||
echo "$txt"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
clean()
|
||||
{
|
||||
clean_dir()
|
||||
{
|
||||
local dir="$1"
|
||||
if [ -d "$dir" ]; then
|
||||
find "$dir" -name "*~" -print -delete
|
||||
find "$dir" -name ".*~" -print -delete
|
||||
find "$dir" -name "#*#" -print -delete
|
||||
else
|
||||
echo "$dir: not a directory" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
for dir in "$@"; do
|
||||
clean_dir "$dir"
|
||||
done
|
||||
else
|
||||
clean_dir "./"
|
||||
fi
|
||||
|
||||
unfunction clean_dir
|
||||
}
|
||||
|
||||
if hash rankmirrors 2>/dev/null; then
|
||||
update_mirrorlist()
|
||||
{
|
||||
local pacman_dir="/etc/pacman.d"
|
||||
local mirror_file="$pacman_dir/mirrorlist"
|
||||
local mirror_pacnew="$mirror_file.pacnew"
|
||||
local mirror_orig="$mirror_file.orig"
|
||||
local mirror_tmp="/tmp/mirrorlist.tmp"
|
||||
|
||||
if [ -f "$mirror_pacnew" ]; then
|
||||
echo "Using $mirror_file"
|
||||
mv "$mirror_pacnew" "$mirror_orig"
|
||||
fi
|
||||
|
||||
if [ ! -f "$mirror_orig" ]; then
|
||||
echo "$mirror_orig: file not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/usr/bin/grep 'Server' "$mirror_orig" | tr -d "#" > "$mirror_tmp"
|
||||
rankmirrors -n 6 "$mirror_tmp" > "$mirror_file"
|
||||
rm -f "$mirror_tmp"
|
||||
pacman -Syy
|
||||
}
|
||||
fi
|
||||
[ -f "$HOME/.aliases" ] && . "$HOME/.aliases"
|
||||
|
|
22
bin/clean
Executable file
22
bin/clean
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
clean_dir()
|
||||
{
|
||||
local dir="$1"
|
||||
|
||||
if [ -d "$dir" ]; then
|
||||
find "$dir" -name "*~" -print -delete
|
||||
find "$dir" -name ".*~" -print -delete
|
||||
find "$dir" -name "#*#" -print -delete
|
||||
else
|
||||
echo "$dir: not a directory" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
for dir in "$@"; do
|
||||
clean_dir "$dir"
|
||||
done
|
||||
else
|
||||
clean_dir "./"
|
||||
fi
|
21
bin/update_mirrorlist
Executable file
21
bin/update_mirrorlist
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
mirror_file="$pacman_dir/mirrorlist"
|
||||
mirror_pacnew="$mirror_file.pacnew"
|
||||
mirror_orig="$mirror_file.orig"
|
||||
mirror_tmp="/tmp/mirrorlist.tmp"
|
||||
|
||||
if [ -f "$mirror_pacnew" ]; then
|
||||
echo "Using $mirror_file"
|
||||
mv "$mirror_pacnew" "$mirror_orig"
|
||||
fi
|
||||
|
||||
if [ ! -f "$mirror_orig" ]; then
|
||||
echo "$mirror_orig: file not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
grep 'Server' "$mirror_orig" | tr -d "#" > "$mirror_tmp"
|
||||
rankmirrors -n 6 "$mirror_tmp" > "$mirror_file"
|
||||
rm -f "$mirror_tmp"
|
||||
pacman -Syy
|
Loading…
Reference in a new issue