Updating #fishshell

This commit is contained in:
Colin Powell
2019-11-12 11:41:01 -05:00
parent 859e1d1d53
commit afe917b512
19 changed files with 8 additions and 394 deletions

Binary file not shown.

View File

@ -1,152 +0,0 @@
# MIT License
# Copyright (c) 2016 Francisco Lourenço & Daniel Wehner
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -g __done_version 1.10.0
function __done_get_focused_window_id
if type -q lsappinfo
lsappinfo info -only bundleID (lsappinfo front) | cut -d '"' -f4
else if test -n "$SWAYSOCK"
and type -q jq
swaymsg --type get_tree | jq '.. | objects | select(.focused == true) | .id'
else if type -q xprop
and test -n "$DISPLAY"
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
end
end
function __done_is_tmux_window_active
set -q fish_pid; or set -l fish_pid %self
not tmux list-panes -a -F "#{session_attached} #{window_active} #{pane_pid}" | string match -q "1 0 $fish_pid"
end
function __done_is_process_window_focused
# Return false if the window is not focused
if test $__done_initial_window_id != (__done_get_focused_window_id)
return 1
end
# If inside a tmux session, check if the tmux window is focused
if type -q tmux
and test -n "$TMUX"
__done_is_tmux_window_active
return $status
end
return 0
end
# verify that the system has graphical capabilites before initializing
if test -z "$SSH_CLIENT" # not over ssh
and count (__done_get_focused_window_id) > /dev/null # is able to get window id
set -g __done_initial_window_id ''
set -q __done_min_cmd_duration; or set -g __done_min_cmd_duration 5000
set -q __done_exclude; or set -g __done_exclude 'git (?!push|pull)'
set -q __done_notify_sound; or set -g __done_notify_sound 0
function __done_started --on-event fish_preexec
set __done_initial_window_id (__done_get_focused_window_id)
end
function __done_ended --on-event fish_prompt
set -l exit_status $status
# backwards compatibilty for fish < v3.0
set -q cmd_duration; or set -l cmd_duration $CMD_DURATION
if test $cmd_duration
and test $cmd_duration -gt $__done_min_cmd_duration # longer than notify_duration
and not __done_is_process_window_focused # process pane or window not focused
and not string match -qr $__done_exclude $history[1] # don't notify on git commands which might wait external editor
# Store duration of last command
set -l humanized_duration (echo "$cmd_duration" | humanize_duration)
set -l title "Done in $humanized_duration"
set -l wd (pwd | sed "s,^$HOME,~,")
set -l message "$wd/ $history[1]"
set -l sender $__done_initial_window_id
if test $exit_status -ne 0
set title "Failed ($exit_status) after $humanized_duration"
end
if set -q __done_notification_command
eval $__done_notification_command
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else if type -q terminal-notifier # https://github.com/julienXX/terminal-notifier
if test "$__done_notify_sound" -eq 1
terminal-notifier -message "$message" -title "$title" -sender "$__done_initial_window_id" -sound default
else
terminal-notifier -message "$message" -title "$title" -sender "$__done_initial_window_id"
end
else if type -q osascript # AppleScript
osascript -e "display notification \"$message\" with title \"$title\""
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else if type -q notify-send # Linux notify-send
set -l urgency
if test $exit_status -ne 0
set urgency "--urgency=critical"
end
notify-send $urgency --icon=terminal --app-name=fish "$title" "$message"
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else if type -q notify-desktop # Linux notify-desktop
set -l urgency
if test $exit_status -ne 0
set urgency "--urgency=critical"
end
notify-desktop $urgency --icon=terminal --app-name=fish "$title" "$message"
if test "$__done_notify_sound" -eq 1
echo -e "\a" # bell sound
end
else # anything else
echo -e "\a" # bell sound
end
end
end
end
function __done_uninstall -e done_uninstall
# Erase all __done_* functions
functions -e __done_ended
functions -e __done_started
functions -e __done_get_focused_window_id
functions -e __done_is_tmux_window_active
functions -e __done_is_process_window_focused
# Erase __done variables
set -e __done_version
end

View File

@ -5,4 +5,3 @@ oh-my-fish/plugin-direnv
joseluisq/gitnow
fishpkg/fish-git-util
rafaelrinaldi/pure
franciscolourenco/done

View File

@ -1,3 +0,0 @@
function 3screens
~/.screenlayout/three.sh
end

View File

@ -1,167 +0,0 @@
#!/bin/bash
# archey-osx 1.5.2 (https://github.com/obihann/archey-osx/)
# test to see if bash supports arrays
arraytest[0]='test' || (echo 'Error: Arrays are not supported in this version of
bash.' && exit 2)
# Detect the packager.
#if [ -x /usr/local/bin/brew ]; then
#detectedpackager=homebrew
#elif command -v port >/dev/null; then
#detectedpackager=macports
#else
#detectedpackager=none
#fi
# Get the command line options
opt_nocolor=f
opt_force_color=f
opt_offline=f
for arg in "$@"
do
case "${arg}" in
-p|--packager)
packager=$detectedpackager
;;
-m|--macports)
packager=macports
;;
-b|--nocolor)
opt_nocolor=t
;;
-c|--color)
opt_nocolor=f
opt_force_color=t
;;
-o|--offline)
opt_offline=t
;;
-h|--help)
echo "Archey OS X 1.5.2"
echo
echo "Usage: $0 [options]"
echo
echo " -p --packager Use auto detected package system (default packager: ${detectedpackager})."
echo " -m --macports Force use MacPorts as package system."
echo " -b --nocolor Turn color off."
echo " -c --color Force the color on (overrides --nocolor)."
echo " -o --offline Disable the IP address check."
exit 0
;;
*)
echo "Unknown argument: $1" 1>&2
echo "For help, use: $0 --help" 1>&2
exit 1
;;
esac
done
# System Variables
user=$(whoami)
hostname=$(hostname | sed 's/.local//g')
#if [[ "${opt_offline}" = f ]]; then
#ipfile="${HOME}/.archey-ip"
#if [ -a "$ipfile" ] && test `find "$ipfile" -mmin -360`; then
#while read -r line; do
#ip="$line"
#done < "$ipfile"
#else
#ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
#echo $ip > "$ipfile"
#fi
#fi
distro="OS X $(sw_vers -productVersion)"
kernel=$(uname)
uptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
shell="$SHELL"
terminal="$TERM ${TERM_PROGRAM//_/ }"
cpu=$(sysctl -n machdep.cpu.brand_string)
#battery=$(ioreg -c AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
battery=$(pmset -g batt | xargs | egrep "\d+%" -o)
# removes (R) and (TM) from the CPU name so it fits in a standard 80 window
cpu=$(echo "$cpu" | awk '$1=$1' | sed 's/([A-Z]\{1,2\})//g')
ram="$(( $(sysctl -n hw.memsize) / 1024 ** 3 )) GB"
disk=$(df | head -2 | tail -1 | awk '{print $5}')
# Set up colors if:
# * stdout is a tty
# * the user hasn't turned it off
# * or if we're forcing color
if [[ ( -t 1 && "${opt_nocolor}" = f) || "${opt_force_color}" = t ]]
then
RED=$(tput setaf 1 2>/dev/null)
GREEN=$(tput setaf 2 2>/dev/null)
YELLOW=$(tput setaf 3 2>/dev/null)
BLUE=$(tput setaf 4 2>/dev/null)
PURPLE=$(tput setaf 5 2>/dev/null)
textColor=$(tput setaf 6 2>/dev/null)
normal=$(tput sgr0 2>/dev/null)
fi
case "${packager}" in
homebrew)
packagehandler=$(brew list -1 | wc -l | awk '{print $1 }')
;;
macports)
packagehandler=$(port installed | wc -l | awk '{print $1 }')
;;
*)
packagehandler=0
;;
esac
fieldlist[${#fieldlist[@]}]="${textColor}User:${normal} ${user}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Hostname:${normal} ${hostname}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Distro:${normal} ${distro}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Kernel:${normal} ${kernel}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Uptime:${normal} ${uptime}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Shell:${normal} ${shell}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Terminal:${normal} ${terminal}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Terminal Size:${normal} $(tput lines) x $(tput cols)"
#if [ ${packagehandler} -ne 0 ]; then
#fieldlist[${#fieldlist[@]}]="${textColor}Packages:${normal} ${packagehandler}${normal}"
#fi
fieldlist[${#fieldlist[@]}]="${textColor}CPU:${normal} ${cpu}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Memory:${normal} ${ram}${normal}"
fieldlist[${#fieldlist[@]}]="${textColor}Disk:${normal} ${disk}${normal}"
#if [ ! -z $battery ]; then
#fi
fieldlist[${#fieldlist[@]}]="${textColor}Battery:${normal} ${battery}${normal}"
#if [ "${opt_offline}" = f ]; then
#fieldlist[${#fieldlist[@]}]="${textColor}IP Address:${normal} ${ip}${normal}"
#fi
fieldlist[${#fieldlist[@]}]="${textColor}Date:${normal} $(date)${normal}"
logofile=${ARCHEY_LOGO_FILE:-"${HOME}/.config/archey-logo"}
if [ -a "$logofile" ]
then
source "$logofile"
else
# The ${foo# } is a cheat so that it lines up here as well
# as when run.
echo -e "
${GREEN# } ####### ${fieldlist[0]}
${GREEN# } ######## ${fieldlist[1]}
${GREEN# } ##### ${fieldlist[2]}
${GREEN# } ##### ${fieldlist[3]}
${YELLOW# } ###### ${fieldlist[4]}
${YELLOW# } ######## ${fieldlist[5]}
${RED# } ########### ${fieldlist[6]}
${RED# } ##### ##### ${fieldlist[7]}
${RED# } ##### ##### ${fieldlist[8]}
${PURPLE# } ##### ##### ${fieldlist[9]}
${PURPLE# } ##### ##### ## ${fieldlist[10]}
${BLUE# } ##### ########## ${fieldlist[11]}
${BLUE# } ##### ####### ${fieldlist[12]}
${normal}
"
fi

View File

@ -1,5 +0,0 @@
function dbag
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Tap Action" 0
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics ClickPad" 0
setxkbmap -option "caps:escape"
end

View File

@ -1,5 +0,0 @@
function dces
pushd ~/src/elation/hippo-sync
docker-compose $argv
popd
end

View File

@ -1,5 +0,0 @@
function dcesdj
pushd ~/src/elation/hippo-sync
docker-compose exec hippo django-admin $argv
popd
end

View File

@ -1,7 +0,0 @@
function doomu
cd ~/.emacs.d/
./bin/doom clean
./bin/doom upgrade --no-ask
./bin/doom update --no-ask
./bin/doom compile :core lang/python --no-ask
end

View File

@ -0,0 +1,3 @@
function pe
~/.screenlayout/prometheus-ext.sh
end

View File

@ -1,19 +0,0 @@
function humanize_duration -d "Make a time interval human readable"
command awk '
function hmTime(time, stamp) {
split("h:m:s:ms", units, ":")
for (i = 2; i >= -1; i--) {
if (t = int( i < 0 ? time % 1000 : time / (60 ^ i * 1000) % 60 )) {
stamp = stamp t units[sqrt((i - 2) ^ 2) + 1] " "
}
}
if (stamp ~ /^ *$/) {
return "0ms"
}
return substr(stamp, 1, length(stamp) - 1)
}
{
print hmTime($0)
}
'
end

View File

@ -1,3 +0,0 @@
function k
kubectl $argv
end

View File

@ -1,3 +0,0 @@
function nconn
nmcli device wifi connect $argv
end

View File

@ -1,4 +1,4 @@
function off
set -x DISPLAY :0
xset -dpms s on
xset -dpms s on
end

View File

@ -1,4 +1,4 @@
function on
set -x DISPLAY :0
xset -dpms s off
xset -dpms s off
end

View File

@ -0,0 +1,3 @@
function pe
~/.screenlayout/prometheus-ext.sh
end

View File

@ -1,3 +0,0 @@
function rechunk
brew services restart chunkwm
end

View File

@ -1,8 +0,0 @@
function update
pushd ~/dotfiles
git stash
git pull --rebase
fisher
git stash apply
popd
end

View File

@ -1,11 +0,0 @@
# Function to filter through recently used directories
function zd --argument-names 'name'
set -l zd_command "command fasd -Rdl $name 2> /dev/null"
fish -c "$zd_command" | __fzfcmd -1 -0 --no-sort -m | read -la select
if test ! (count $select) -eq 0
cd "$select"
end
end
# Set above function to even shorter j alias
alias j "zd"