Added chx() to toggle whether a file is executable

This commit is contained in:
PowerUser64 2021-08-22 14:25:54 -07:00
parent 1f57a0d47b
commit 842945ffe8

23
.zshrc
View file

@ -59,7 +59,6 @@
## Program improvements (ex: ls = ls -h) >>>
alias df='df -h' # Human-readable sizes
alias free='free -m' # Show sizes in MB
alias tm='tmux new -As0' # open a new session called 0, but if there is already a session called 0, connect to it
alias bc="bc -ql" # Make bc usable for fast math
# Colors
@ -75,6 +74,8 @@
# dotfile management
alias dot='git --git-dir="/home/blake/git/dotfiles" --work-tree="$HOME"'
alias tm='tmux new -As0' # open a new session called 0, but if there is already a session called 0, connect to it
# Edit config files
alias \
vimrc="$EDITOR ~/.config/nvim/init.vim" \
@ -105,7 +106,8 @@
logs='docker-compose logs --tail=200 -f' \
dupd='docker-compose up -d' \
ddwn='docker-compose down' \
occ='docker exec -it nextcloud occ' \
dc='docker-compose' \
occ='docker exec -it -u www-data nextcloud php occ' \
# lists all open ports, along with some other info
alias ls-ports='netstat -tulpn'
@ -117,7 +119,7 @@
SMART_PLUG_IP='192.168.1.250'
alias l='tplink_smartplug.py -t $SMART_PLUG_IP -c'
# Colors
# Common ls aliases
alias \
la='ls -ah' \
ll='ls -lh' \
@ -133,6 +135,21 @@
# optionally source an external function file
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/fnrc"
# toggles whether a file or group of files is executable
chx() {
for FILE in "$@";do
if [ -x "$FILE" ];then
chmod -x "$FILE" &&
echo -e "$FILE: -x"
elif ! [ -x "$FILE" ];then
chmod +x "$FILE" &&
echo -e "$FILE: +x"
else
echo "error: file $FILE does not exist" >&2
fi
done
}
# Simple extraction script. Taken from manjaro's .bashrc
ex() {
if [ -f $1 ] ; then