diff --git a/extras/automatic_tmux_login.sh b/extras/automatic_tmux_login.sh new file mode 100644 index 0000000..ab9b8a1 --- /dev/null +++ b/extras/automatic_tmux_login.sh @@ -0,0 +1,10 @@ +#_tmux_sourced=1 exec tmux +if [[ -z $TMUX ]] && [[ -n $SSH_TTY ]]; then + session=tmux + + if tmux has-session -t "$session" 2>/dev/null; then + exec tmux attach-session -t "$session" + else + exec tmux new-session -s "$session" + fi +fi diff --git a/extras/sort_timings.zsh b/extras/sort_timings.zsh new file mode 100755 index 0000000..f7f9332 --- /dev/null +++ b/extras/sort_timings.zsh @@ -0,0 +1,50 @@ +#!/usr/bin/env zsh +# Reads output from zprof. +# Usage: +# 1. add the following to the beginning of your zshrc +# if [[ -n $profiling ]]; then +# zmodload zsh/zprof +# zmodload zsh/datetime +# setopt PROMPT_SUBST +# PS4='+$EPOCHREALTIME %N:%i> ' +# +# logfile=$(mktemp zsh_profile.XXXXXXXX) +# echo "Logging to $logfile" +# exec 3>&2 2>$logfile +# +# setopt XTRACE +# fi +# 2. add this to the end of your zshrc +# if [[ -n $profiling ]]; then +# unsetopt XTRACE +# exec 2>&3 3>&- +# zprof +# fi +# 3. zsh -i -c exit +# 4. sort_timings.zsh zsh_profile.* # or use the newly-created file + +typeset -a lines +typeset -i prev_time=0 +typeset prev_command + +while read line; do + if [[ $line =~ '^.*\+([0-9]{10})\.([0-9]{6})[0-9]* (.+)' ]]; then + integer this_time=$match[1]$match[2] + + if [[ $prev_time -gt 0 ]]; then + time_difference=$(( $this_time - $prev_time )) + lines+="$time_difference $prev_command" + fi + + prev_time=$this_time + + local this_command=$match[3] + if [[ ${#this_command} -le 80 ]]; then + prev_command=$this_command + else + prev_command="${this_command}..." + fi + fi +done < ${1:-/dev/stdin} + +print -l ${(@On)lines} # | sort -h | vim - diff --git a/extras/sshrc b/extras/sshrc new file mode 100644 index 0000000..d5da6bd --- /dev/null +++ b/extras/sshrc @@ -0,0 +1,4 @@ +#!/bin/bash +if test "$SSH_AUTH_SOCK" ; then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock +fi diff --git a/extras/zprofile b/extras/zprofile new file mode 100644 index 0000000..bc7d4c4 --- /dev/null +++ b/extras/zprofile @@ -0,0 +1,15 @@ +# Make sure SSH_AUTH_sock is symlinked +if test "$SSH_AUTH_SOCK" ; then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock +fi + +#_tmux_sourced=1 exec tmux +if [[ -z $TMUX ]] && [[ -n $SSH_TTY ]]; then + session=tmux + + if tmux has-session -t "$session" 2>/dev/null; then + exec tmux attach-session -t "$session" + else + exec tmux new-session -s "$session" + fi +fi diff --git a/extras/zprofile_chapek.zsh b/extras/zprofile_chapek.zsh new file mode 100644 index 0000000..d64b6ee --- /dev/null +++ b/extras/zprofile_chapek.zsh @@ -0,0 +1,18 @@ + +# Make sure SSH_AUTH_sock is symlinked +if test "$SSH_AUTH_SOCK" ; then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock +fi + +#_tmux_sourced=1 exec tmux +if [[ -z $TMUX ]] && [[ -n $SSH_TTY ]]; then + set -x + session=tmux + + if tmux has-session -t "$session" 2>/dev/null; then + exec tmux attach-session -t "$session" + else + tmux new-session -s "$session" + exec tmux attach-session -t "$session" + fi +fi