Handle terminals better
This commit is contained in:
parent
1a886be02c
commit
19200291f9
@ -6,7 +6,34 @@
|
||||
# If not running interactively, don't do anything
|
||||
[ -z "$PS1" ] && return
|
||||
|
||||
<<<<<<< HEAD
|
||||
[ "$(tty)" = "/dev/ttyUSB0" ] && export TERM=vt220
|
||||
=======
|
||||
case "$(tty)" in
|
||||
/dev/ttyS*|/dev/ttyUSB*|/dev/ttyACM*|/dev/ttyAMA)
|
||||
# Don't try to set the window title on serial ports
|
||||
shopt -u checkwinsize
|
||||
export TERM=vt220
|
||||
;;
|
||||
esac
|
||||
|
||||
limited_terminal() {
|
||||
case $TERM in
|
||||
*-color*|*-256color*)
|
||||
return false
|
||||
;;
|
||||
*unicode*)
|
||||
return false
|
||||
;;
|
||||
dumb|linux|hurd|vt*|mach*|wsvt*|tmux*|cons25*|rxvt*|screen*|sun)
|
||||
return true
|
||||
;;
|
||||
*)
|
||||
return false
|
||||
;;
|
||||
esac
|
||||
}
|
||||
>>>>>>> 9eb8244 (Handle terminals better)
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
|
@ -1,7 +1,3 @@
|
||||
alias ls='ls --color=auto'
|
||||
alias ll='ls -lh'
|
||||
alias la='ls -A'
|
||||
|
||||
alias mv="mv -iv"
|
||||
alias cp="cp -riv"
|
||||
alias mkdir="mkdir -vp"
|
||||
@ -9,13 +5,52 @@ alias mkdir="mkdir -vp"
|
||||
alias red_october="ping -c1"
|
||||
alias ro="red_october"
|
||||
|
||||
alias clipboard="xclip -selection c -i"
|
||||
alias cb="clipboard"
|
||||
if [ -n $DISPLAY ]
|
||||
then
|
||||
alias clipboard="xclip -selection c -i"
|
||||
alias cb="clipboard"
|
||||
fi
|
||||
|
||||
alias compose="less /usr/share/X11/locale/en_US.UTF-8/Compose"
|
||||
if [ -f /usr/share/X11/locale/en_US.UTF-8/Compose ]
|
||||
then
|
||||
alias compose_ref="less /usr/share/X11/locale/en_US.UTF-8/Compose"
|
||||
fi
|
||||
|
||||
if [ -x "$(which nvim)" ]
|
||||
then
|
||||
alias vim=nvim
|
||||
alias vimdiff="nvim -d"
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v xdg-open)" ]
|
||||
then
|
||||
alias open="xdg-open"
|
||||
fi
|
||||
|
||||
# cat && less
|
||||
if [ ! limited_terminal && -x "$(command -v batcat)" ] || [ -x "$(command -v bat)" ]
|
||||
then
|
||||
if [ -x "$(command -v batcat)" ]
|
||||
then
|
||||
alias bat=batcat
|
||||
fi
|
||||
alias ccat="$(which cat)"
|
||||
alias lless="$(which less)"
|
||||
alias less=bat
|
||||
alias cat=bat
|
||||
fi
|
||||
|
||||
# ls
|
||||
if [ ! limited_terminal ]
|
||||
then
|
||||
if [ -x "$(command -v lsd)" ]
|
||||
then
|
||||
alias lls="$(which ls)"
|
||||
alias ls=lsd
|
||||
else
|
||||
alias ls='ls --color=auto'
|
||||
fi
|
||||
fi
|
||||
alias la='ls -A'
|
||||
alias ll='ls -lh'
|
||||
alias lla='ls -lA'
|
||||
|
@ -7,3 +7,51 @@ function cll() {
|
||||
cd $1
|
||||
ls -l
|
||||
}
|
||||
|
||||
function whence() {
|
||||
# Usage:
|
||||
# which_follow_links [-p] <command>
|
||||
# -p: Print each symlink path
|
||||
local follow_links=false
|
||||
local print_links=false
|
||||
|
||||
# Option parsing
|
||||
while getopts "p" opt; do
|
||||
case $opt in
|
||||
p)
|
||||
print_links=true
|
||||
;;
|
||||
h)
|
||||
tabs 2
|
||||
echo "Usage:"
|
||||
echo -e "\twhence [-p | -h] <command>"
|
||||
echo -e "\t\t-h: Print Usage"
|
||||
echo -e "\t\t-p: Print each symlink path"
|
||||
tabs
|
||||
return
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
return
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# Find the initial path using which
|
||||
local path=$(which "$1" 2> /dev/null)
|
||||
if [[ -z "$path" ]]; then
|
||||
echo "$1 not found"
|
||||
return
|
||||
fi
|
||||
|
||||
# Follow symlinks
|
||||
while [[ -L "$path" ]]; do
|
||||
if [[ "$print_links" == "true" ]]; then
|
||||
echo "Link: $path -> $(readlink -f "$path")"
|
||||
fi
|
||||
path=$(readlink -f "$path")
|
||||
done
|
||||
|
||||
echo "Final target: $path"
|
||||
}
|
||||
|
@ -82,10 +82,8 @@ prompt_cmd() {
|
||||
echo
|
||||
}
|
||||
|
||||
if [ "$TERM" = "vt220" ]
|
||||
if [ ! limited_terminal ]
|
||||
then
|
||||
echo > /dev/null
|
||||
else
|
||||
export PROMPT_COMMAND="prompt_cmd"
|
||||
export PS1="$PREFIX\[$(tput setaf $BASE_COLOR)\]\[$(tput bold)\][\[$(tput setaf 1)\]\u\[$(tput setaf $BASE_COLOR)\]@\h \[$(tput setaf 3)\]\W\[$(tput setaf $BASE_COLOR)\]]\[$(tput setaf 1)\]\\$ \[$(tput sgr0)\]"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user