Compare commits

..

3 Commits

Author SHA1 Message Date
acfd0cdee4 More escape sequence utilities
* Add `tmux-dcs-passthrough` to passthrough escape sequences tmux
  doesn't understand.
* Add `notify` to post a notification via the terminal emulator.
2021-06-17 22:46:14 +01:00
4561adf530 Teach ipython to use XDG base dirs 2021-06-17 22:46:14 +01:00
a7a8d7da8f Properly extract .tar.xz on macOS 2021-06-17 22:46:14 +01:00
2 changed files with 31 additions and 13 deletions

View File

@ -15,29 +15,46 @@ elif which xclip &> /dev/null; then
fi fi
# Abstract different ways to paste from the clipboard. # Abstract different ways to paste from the clipboard.
# TODO: Use OSC-52 to get the clipboard, not widely supported though
if [ "`uname`" = "Darwin" ]; then if [ "`uname`" = "Darwin" ]; then
# Use pbpaste to get the clipboard
alias paste='pbpaste' alias paste='pbpaste'
elif which xclip &> /dev/null; then elif which xclip &> /dev/null; then
# Use xclip to get the clipboard
alias paste='xclip -selection c -o' alias paste='xclip -selection c -o'
fi fi
# Passthrough an escape sequences tmux doesn't know about.
tmux-dcs-passthrough() {
if [ -n "$TMUX" ]; then
printf "\x1bPtmux;\x1b$1\x1b\\"
else
printf "$1"
fi
}
# OSC 9 - Post a notification - supported by iTerm2, maybe others?
notify() {
tmux-dcs-passthrough "\x1b]9;$*\x7"
}
# Detect the type and extract an archive file. # Detect the type and extract an archive file.
extract() { extract() {
if [ -f $1 ]; then if [ -f $1 ]; then
case $1 in case $1 in
*.tar.bz2) tar xvjf $1 ;; *.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;; *.tar.gz) tar xvzf $1 ;;
*.tar.xz) gunzip $1 ;; *.tar.xz) [ `"uname"` = "Darwin" ] && tar xvJf $1 || gunzip $1 ;;
*.bz2) bunzip2 $1 ;; *.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;; *.rar) unrar x $1 ;;
*.gz) gunzip $1 ;; *.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;; *.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;; *.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;; *.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;; *.zip) unzip $1 ;;
*.Z) uncompress $1 ;; *.Z) uncompress $1 ;;
*.7z) 7zr x $1 ;; *.7z) 7zr x $1 ;;
*) echo "$fg[red]error:$reset_color unable to extract '$1'" ;; *) echo "$fg[red]error:$reset_color unable to extract '$1'" ;;
esac esac
else else
echo "$fg[red]error:$reset_color file not found '$1'" echo "$fg[red]error:$reset_color file not found '$1'"

1
zshenv
View File

@ -81,6 +81,7 @@ which pinentry-curses &> /dev/null && \
export LPASS_PINENTRY=pinentry-curses export LPASS_PINENTRY=pinentry-curses
# Teach these some XDG Base Directory Spec manners # Teach these some XDG Base Directory Spec manners
export IPYTHONDIR=$HOME/.config/ipython
which cargo &> /dev/null && \ which cargo &> /dev/null && \
export CARGO_HOME=$HOME/.local/share/cargo export CARGO_HOME=$HOME/.local/share/cargo
if which ccache &> /dev/null; then if which ccache &> /dev/null; then