Support additional shell functions
I learned about compgen, so I made a bunch of aliases that should help me remember its uses. Also added a myriad of others.
This commit is contained in:
parent
43a2d0de2c
commit
f9be76e678
1 changed files with 62 additions and 0 deletions
|
@ -108,6 +108,22 @@ kush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
|
all_users() {
|
||||||
|
# Lists all of the known users in the Linux system
|
||||||
|
# Useful because when you type `~art` in a prompt and tab-complete, ZSH looks
|
||||||
|
# up all users whose names start with "art". It's also just interesting to
|
||||||
|
# have access to this information.
|
||||||
|
#
|
||||||
|
# NOTE: this is not as simple as `cat /etc/passwd` for reasons of which I'm
|
||||||
|
# not entirely sure.
|
||||||
|
getent passwd
|
||||||
|
}
|
||||||
|
|
||||||
|
test_true_color() {
|
||||||
|
# Run this to test if your terminal emulator supports True Color
|
||||||
|
curl --silent https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | bash
|
||||||
|
}
|
||||||
|
|
||||||
path() {
|
path() {
|
||||||
# Pretty-print the $PATH variable
|
# Pretty-print the $PATH variable
|
||||||
echo "$PATH" | tr : '\n'
|
echo "$PATH" | tr : '\n'
|
||||||
|
@ -212,6 +228,16 @@ monitor_dimensions() {
|
||||||
xdpyinfo | awk '/dimensions/{ print $2 }'
|
xdpyinfo | awk '/dimensions/{ print $2 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_sinks() {
|
||||||
|
# Lists the available output sources (speakers?)
|
||||||
|
pacmd list-sinks | grep -e 'name:' -e 'index:'
|
||||||
|
}
|
||||||
|
|
||||||
|
list_sources() {
|
||||||
|
# List available input sources (microphones?)
|
||||||
|
pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'
|
||||||
|
}
|
||||||
|
|
||||||
lt() {
|
lt() {
|
||||||
# Convenience wrapper around `exa --tree`.
|
# Convenience wrapper around `exa --tree`.
|
||||||
# Optionally accepts a number for the max-depth and a directory to list.
|
# Optionally accepts a number for the max-depth and a directory to list.
|
||||||
|
@ -296,7 +322,43 @@ tk() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmux_is_running() {
|
||||||
|
# Returns zero if tmux is running
|
||||||
|
# Although this is a simple function body, it's useful to encode esoteric
|
||||||
|
# knowledge that I will easily forget.
|
||||||
|
test -n "$TMUX"
|
||||||
|
}
|
||||||
|
|
||||||
|
tmux_focused_pane() {
|
||||||
|
# Returns the ID of the focused tmux pane.
|
||||||
|
# WIP
|
||||||
|
# tmux list-panes -F '#{pane_active} #{pane_tty}' | awk /1/{ print $1 }
|
||||||
|
echo 'Not implemented'
|
||||||
|
}
|
||||||
|
|
||||||
# zsh
|
# zsh
|
||||||
|
fns() {
|
||||||
|
# Outputs all available functions.
|
||||||
|
# `fns` was chosen instead of `functions`, since `functions` was already
|
||||||
|
# taken.
|
||||||
|
compgen -A function
|
||||||
|
}
|
||||||
|
|
||||||
|
aliases() {
|
||||||
|
# Outputs all available aliases.
|
||||||
|
compgen -a
|
||||||
|
}
|
||||||
|
|
||||||
|
keywords() {
|
||||||
|
# Outputs all of the shell's reserved keywords.
|
||||||
|
compgen -k
|
||||||
|
}
|
||||||
|
|
||||||
|
builtins() {
|
||||||
|
# Outputs all of the shell's builtin commands.
|
||||||
|
compgen -b
|
||||||
|
}
|
||||||
|
|
||||||
zle_insert_subshell() {
|
zle_insert_subshell() {
|
||||||
LBUFFER+='$(' ; RBUFFER=")$RBUFFER"
|
LBUFFER+='$(' ; RBUFFER=")$RBUFFER"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue