Compare commits

...

2 Commits

Author SHA1 Message Date
b694e9cdf5 Add copy and paste aliases to clipboard commands
Interact with the clipboard through the `copy` and `paste` aliases.

`copy` is defined when:

1. An `ssh` connection is detected, using OSC-52.
2. macOS is detected, using `pbcopy`.
3. `xsel` is detected.

`paste` is define when:

1. macOS is detected, using `pbpaste`.
2. `xsel` is detected.
2021-03-02 20:04:33 +00:00
d91d6b3534 Wrap bat with additional arguments 2021-03-02 20:02:30 +00:00

View File

@ -2,6 +2,25 @@
autoload colors && colors
# Abstract different ways to copy to the clipboard.
if [ -n "$SSH_CONNECTION" ] ; then
# Use OSC-52 to set the clipboard
alias copy='base64 | xargs -0 printf "\033]52;c;%s\a"'
elif [ "`uname`" = "Darwin" ]; then
# Use pbcopy to set the clipboard
alias copy='pbcopy'
elif which xclip &> /dev/null; then
# Use xclip to set the clipboard
alias copy='xclip -selection c'
fi
# Abstract different ways to paste from the clipboard.
if [ "`uname`" = "Darwin" ]; then
alias paste='pbpaste'
elif which xclip &> /dev/null; then
alias paste='xclip -selection c -o'
fi
# Detect the type and extract an archive file.
extract() {
if [ -f $1 ]; then
@ -25,6 +44,16 @@ extract() {
fi
}
if which bat &> /dev/null; then
# Wrap bat to specify a theme, always enable color, pipe the output to less.
# Both --theme and --color can be specified multiple times and will override
# these defaults.
bat() {
command bat --theme='Solarized (dark)' --color always \
--paging always --pager 'less -R' "$@"
}
fi
if which docker-machine &> /dev/null; then
# Wrap the docker command to print a message if a docker-machine is not
# running, rather than just stating it can not find it's socket.