Reemplazo de espacios por tabulaciones
This commit is contained in:
parent
935ade622c
commit
a4fbd124da
|
@ -1,9 +1,8 @@
|
|||
# Añadir esta configuración en /root/.profile para personalizar el prompt para root
|
||||
|
||||
function admin_prompt
|
||||
{
|
||||
[[ $PWD == $HOME ]] && dir="~" || dir="${PWD#*/}"
|
||||
print "${YELLOW}[$dir] ${GREEN}#${RED} "
|
||||
function admin_prompt {
|
||||
[[ $PWD == $HOME ]] && dir="~" || dir="${PWD#*/}"
|
||||
print "${YELLOW}[$dir] ${GREEN}#${RED} "
|
||||
}
|
||||
|
||||
PS1="\$(admin_prompt) "
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# Contar archivos o directorios en el directorio
|
||||
# Esto funciona pasando la salida del glob a la función y luego contando el número de argumentos.
|
||||
|
||||
function count
|
||||
{
|
||||
# Uso:
|
||||
# count /path/to/dir/* -> Total (archivos y directorios)
|
||||
# count /path/to/dir/*/ -> Total de directorios
|
||||
|
||||
[[ -e $1 ]] && print "$#" || print 0
|
||||
function count {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
print "count /path/to/dir/* -> Total (archivos y directorios)" >&2
|
||||
print "count /path/to/dir/*/ -> Total de directorios" >&2
|
||||
return 1
|
||||
elif
|
||||
[[ -e $1 ]] && print "$#" || print 0
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
function countl
|
||||
{
|
||||
lines=0
|
||||
lines=0
|
||||
|
||||
while IFS= read -r line || [[ -n $line ]]; do
|
||||
# lines=$((lines+1)) is slower than ((lines=lines+1))
|
||||
((lines=lines+1))
|
||||
done < "$1"
|
||||
while IFS= read -r line || [[ -n $line ]]; do
|
||||
((lines=lines+1))
|
||||
done < "$1"
|
||||
|
||||
printf '%s\n' "$lines"
|
||||
printf '%s\n' "$lines"
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
# Mostrar rama actual en directorios de git
|
||||
|
||||
function get_branch
|
||||
{
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
|
||||
if [[ ! -z ${BRANCH} ]]; then
|
||||
print "${BRANCH}"
|
||||
fi
|
||||
function get_branch {
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
|
||||
if [[ ! -z ${BRANCH} ]]; then
|
||||
print "${BRANCH}"
|
||||
fi
|
||||
|
||||
unset BRANCH
|
||||
unset BRANCH
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Mostrar directorio de trabajo actual
|
||||
|
||||
function get_dir
|
||||
{
|
||||
printf '%s\n' ${PWD/$HOME/\~}
|
||||
function get_dir {
|
||||
printf '%s\n' ${PWD/$HOME/\~}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# Mostrar los manuales de los programa con color
|
||||
|
||||
function man
|
||||
{
|
||||
LESS_TERMCAP_mb=$(printf %b "\033[1;31m") \
|
||||
LESS_TERMCAP_md=$(printf %b "\033[1;31m") \
|
||||
LESS_TERMCAP_me=$(printf %b "\033[0m") \
|
||||
LESS_TERMCAP_se=$(printf %b "\033[0m") \
|
||||
LESS_TERMCAP_so=$(printf %b "\033[1;44;33m") \
|
||||
LESS_TERMCAP_ue=$(printf %b "\033[0m") \
|
||||
LESS_TERMCAP_us=$(printf %b "\033[1;32m") \
|
||||
command man -a "$@"
|
||||
function man {
|
||||
LESS_TERMCAP_mb=$(printf %b "\033[1;31m") \
|
||||
LESS_TERMCAP_md=$(printf %b "\033[1;31m") \
|
||||
LESS_TERMCAP_me=$(printf %b "\033[0m") \
|
||||
LESS_TERMCAP_se=$(printf %b "\033[0m") \
|
||||
LESS_TERMCAP_so=$(printf %b "\033[1;44;33m") \
|
||||
LESS_TERMCAP_ue=$(printf %b "\033[0m") \
|
||||
LESS_TERMCAP_us=$(printf %b "\033[1;32m") \
|
||||
command man -a "$@"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Crear un directorio y cambiar a él
|
||||
|
||||
function mkcd
|
||||
{
|
||||
mkdir -p -- "$1" || return
|
||||
cd -P -- "$1"
|
||||
function mkcd {
|
||||
mkdir -p -- "$1" || return
|
||||
cd -P -- "$1"
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
# Prompt para usuario normal
|
||||
|
||||
function prompt
|
||||
{
|
||||
print "${GREEN}${PWD/$HOME/\~} ${CYAN}$(get_branch)"
|
||||
print "${RED}-> ${YELLOW}$ ${NORM}"
|
||||
function prompt {
|
||||
print "${GREEN}${PWD/$HOME/\~} ${CYAN}$(get_branch)"
|
||||
print "${RED}-> ${YELLOW}$ ${NORM}"
|
||||
}
|
||||
|
||||
PS1="\$(prompt) "
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# Consultar manuales de programa remotos
|
||||
|
||||
rman() {
|
||||
if command -v lynx >/dev/null; then
|
||||
lynx https://man.voidlinux.org/x86_64/"$@"
|
||||
return 0
|
||||
else
|
||||
print "Instale el programa lynx"
|
||||
return 1
|
||||
fi
|
||||
if command -v lynx >/dev/null; then
|
||||
lynx https://man.voidlinux.org/x86_64/"$@"
|
||||
return 0
|
||||
else
|
||||
print "Instale el programa lynx"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Consultar qué versión de shell korn se tiene en el sistema
|
||||
|
||||
ver() {
|
||||
printf '%s\n' "Korn Shell: ${KSH_VERSION:-desconocida}"
|
||||
printf '%s\n' "Korn Shell: ${KSH_VERSION:-desconocida}"
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
# Función que se encarga de determinar qué programa usar para escalar
|
||||
# permisos de administrador
|
||||
|
||||
function which_sudo
|
||||
{
|
||||
if command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-install; then
|
||||
print sudo
|
||||
elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
|
||||
print doas
|
||||
elif [[ $(id -u) != 0 ]]; then
|
||||
print su
|
||||
fi
|
||||
function which_sudo {
|
||||
if [[ $(id -u) == 0 ]]; then
|
||||
return
|
||||
elif command -v sudo >/dev/null && id | grep -q wheel; then
|
||||
print sudo
|
||||
elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
|
||||
print doas
|
||||
else
|
||||
print su
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue