├── .gitignore ├── .gitmodules ├── .tmux-powerline ├── AUTHORS ├── LICENSE ├── README.md ├── config.sh ├── img │ ├── full.png │ ├── left-status.png │ ├── right-status.png │ ├── right-status_no_mail.png │ ├── right-status_no_mpd.png │ └── right-status_weather_battery.png ├── lib.sh ├── segments │ ├── Makefile │ ├── apple_mail_count.sh │ ├── battery.sh │ ├── battery_mac.sh │ ├── cpu.sh │ ├── date_day.sh │ ├── date_full.sh │ ├── hostname.sh │ ├── lan_ip.sh │ ├── load.sh │ ├── maildir_count.sh │ ├── np_audacious.sh │ ├── np_banshee.sh │ ├── np_itunes_mac.sh │ ├── np_mpd.c │ ├── np_mpd.sh │ ├── np_rhythmbox.sh │ ├── np_spotify_linux_native.sh │ ├── np_spotify_linux_wine.sh │ ├── np_spotify_mac.script │ ├── np_spotify_mac.sh │ ├── pwd.sh │ ├── time.sh │ ├── tmux_session_info.sh │ ├── uptime.sh │ ├── username.sh │ ├── vcs_branch.sh │ ├── wan_ip.sh │ ├── weather.sh │ ├── xkb_layout.c │ └── xkb_layout.sh ├── status-left.sh └── status-right.sh ├── .tmux.conf ├── LICENSE.md ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .tmux/plugins/* 2 | .tmux/resurrect 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule ".tmux/plugins/tpm"] 2 | path = .tmux/plugins/tpm 3 | url = https://github.com/tmux-plugins/tpm 4 | -------------------------------------------------------------------------------- /.tmux-powerline/AUTHORS: -------------------------------------------------------------------------------- 1 | Please append you name/nick here when you have contributed with something! 2 | 3 | Erik Westrup 4 | Suvash Thapaliya 5 | Erik Jansson 6 | Yuku Takahashi 7 | Oscar Olsson 8 | Ryo Katsuma 9 | negipo 10 | Sina Siadat 11 | Vivien Leroy 12 | Gino Lucero 13 | Derek Ashley Thomas 14 | -------------------------------------------------------------------------------- /.tmux-powerline/LICENSE: -------------------------------------------------------------------------------- 1 | tmux-powerline - Statusbar configuration for tmux that looks like vim-powerline and consist of dynamic segments. 2 | 3 | Copyright (c) 2012, see AUTHORS 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | 14 | http://opensource.org/licenses/BSD-3-Clause 15 | -------------------------------------------------------------------------------- /.tmux-powerline/README.md: -------------------------------------------------------------------------------- 1 | # tmux-powerline 2 | This is a set of scripts (segments) for making a nice and dynamic tmux statusbar where elements can come and disappears depending on events. I really like the look of [Lokaltog/vim-powerline](https://github.com/Lokaltog/vim-powerline) and I decided I wanted the same for tmux. 3 | 4 | The following segments exists for now: 5 | * LAN & WAN IP addresses. 6 | * Now Playing for MPD, Spotify (GNU/Linux native or wine, OS X), iTunes (OS X), Rhythmbox, Banshee and Audacious. 7 | * New mail count for Maildir and Apple Mail. 8 | * GNU/Linux and Macintosh OS X battery status (uses [richo/dotfiles/bin/battery](https://github.com/richoH/dotfiles/blob/master/bin/battery)). 9 | * Weather in Celsius, Fahrenheit and Kelvin using Google's weather API. 10 | * System load, cpu usage and uptime. 11 | * Git, SVN and Mercurial branch in CWD. 12 | * Date and time. 13 | * Hostname. 14 | * tmux info. 15 | * CWD in pane. 16 | * Current X keyboard layout. 17 | 18 | Check [segments/](https://github.com/erikw/tmux-powerline/tree/master/segments) for more undocumented segments and details. 19 | 20 | # Screenshots 21 | **Full screenshot** 22 | 23 | ![Full screenshot](https://github.com/erikw/tmux-powerline/raw/master/img/full.png) 24 | 25 | **left-status** 26 | 27 | Current tmux session, window and pane, hostname and LAN & WAN IP address. 28 | 29 | ![left-status](https://github.com/erikw/tmux-powerline/raw/master/img/left-status.png) 30 | 31 | **right-status** 32 | 33 | New mails, now playing, average load, weather, date and time. 34 | 35 | ![right-status](https://github.com/erikw/tmux-powerline/raw/master/img/right-status.png) 36 | 37 | Now I've read my inbox so the mail segment disappears! 38 | 39 | ![right-status, no mail](https://github.com/erikw/tmux-powerline/raw/master/img/right-status_no_mail.png) 40 | 41 | After pausing the music there's no need for showing NP anymore. Also the weather has become much nicer! 42 | 43 | ![right-status, no mpd](https://github.com/erikw/tmux-powerline/raw/master/img/right-status_no_mpd.png) 44 | 45 | Remaining battery. 46 | 47 | ![right-status, weather and battery](https://github.com/erikw/tmux-powerline/raw/master/img/right-status_weather_battery.png) 48 | 49 | # Requirements 50 | Requirements for the lib to work are: 51 | 52 | * Recent tmux version 53 | * `bash --version` >= 4.0 54 | * A patched font. Follow instructions at [Lokaltog/vim-powerline/fontpatcher](https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher). 55 | 56 | ## Segment Requirements 57 | Requirements for some segments. You only need to fullfill the requirements for those segments you want to use. 58 | 59 | * WAN IP: curl 60 | * MPD now playing: [libmpdclient](http://sourceforge.net/projects/musicpd/files/libmpdclient/) 61 | * xkb_layout: X11, XKB 62 | 63 | ## OS X specific requirements 64 | 65 | **You still need to follow the first part of these instructions even if you are running zsh or something else as your default shell!** 66 | 67 | tmux-powerline uses associative arrays in bash, which were added in bash version 4.0. OS X Lion ships with an antiquated version of bash ( run 68 | `bash --version` to see your version). In order to use tmux-powerline, you need to install a newer version of bash, fortunately, 69 | [brew](http://mxcl.github.com/homebrew/) makes this very easy. If you don't have brew, [install it](https://github.com/mxcl/homebrew/wiki/installation). 70 | Then follow these steps: 71 | 72 | ```bash 73 | $ brew install bash 74 | ``` 75 | 76 | **If you're using something other than bash (or if you don't want this newer version of bash as your default shell) you should be done now**. If something 77 | seems broken, try following the last two steps and see if it helps: 78 | 79 | ```bash 80 | $ sudo bash -c "echo /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash >> /private/etc/shells" 81 | $ chsh -s /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash 82 | ``` 83 | 84 | The first command installs bash through brew, the second registers the new shell with the system and the third changes to the new shell for your user. 85 | If you later upgrade bash through brew, don't forget to do the last two steps again with the new version number. After doing the above and restarting your 86 | terminal, running `echo $SHELL` should result in the following: 87 | 88 | ```bash 89 | $ echo $SHELL 90 | /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash 91 | ``` 92 | 93 | # Installation 94 | Just check out the repository with: 95 | 96 | ```console 97 | $ cd ~/some/path/ 98 | $ git clone git://github.com/erikw/tmux-powerline.git 99 | ``` 100 | 101 | Now edit your `~/.tmux.conf` to use the scripts: 102 | 103 | 104 | ```vim 105 | set-option -g status on 106 | set-option -g status-interval 2 107 | set-option -g status-utf8 on 108 | set-option -g status-justify "centre" 109 | set-option -g status-left-length 60 110 | set-option -g status-right-length 90 111 | set-option -g status-left "#(~/path/to/tmux-powerline/status-left.sh)" 112 | set-option -g status-right "#(~/path/to/tmux-powerline/status-right.sh)" 113 | ``` 114 | 115 | Set the maximum lengths to something that suits your configuration of segments and size of terminal (the maximum segments length will be handled better in the future). Don't forget to change the PLATFORM variable in `config.sh` or your `~/.bashrc` to reflect your operating system of choice. 116 | 117 | Also I recommend you to use the [tmux-colors-solarized](https://github.com/seebi/tmux-colors-solarized) theme (as well as solarized for [everything else](http://ethanschoonover.com/solarized) :)): 118 | 119 | ```bash 120 | source ~/path/to/tmux-colors-solarized/tmuxcolors.conf 121 | ``` 122 | Some segments e.g. cwd and cvs_branch needs to find the current working directory of the active pane. To achive this we let tmux save the path each time the bash prompt is displayed. Put this in your `~/.bashrc` or where you define you PS1 variable (I use and source `~/.bash_ps1`): 123 | 124 | ```bash 125 | PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")' 126 | ``` 127 | 128 | # Configuration 129 | 130 | Edit the two status scripts to suit you needs. A number of common segments are included that covers some general functions like time, date, battery etc. The segments can be moved around and does not needs to be in the order (or same file) as they are now. It should be quite easy to add you own segments. 131 | 132 | ```console 133 | $ $EDITOR ~/path/to/tmux-powerline/status-left.sh 134 | $ $EDITOR ~/path/to/tmux-powerline/status-right.sh 135 | ``` 136 | 137 | 138 | Here is one segment configuration explained so you'll know how to make you own. 139 | 140 | ```bash 141 | declare -A time # The name of the array. 142 | time+=(["script"]="${segments_path}/time.sh") # mandatory, the shell script producing the output text to be shown. 143 | time+=(["foreground"]="colour136") # mandatory, the text foreground color. 144 | time+=(["background"]="colour235") # mandatory, the text background color. 145 | time+=(["separator"]="${separator_left_thin}") # mandatory, the separator to use. Can be (as described in `lib.sh`) any of separator_(left|right)_(bold|thin) 146 | time+=(["separator_fg"]="default") # optional, overrides the default blending coloring of the separator with a custom colored foreground. 147 | register_segment "time" # Registers the name of the array declared above. 148 | ``` 149 | # Hacking 150 | 151 | This project can only gain positively from contributions. Fork today and make your own enhancments and segments to share back! 152 | -------------------------------------------------------------------------------- /.tmux-powerline/config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Cofigurations for tmux-powerline. 3 | 4 | if [ -z "$PLATFORM" ]; then 5 | # You platform \in {linux,bsd,mac}. 6 | export PLATFORM="linux" 7 | fi 8 | 9 | if [ -z "$USE_PATCHED_FONT" ]; then 10 | # Useage of patched font for symbols. true or false. 11 | export USE_PATCHED_FONT="true" 12 | fi 13 | -------------------------------------------------------------------------------- /.tmux-powerline/img/full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbnicolai/tmux/a4aed81545c7f444024d61cbb724e779868a538a/.tmux-powerline/img/full.png -------------------------------------------------------------------------------- /.tmux-powerline/img/left-status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbnicolai/tmux/a4aed81545c7f444024d61cbb724e779868a538a/.tmux-powerline/img/left-status.png -------------------------------------------------------------------------------- /.tmux-powerline/img/right-status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbnicolai/tmux/a4aed81545c7f444024d61cbb724e779868a538a/.tmux-powerline/img/right-status.png -------------------------------------------------------------------------------- /.tmux-powerline/img/right-status_no_mail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbnicolai/tmux/a4aed81545c7f444024d61cbb724e779868a538a/.tmux-powerline/img/right-status_no_mail.png -------------------------------------------------------------------------------- /.tmux-powerline/img/right-status_no_mpd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbnicolai/tmux/a4aed81545c7f444024d61cbb724e779868a538a/.tmux-powerline/img/right-status_no_mpd.png -------------------------------------------------------------------------------- /.tmux-powerline/img/right-status_weather_battery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbnicolai/tmux/a4aed81545c7f444024d61cbb724e779868a538a/.tmux-powerline/img/right-status_weather_battery.png -------------------------------------------------------------------------------- /.tmux-powerline/lib.sh: -------------------------------------------------------------------------------- 1 | # Library functions. 2 | 3 | segments_dir="segments" 4 | declare entries 5 | 6 | if [ -n "$USE_PATCHED_FONT" -a "$USE_PATCHED_FONT" == "true" ]; then 7 | # Separators (patched font required) 8 | separator_left_bold="⮂" 9 | separator_left_thin="⮃" 10 | separator_right_bold="⮀" 11 | separator_right_thin="⮁" 12 | else 13 | # Alternative separators in the normal Unicode table. 14 | separator_left_bold="◀" 15 | separator_left_thin="❮" 16 | separator_right_bold="▶" 17 | separator_right_thin="❯" 18 | fi 19 | 20 | # Make sure that grep does not emit colors. 21 | export GREP_OPTIONS="--color=never" 22 | 23 | # Register a segment. 24 | register_segment() { 25 | segment_name="$1" 26 | entries[${#entries[*]}]="$segment_name" 27 | 28 | } 29 | 30 | print_status_line_right() { 31 | local prev_bg="colour235" 32 | for entry in ${entries[*]}; do 33 | local script=$(eval echo \${${entry}["script"]}) 34 | local foreground=$(eval echo \${${entry}["foreground"]}) 35 | local background=$(eval echo \${${entry}["background"]}) 36 | local separator=$(eval echo \${${entry}["separator"]}) 37 | local separator_fg="" 38 | if [ $(eval echo \${${entry}["separator_fg"]+_}) ];then 39 | separator_fg=$(eval echo \${${entry}["separator_fg"]}) 40 | fi 41 | 42 | local output=$(${script}) 43 | if [ -z "$output" ]; then 44 | continue 45 | fi 46 | __ui_right "$prev_bg" "$background" "$foreground" "$separator" "$separator_fg" 47 | echo -n "$output" 48 | prev_bg="$background" 49 | done 50 | # End in a clean state. 51 | echo "#[default]" 52 | } 53 | 54 | first_segment_left=1 55 | print_status_line_left() { 56 | prev_bg="colour148" 57 | for entry in ${entries[*]}; do 58 | local script=$(eval echo \${${entry}["script"]}) 59 | local foreground=$(eval echo \${${entry}["foreground"]}) 60 | local background=$(eval echo \${${entry}["background"]}) 61 | local separator=$(eval echo \${${entry}["separator"]}) 62 | local separator_fg="" 63 | if [ $(eval echo \${${entry}["separator_fg"]+_}) ];then 64 | separator_fg=$(eval echo \${${entry}["separator_fg"]}) 65 | fi 66 | 67 | local output=$(${script}) 68 | if [ -z "$output" ]; then 69 | continue 70 | fi 71 | __ui_left "$prev_bg" "$background" "$foreground" "$separator" "$separator_fg" 72 | echo -n "$output" 73 | prev_bg="$background" 74 | if [ "$first_segment_left" -eq "1" ]; then 75 | first_segment_left=0 76 | fi 77 | done 78 | __ui_left "colour235" "colour235" "red" "$separator_right_bold" "$prev_bg" 79 | 80 | # End in a clean state. 81 | echo "#[default]" 82 | } 83 | 84 | #Internal printer for right. 85 | __ui_right() { 86 | local bg_left="$1" 87 | local bg_right="$2" 88 | local fg_right="$3" 89 | local separator="$4" 90 | local separator_fg 91 | if [ -n "$5" ]; then 92 | separator_fg="$5" 93 | else 94 | separator_fg="$bg_right" 95 | fi 96 | echo -n " #[fg=${separator_fg}, bg=${bg_left}]${separator}#[fg=${fg_right},bg=${bg_right}] " 97 | } 98 | 99 | # Internal printer for left. 100 | __ui_left() { 101 | local bg_left="$1" 102 | local bg_right="$2" 103 | local fg_right="$3" 104 | local separator 105 | if [ "$first_segment_left" -eq "1" ]; then 106 | separator="" 107 | else 108 | separator="$4" 109 | fi 110 | 111 | local separator_bg 112 | if [ -n "$5" ]; then 113 | bg_left="$5" 114 | separator_bg="$bg_right" 115 | else 116 | separator_bg="$bg_right" 117 | fi 118 | 119 | if [ "$first_segment_left" -eq "1" ]; then 120 | echo -n "#[bg=${bg_right}]" 121 | fi 122 | 123 | echo -n " #[fg=${bg_left}, bg=${separator_bg}]${separator}#[fg=${fg_right},bg=${bg_right}]" 124 | 125 | if [ "$first_segment_left" -ne "1" ]; then 126 | echo -n " " 127 | fi 128 | } 129 | 130 | # Get the current path in the segment. 131 | get_tmux_cwd() { 132 | local env_name=$(tmux display -p "TMUXPWD_#I_#P") 133 | local env_val=$(tmux show-environment | grep "$env_name") 134 | # The version below is still quite new for tmux. Uncommented this in the future :-) 135 | #local env_val=$(tmux show-environment "$env_name" 2>&1) 136 | 137 | if [[ ! $env_val =~ "unknown variable" ]]; then 138 | local tmux_pwd=$(echo "$env_val" | grep -PZo "(?<==).*$") 139 | echo "$tmux_pwd" 140 | fi 141 | } 142 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/Makefile: -------------------------------------------------------------------------------- 1 | # Build the small MPD NP program. 2 | # Enable debug printing with $ make -e DEBUG=1 3 | DEBUG=0 4 | CC = $(shell hash clang 2>/dev/null && echo clang || echo gcc) 5 | CFLAGS = -O3 -Wall -std=c99 -I /usr/include/ -D DEBUG=${DEBUG} 6 | LDLIBS = -lmpdclient 7 | XKB_LAYOUT_LDLIBS= -lX11 8 | 9 | .PHONY: all clean 10 | 11 | all: np_mpd xkb_layout 12 | 13 | xkb_layout: xkb_layout.c 14 | $(CC) $(CFLAGS) $(LDFLAGS) $< $(XKB_LAYOUT_LDLIBS) -o $@ 15 | 16 | clean: 17 | $(RM) np_mpd 18 | $(RM) xkb_layout 19 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/apple_mail_count.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env osascript 2 | # Returns the number of unread mails in the INBOX of Apple Mail. 3 | 4 | tell application "System Events" 5 | set process_list to (name of every process) 6 | end tell 7 | 8 | if process_list contains "Mail" then 9 | tell application "Mail" 10 | if unread count of inbox > 0 then 11 | set a to " " & unread count of inbox 12 | end if 13 | end tell 14 | end if 15 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/battery.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # LICENSE This code is not under the same license as the rest of the project as it's "stolen". It's cloned from https://github.com/richoH/dotfiles/blob/master/bin/battery and just some modifications are done so it works for my laptop. Check that URL for more recent versions. 3 | 4 | #CUTE_BATTERY_INDICATOR="true" 5 | 6 | HEART_FULL=♥ 7 | HEART_EMPTY=♡ 8 | [ -z "$NUM_HEARTS" ] && 9 | NUM_HEARTS=5 10 | 11 | cutinate() 12 | { 13 | perc=$1 14 | inc=$(( 100 / $NUM_HEARTS)) 15 | 16 | 17 | for i in `seq $NUM_HEARTS`; do 18 | if [ $perc -lt 100 ]; then 19 | echo $HEART_EMPTY 20 | else 21 | echo $HEART_FULL 22 | fi 23 | perc=$(( $perc + $inc )) 24 | done 25 | } 26 | 27 | linux_get_bat () 28 | { 29 | bf=$(cat $BAT_FULL) 30 | bn=$(cat $BAT_NOW) 31 | echo $(( 100 * $bn / $bf )) 32 | } 33 | 34 | freebsd_get_bat () 35 | { 36 | echo "$(sysctl -n hw.acpi.battery.life)" 37 | 38 | } 39 | 40 | # Do with grep and awk unless too hard 41 | 42 | # TODO Identify which machine we're on from teh script. 43 | 44 | battery_status() 45 | { 46 | case $(uname -s) in 47 | "Linux") 48 | BATPATH=/sys/class/power_supply/BAT0 49 | if [ ! -f $BATPATH ]; then 50 | BATPATH=/sys/class/power_supply/BAT1 51 | fi 52 | STATUS=$BATPATH/status 53 | BAT_FULL=$BATPATH/charge_full 54 | if [ ! -r $BAT_FULL ]; then 55 | BAT_FULL=$BATPATH/energy_full 56 | fi 57 | BAT_NOW=$BATPATH/charge_now 58 | if [ ! -r $BAT_NOW ]; then 59 | BAT_NOW=$BATPATH/energy_now 60 | fi 61 | 62 | if [ "$1" = `cat $STATUS` -o "$1" = "" ]; then 63 | linux_get_bat 64 | fi 65 | ;; 66 | "FreeBSD") 67 | STATUS=`sysctl -n hw.acpi.battery.state` 68 | case $1 in 69 | "Discharging") 70 | if [ $STATUS -eq 1 ]; then 71 | freebsd_get_bat 72 | fi 73 | ;; 74 | "Charging") 75 | if [ $STATUS -eq 2 ]; then 76 | freebsd_get_bat 77 | fi 78 | ;; 79 | "") 80 | freebsd_get_bat 81 | ;; 82 | esac 83 | ;; 84 | "Darwin") 85 | case $1 in 86 | "Discharging") 87 | ext="No";; 88 | "Charging") 89 | ext="Yes";; 90 | esac 91 | 92 | ioreg -c AppleSmartBattery -w0 | \ 93 | grep -o '"[^"]*" = [^ ]*' | \ 94 | sed -e 's/= //g' -e 's/"//g' | \ 95 | sort | \ 96 | while read key value; do 97 | case $key in 98 | "MaxCapacity") 99 | export maxcap=$value;; 100 | "CurrentCapacity") 101 | export curcap=$value;; 102 | "ExternalConnected") 103 | if [ "$ext" != "$value" ]; then 104 | exit 105 | fi 106 | ;; 107 | "FullyCharged") 108 | if [ "$value" = "Yes" ]; then 109 | exit 110 | fi 111 | ;; 112 | esac 113 | if [[ -n "$maxcap" && -n $curcap ]]; then 114 | echo $(( 100 * $curcap / $maxcap )) 115 | break 116 | fi 117 | done 118 | esac 119 | } 120 | 121 | BATTERY_STATUS=`battery_status $1` 122 | [ -z "$BATTERY_STATUS" ] && exit 123 | 124 | if [ -n "$CUTE_BATTERY_INDICATOR" ]; then 125 | echo `cutinate $BATTERY_STATUS` 126 | else 127 | echo "${HEART_FULL} ${BATTERY_STATUS}%" 128 | #echo "⛁ ${BATTERY_STATUS}%" 129 | fi 130 | 131 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/battery_mac.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | HEART_CONNECTED=♥ 4 | HEART_DISCONNECTED=♡ 5 | 6 | case $(uname -s) in 7 | "Darwin") 8 | ioreg -c AppleSmartBattery -w0 | \ 9 | grep -o '"[^"]*" = [^ ]*' | \ 10 | sed -e 's/= //g' -e 's/"//g' | \ 11 | sort | \ 12 | while read key value; do 13 | case $key in 14 | "MaxCapacity") 15 | export maxcap=$value;; 16 | "CurrentCapacity") 17 | export curcap=$value;; 18 | "ExternalConnected") 19 | export extconnect=$value;; 20 | esac 21 | if [[ -n $maxcap && -n $curcap && -n $extconnect ]]; then 22 | if [[ "$curcap" == "$maxcap" ]]; then 23 | exit 24 | fi 25 | if [[ "$extconnect" == "Yes" ]]; then 26 | echo $HEART_CONNECTED $(( 100 * $curcap / $maxcap ))"%" 27 | else 28 | echo $HEART_DISCONNECTED $(( 100 * $curcap / $maxcap ))"%" 29 | fi 30 | break 31 | fi 32 | done 33 | esac 34 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/cpu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints the CPU usage: user% sys% idle. 3 | 4 | if [ "$PLATFORM" == "linux" ] ; then 5 | cpu_line=$(top -b -n 1 | grep "Cpu(s)" ) 6 | cpu_user=$(echo "$cpu_line" | grep -Po "(\d+(.\d+)?)(?=%?\s?(us(er)?))") 7 | cpu_system=$(echo "$cpu_line" | grep -Po "(\d+(.\d+)?)(?=%?\s?(sys?))") 8 | cpu_idle=$(echo "$cpu_line" | grep -Po "(\d+(.\d+)?)(?=%?\s?(id(le)?))") 9 | else 10 | cpus_line=$(top -l 1 | grep "CPU usage:" | sed 's/CPU usage: //') 11 | cpu_user=$(echo "$cpus_line" | awk '{print $1}' | sed 's/%//' ) 12 | cpu_system=$(echo "$cpus_line" | awk '{print $3}'| sed 's/%//' ) 13 | cpu_idle=$(echo "$cpus_line" | awk '{print $5}' | sed 's/%//' ) 14 | fi 15 | 16 | if [ -n "$cpu_user" ] && [ -n "$cpu_system" ] && [ -n "$cpu_idle" ]; then 17 | echo "${cpu_user}, ${cpu_system}, ${cpu_idle}" | awk -F', ' '{printf("%5.1f,%5.1f,%5.1f",$1,$2,$3)}' 18 | exit 0 19 | else 20 | exit 1 21 | fi 22 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/date_day.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints the name of the current day. 3 | date +"%a" 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/date_full.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Print the current date in ISO 8601 format. 3 | date +"%F" 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/hostname.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints the hostname 3 | hostname -s 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/lan_ip.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Prints the local network IP address for a staticly defined NIC or search for an IP address on all active NICs. 3 | 4 | # TODO fix the mac part so it also can search for interfaces like the Linux one can. 5 | if [ "$PLATFORM" == "mac" ]; then 6 | nic0="en0" 7 | nic1="en1" 8 | ip0=$(/sbin/ifconfig ${nic0} 2>/dev/null | grep 'inet ') 9 | ip1=$(/sbin/ifconfig ${nic1} 2>/dev/null | grep 'inet ' | cut -f2 -d' ') 10 | echo "ⓛ ${ip1}" 11 | else 12 | #nic=eth0 # Use this NIC. 13 | nic="USE_FIRST_FOUND" # Find the first IP address on all active NICs. 14 | 15 | if [ "$nic" == "USE_FIRST_FOUND" ]; then 16 | all_nics=$(ifconfig | cut -d ' ' -f1) 17 | nics=(${all_nics[@]//lo/}) # Remove lo interface. 18 | 19 | for nic in ${nics[@]}; do 20 | lan_ip=$(ifconfig "$nic" | grep -Po "(?<=inet addr:)[^ ]+") 21 | [ -n "$lan_ip" ] && break 22 | done 23 | else 24 | lan_ip=$(ifconfig "$nic" | grep -Po "(?<=inet addr:)[^ ]+") 25 | fi 26 | fi 27 | 28 | if [ -n "$lan_ip" ]; then 29 | 30 | #echo "Ⓛ ${lan_ip}" 31 | echo "ⓛ ${lan_ip}" 32 | exit 0 33 | else 34 | #echo "Ⓛ ${lan_ip}" 35 | exit 1 36 | fi 37 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/load.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Print the average load. 3 | uptime | cut -d "," -f 3- | cut -d ":" -f2 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/maildir_count.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Return the number of new mails in a maildir. 3 | 4 | inbox="$HOME/.mail/inbox/new" 5 | 6 | cd "$(dirname $0)" 7 | 8 | if [ ! -d "$inbox" ]; then 9 | exit 1 10 | fi 11 | 12 | nbr_new=$(ls "$inbox" | wc -l) 13 | 14 | if [ "$nbr_new" -gt "0" ]; then 15 | echo "✉ ${nbr_new}" 16 | fi 17 | 18 | exit 0; 19 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_audacious.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Print Audacious now playing. 3 | 4 | max_len=40 # Trim output to this length. 5 | 6 | # Check if audacious is playing and print that song. 7 | audacious_pid=$(pidof audacious) 8 | if [ -n "$audacious_pid" ]; then 9 | if $(audtool playback-playing); then 10 | echo "♫ $(audtool current-song)" | cut -c1-"$max_len" 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_banshee.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Prints now playing in Banshee. 3 | 4 | max_len=40 # Trim output to this length. 5 | 6 | # Check if banshee is playing and print that song. 7 | banshee_pid=$(pidof banshee) 8 | if [ -n "$banshee_pid" ]; then 9 | banshee_status=$(banshee --query-current-state 2> /dev/null) 10 | if [[ "$banshee_status" == "current-state: playing" ]]; then 11 | np=$(banshee --query-artist --query-title | cut -d ":" -f2 | sed -e 's/ *$//g' -e 's/^ *//g'| sed -e ':a;N;$!ba;s/\n/ - /g' ) 12 | echo "♫ ${np}" | cut -c1-"$max_len" 13 | fi 14 | fi 15 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_itunes_mac.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env osascript 2 | # Returns the current playing song in iTunes for OSX 3 | 4 | tell application "System Events" 5 | set process_list to (name of every process) 6 | end tell 7 | 8 | if process_list contains "iTunes" then 9 | tell application "iTunes" 10 | if player state is playing then 11 | set track_name to name of current track 12 | set artist_name to artist of current track 13 | # set album_name to album of current track 14 | set trim_length to 40 15 | set now_playing to "♫ " & artist_name & " - " & track_name 16 | if length of now_playing is less than trim_length then 17 | set now_playing_trim to now_playing 18 | else 19 | set now_playing_trim to characters 1 thru trim_length of now_playing as string 20 | end if 21 | end if 22 | end tell 23 | end if 24 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_mpd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef DEBUG 8 | #define DO_DEBUG DEBUG 9 | #else 10 | #define DO_DEBUG 0 11 | #endif 12 | #define DEBUG_PRINTF(...) do{ if (DO_DEBUG) { printf(__VA_ARGS__);} } while(0) 13 | 14 | /* Output the current song if MPD is in a playing state. The connection password, host and port is 15 | * specified like for mpc with environment variables 16 | * MPD_HOST=[password@]host 17 | * MPD_PORT=port 18 | * If they are empty they defaults to localhost on port 6600. 19 | */ 20 | int main(int argc, const char *argv[]) 21 | { 22 | char *mpd_host = NULL; 23 | char *mpd_password = NULL; 24 | unsigned int mpd_port = 0; 25 | 26 | char *mpd_host_m = NULL; 27 | char *mpd_password_m = NULL; 28 | 29 | const char *mpd_host_str = getenv("MPD_HOST"); 30 | if (mpd_host_str == NULL || strlen(mpd_host_str) == 0) { 31 | DEBUG_PRINTF("No envvar MPD_HOST set or empty. Using default value (localhost).\n"); 32 | mpd_host = "localhost"; 33 | } else { 34 | size_t mpd_host_len = strlen(mpd_host_str); 35 | char mpd_host_env[mpd_host_len + 1]; 36 | strncpy(mpd_host_env, mpd_host_str, mpd_host_len); 37 | mpd_host_env[mpd_host_len] = '\0'; 38 | 39 | char *pch = strtok(mpd_host_env, "@"); 40 | char *first = NULL; 41 | char *second = NULL; 42 | if (pch != NULL) { 43 | first = pch; 44 | } 45 | pch = strtok(NULL, "@"); 46 | if (pch != NULL) { 47 | second = pch; 48 | } 49 | 50 | if (first != NULL && second != NULL) { 51 | DEBUG_PRINTF("%s - %s\n", first, second); 52 | size_t first_len = strlen(first); 53 | size_t second_len = strlen(second); 54 | mpd_password_m = (char *) malloc(first_len + 1); 55 | mpd_host_m= (char *) malloc(second_len + 1); 56 | if (mpd_password_m == NULL || mpd_host_m == NULL) { 57 | DEBUG_PRINTF("Failed alloc password/host.\n"); 58 | return EXIT_FAILURE; 59 | } 60 | strncpy(mpd_password_m, first, first_len); 61 | mpd_password_m[first_len] = '\0'; 62 | strncpy(mpd_host_m, second, second_len); 63 | mpd_host_m[second_len] = '\0'; 64 | } else if (first != NULL) { 65 | DEBUG_PRINTF("%s\n", first); 66 | size_t first_len = strlen(first); 67 | mpd_host_m = (char *) malloc(first_len + 1); 68 | if (mpd_host_m == NULL ) { 69 | DEBUG_PRINTF("Failed alloc host.\n"); 70 | return EXIT_FAILURE; 71 | } 72 | strncpy(mpd_host_m, first, first_len); 73 | mpd_host_m[first_len] = '\0'; 74 | } 75 | } 76 | 77 | if (mpd_host_m != NULL) { 78 | mpd_host = mpd_host_m; 79 | } 80 | 81 | if (mpd_password_m != NULL) { 82 | mpd_password = mpd_password_m; 83 | } 84 | 85 | const char *mpd_port_env = getenv("MPD_PORT"); 86 | if (mpd_port_env == NULL || strlen(mpd_port_env) == 0) { 87 | DEBUG_PRINTF("No envvar MPD_PORT set or empty. Using default value (6600).\n"); 88 | mpd_port = 6600; 89 | } else { 90 | int mpd_port_m = atoi(mpd_port_env); 91 | if (mpd_port_m == 0) { 92 | DEBUG_PRINTF("Could not convert MPD_PORT to int.\n"); 93 | return EXIT_FAILURE; 94 | } else if (mpd_port_m < 0) { 95 | DEBUG_PRINTF("Negative port?!\n"); 96 | return EXIT_FAILURE; 97 | } else { 98 | mpd_port = mpd_port_m; 99 | DEBUG_PRINTF("Using port %i\n", mpd_port); 100 | } 101 | } 102 | 103 | 104 | struct mpd_connection *mpd_connection = mpd_connection_new(mpd_host, mpd_port, 1000); 105 | if (mpd_connection == NULL) { 106 | DEBUG_PRINTF("%s\n", "Could Not connect"); 107 | return EXIT_FAILURE; 108 | } 109 | 110 | if (mpd_password != NULL) { 111 | bool authenticated = mpd_run_password(mpd_connection, mpd_password); 112 | if (!authenticated) { 113 | DEBUG_PRINTF("Failed to authenticate.\n"); 114 | return EXIT_FAILURE; 115 | } 116 | } 117 | 118 | free(mpd_host_m); 119 | free(mpd_password_m); 120 | 121 | bool sent_status = mpd_send_status(mpd_connection); 122 | if (!sent_status) { 123 | DEBUG_PRINTF("Could not send status request."); 124 | return EXIT_FAILURE; 125 | } 126 | struct mpd_status *mpd_status = mpd_recv_status(mpd_connection); 127 | if (mpd_status == NULL) { 128 | DEBUG_PRINTF("Could not get mpd status.\n"); 129 | return EXIT_FAILURE; 130 | } 131 | 132 | enum mpd_state mpd_state = mpd_status_get_state(mpd_status); 133 | DEBUG_PRINTF("State: "); 134 | if (mpd_state == MPD_STATE_PLAY) { 135 | DEBUG_PRINTF("Playing."); 136 | } else if (mpd_state == MPD_STATE_PAUSE) { 137 | DEBUG_PRINTF("Paused."); 138 | } else if (mpd_state == MPD_STATE_UNKNOWN) { 139 | DEBUG_PRINTF("Unknown state."); 140 | } else if (mpd_state == MPD_STATE_STOP) { 141 | DEBUG_PRINTF("Stopped."); 142 | } 143 | DEBUG_PRINTF("\n"); 144 | 145 | if (mpd_state != MPD_STATE_PLAY) { 146 | // Nothing to do. 147 | mpd_status_free(mpd_status); 148 | mpd_connection_free(mpd_connection); 149 | return EXIT_SUCCESS; 150 | } 151 | 152 | int song_id = mpd_status_get_song_id(mpd_status); 153 | DEBUG_PRINTF("songid = %i\n", song_id); 154 | 155 | mpd_status_free(mpd_status); 156 | 157 | struct mpd_song *song = mpd_run_get_queue_song_id(mpd_connection, song_id); 158 | if (song == NULL) { 159 | DEBUG_PRINTF("Could not get song.\n"); 160 | return EXIT_FAILURE; 161 | } 162 | 163 | const char *song_artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0); 164 | if (song_artist == NULL) { 165 | DEBUG_PRINTF("Could not get song artist."); 166 | return EXIT_FAILURE; 167 | } 168 | 169 | const char *song_title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0); 170 | if (song_title == NULL) { 171 | DEBUG_PRINTF("Could not get song title."); 172 | return EXIT_FAILURE; 173 | } 174 | printf("%s - %s\n", song_artist, song_title); 175 | 176 | mpd_song_free(song); 177 | mpd_connection_free(mpd_connection); 178 | return EXIT_SUCCESS; 179 | } 180 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_mpd.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Print a simple line of NP in mpd. 3 | # 4 | # Previously I used something as simple as 5 | #mpc --format "%artist%\n%title%" | grep -Pzo '^(.|\n)*?(?=\[)' | sed ':a;N;$!ba;s/\n/ - /g' | sed 's/\s*-\s$//' | cut -c1-50 6 | # But I decided that I don't want any info about songs if there is nothing playing. Unfortunately I did not find a way of expressing this with mpc (I'm sure there is with idle/idleloop) but I did found a useful library: libmpdclient. I've used version 2.7 when developing my small program. Download the latest version here: http://sourceforge.net/projects/musicpd/files/libmpdclient/ 7 | 8 | max_len=40 # Trim output to this length. 9 | 10 | # Source MPD environment variables (MPD_HOST and MPD_PORT). I refactored out this from ~/.bashrc and source this file there as well. This is not needed if you run your MPD server at localhost, no password and on the standard port. 11 | if [ -f $HOME/.mpd_env ]; then 12 | source $HOME/.mpd_env 13 | fi 14 | 15 | cd "$(dirname $0)" 16 | 17 | if [ ! -x "np_mpd" ]; then 18 | make clean np_mpd &>/dev/null 19 | fi 20 | 21 | 22 | if [ -x "np_mpd" ]; then 23 | np=$(./np_mpd) 24 | if [ -n "$np" ]; then 25 | echo "♫ ${np}" | cut -c1-"$max_len" 26 | fi 27 | exit 0 28 | else 29 | exit 1 30 | fi 31 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_rhythmbox.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Prints now playing in Rhytmbox. 3 | 4 | max_len=40 # Trim output to this length. 5 | 6 | # Check if rhythmbox is playing and print that song. 7 | rhythmbox_pid=$(pidof rhythmbox) 8 | if [ -n "$rhythmbox_pid" ]; then 9 | rhythmbox_np=$(rhythmbox-client --no-start --print-playing) # Does not tell if the music is playing or paused. 10 | rhythmbox_paused=$(xwininfo -root -tree | grep "$rhythmbox_np" | sed "s/${rhythmbox_np}//;s/ //g" | cut -f2 -d '"') 11 | # TODO I cant produce the output "Not playing", using rhythmbox 2.97. 12 | #STATUS=$(rhythmbox-client --no-start --print-playing) 13 | if [[ "$rhythmbox_paused" != "(Paused)" ]]; then 14 | echo "♫ ${rhythmbox_np}" | cut -c1-"$max_len" 15 | fi 16 | fi 17 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_spotify_linux_native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Print Spotify now playing for GNU/Linux running the native client. 3 | # List functions and properties with 4 | #$ mdbus2 org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer 5 | 6 | max_len=40 # Trim output to this length. 7 | metadata=$(dbus-send --reply-timeout=42 --print-reply --dest=org.mpris.MediaPlayer2.spotify / org.freedesktop.MediaPlayer2.GetMetadata 2>/dev/null) 8 | if [ "$?" -eq 0 ] && [ -n "$metadata" ]; then 9 | # TODO how do one express this with dbus-send? It works with qdbus but the problem is that it's probably not as common as dbus-send. 10 | state=$(qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus) 11 | if [[ $state == "Playing" ]]; then 12 | artist=$(echo "$metadata" | grep -PA2 "string\s\"xesam:artist\"" | tail -1 | grep -Po "(?<=\").*(?=\")") 13 | track=$(echo "$metadata" | grep -PA1 "string\s\"xesam:title\"" | tail -1 | grep -Po "(?<=\").*(?=\")") 14 | echo "♫ ${artist} - ${track}" | cut -c1-"$max_len" 15 | fi 16 | fi 17 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_spotify_linux_wine.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Print Spotify now playing for GNU/Linux running in wine. 3 | 4 | max_len=40 # Trim output to this length. 5 | 6 | ## Check if Spotify is playing and print that song. 7 | spotify_id=$(xwininfo -root -tree | grep '("spotify' | cut -f1 -d'"' | sed 's/ //g') 8 | echo $spotify_id 9 | if [ -n "$spotify_id" ]; then 10 | np=$(xwininfo -id "$spotify_id" | grep "xwininfo.*Spotify -" | grep -Po "(?<=\"Spotify - ).*(?=\"$)") 11 | if [ -n "$np" ]; then 12 | echo "♫ ${np}" | cut -c1-"$max_len" 13 | fi 14 | fi 15 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_spotify_mac.script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env osascript 2 | # Returns the current playing song in Spotify for OSX 3 | 4 | tell application "System Events" 5 | set process_list to (name of every process) 6 | end tell 7 | 8 | if process_list contains "Spotify" then 9 | tell application "Spotify" 10 | if player state is playing then 11 | set track_name to name of current track 12 | set artist_name to artist of current track 13 | #set album_name to album of current track 14 | set trim_length to 40 15 | set now_playing to artist_name & " - " & track_name 16 | if length of now_playing is less than trim_length then 17 | set now_playing_trim to now_playing 18 | else 19 | set now_playing_trim to characters 1 thru trim_length of now_playing as string 20 | end if 21 | end if 22 | end tell 23 | end if 24 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/np_spotify_mac.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env osascript 2 | # Returns the current playing song in Spotify for OSX 3 | 4 | 5 | tell application "System Events" 6 | set process_list to (name of every process) 7 | end tell 8 | 9 | if process_list contains "Spotify" then 10 | tell application "Spotify" 11 | if player state is playing then 12 | set track_name to name of current track 13 | set artist_name to artist of current track 14 | #set album_name to album of current track 15 | set trim_length to 40 16 | set now_playing to "♫ " & artist_name & " - " & track_name 17 | if length of now_playing is less than trim_length then 18 | set now_playing_trim to now_playing 19 | else 20 | set now_playing_trim to characters 1 thru trim_length of now_playing as string 21 | end if 22 | end if 23 | end tell 24 | end if 25 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/pwd.sh: -------------------------------------------------------------------------------- 1 | #/usr/bin/env bash 2 | # Print the current working directory (max 40+3 characters). 3 | 4 | segment_cwd=$(dirname $0) 5 | source "$segment_cwd/../lib.sh" 6 | 7 | echo $(get_tmux_cwd | sed -e "s|${HOME}|~|" -e 's/^~$/~\//' -e 's/\(.\{40\}\).*$/\1.../') 8 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/time.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints the current time. 3 | date +"%H:%M " 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/tmux_session_info.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints tmux session info. 3 | # Assuems that [ -n "$TMUX"]. 4 | tmux display-message -p '#S:#I.#P' 5 | 6 | exit 0 7 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/uptime.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints the uptime. 3 | uptime | grep -PZo "(?<=up )[^,]*" 4 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/username.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # Prints the hostname 3 | whoami 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/vcs_branch.sh: -------------------------------------------------------------------------------- 1 | #/usr/bin/env bash 2 | # Prints current branch in a VCS directory if it could be detected. 3 | 4 | # Source lib to get the function get_tmux_pwd 5 | segment_path=$(dirname $0) 6 | source "$segment_path/../lib.sh" 7 | 8 | tmux_path=$(get_tmux_cwd) 9 | cd "$tmux_path" 10 | 11 | branch_symbol="⭠" 12 | git_colour="colour5" 13 | git_svn_colour="colour34" 14 | svn_colour="colour220" 15 | hg_colour="colour45" 16 | 17 | # Show git banch. 18 | parse_git_branch() { 19 | type git >/dev/null 2>&1 20 | if [ "$?" -ne 0 ]; then 21 | return 22 | fi 23 | 24 | #git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/' 25 | 26 | # Quit if this is not a Git repo. 27 | branches=$(git branch --no-color 2>/dev/null) 28 | if [ "$?" -ne 0 ]; then 29 | return 30 | fi 31 | 32 | local branch=$(echo "$branches" | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') 33 | 34 | echo "$branches" | grep "remotes/git-svn" &>/dev/null 35 | is_gitsvn=$([ "$?" -eq 0 ] && echo 1 || echo 0) 36 | 37 | echo -n "#[fg=" 38 | if [ "$is_gitsvn" -eq "0" ]; then 39 | echo -n "$git_colour" 40 | else 41 | echo -n "$git_svn_colour" 42 | fi 43 | # TODO pass colour arguments as paramters/globals to segments? 44 | echo "]${branch_symbol} #[fg=colour42]${branch}" 45 | } 46 | 47 | # Show SVN branch. 48 | parse_svn_branch() { 49 | type svn >/dev/null 2>&1 50 | if [ "$?" -ne 0 ]; then 51 | return 52 | fi 53 | 54 | if [ ! -d ".svn/" ]; then 55 | return 56 | fi 57 | 58 | 59 | local svn_root=$(svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p') 60 | local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p') 61 | 62 | local branch=$(echo $svn_url | sed -e 's#^'"${svn_root}"'##g' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | awk '{print $1}') 63 | echo "#[fg=${svn_colour}]${branch_symbol} #[fg=colour42]${branch}" 64 | } 65 | 66 | parse_hg_branch() { 67 | type hg >/dev/null 2>&1 68 | if [ "$?" -ne 0 ]; then 69 | return 70 | fi 71 | 72 | summary=$(hg summary) 73 | if [ "$?" -ne 0 ]; then 74 | return 75 | fi 76 | 77 | local branch=$(echo "$summary" | grep 'branch:' | cut -d ' ' -f2) 78 | echo "#[fg=${hg_colour}]${branch_symbol} #[fg=colour42]${branch}" 79 | } 80 | 81 | branch="" 82 | if [ -n "${git_branch=$(parse_git_branch)}" ]; then 83 | branch="$git_branch" 84 | elif [ -n "${svn_branch=$(parse_svn_branch)}" ]; then 85 | branch="$svn_branch" 86 | elif [ -n "${hg_branch=$(parse_hg_branch)}" ]; then 87 | branch="$hg_branch" 88 | fi 89 | 90 | if [ -n "$branch" ]; then 91 | echo "${branch}" 92 | fi 93 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/wan_ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Prints the WAN IP address. The result is cached and updated according to $update_period. 3 | 4 | tmp_file="/tmp/tmux-powerline_wan_ip.txt" 5 | 6 | wan_ip="" 7 | if [ -f "$tmp_file" ]; then 8 | if [ "$PLATFORM" == "mac" ]; then 9 | last_update=$(stat -f "%m" ${tmp_file}) 10 | else 11 | last_update=$(stat -c "%Y" ${tmp_file}) 12 | fi 13 | time_now=$(date +%s) 14 | update_period=900 15 | 16 | up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc) 17 | if [ "$up_to_date" -eq 1 ]; then 18 | wan_ip=$(cat ${tmp_file}) 19 | fi 20 | fi 21 | 22 | if [ -z "$wan_ip" ]; then 23 | #wan_ip=$(wget --timeout=1 --tries=1 -O - http://formyip.com/ 2>/dev/null | grep -Pzo "(?<=Your IP is )[^<]*") 24 | wan_ip=$(curl --max-time 2 -s http://whatismyip.akamai.com/) 25 | if [ "$?" -eq "0" ]; then 26 | echo "${wan_ip}" > $tmp_file 27 | elif [ -f "${tmp_file}" ]; then 28 | wan_ip=$(cat "$tmp_file") 29 | fi 30 | fi 31 | 32 | if [ -n "$wan_ip" ]; then 33 | #echo "Ⓦ ${wan_ip}" 34 | echo "ⓦ ${wan_ip}" 35 | fi 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/weather.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Prints the current weather in Celsius, Fahrenheits or lord Kelvins. The forecast is cached and updated with a period of $update_period. 3 | 4 | # You location. Find a string that works for you by Googling on "weather in " 5 | location="Lund, Sweden" 6 | 7 | # Can be any of {c,f,k}. 8 | unit="c" 9 | 10 | tmp_file="/tmp/tmux-powerline_weather.txt" 11 | 12 | get_condition_symbol() { 13 | local conditions=$(echo "$1" | tr '[:upper:]' '[:lower:]') 14 | case "$conditions" in 15 | sunny | "partly sunny" | "mostly sunny") 16 | hour=$(date +%H) 17 | if [ "$hour" -ge "22" -o "$hour" -le "5" ]; then 18 | #echo "☽" 19 | echo "☾" 20 | else 21 | #echo "☀" 22 | echo "☼" 23 | fi 24 | ;; 25 | "rain and snow" | "chance of rain" | "light rain" | rain | "heavy rain" | "freezing drizzle" | flurries | showers | "scattered showers" | drizzle | "rain showers") 26 | #echo "☂" 27 | echo "☔" 28 | ;; 29 | snow | "light snow" | "scattered snow showers" | icy | ice/snow | "chance of snow" | "snow showers" | sleet) 30 | #echo "☃" 31 | echo "❅" 32 | ;; 33 | "partly cloudy" | "mostly cloudy" | cloudy | overcast) 34 | echo "☁" 35 | ;; 36 | "chance of storm" | thunderstorm | "chance of tstorm" | storm | "scattered thunderstorms") 37 | #echo "⚡" 38 | echo "☈" 39 | ;; 40 | dust | fog | smoke | haze | mist) 41 | echo "♨" 42 | ;; 43 | windy) 44 | echo "⚑" 45 | #echo "⚐" 46 | ;; 47 | clear) 48 | #echo "☐" 49 | echo "✈" # So clear you can see the aeroplanes! TODO what symbol does best represent a clear sky? 50 | ;; 51 | *) 52 | echo "?" 53 | ;; 54 | esac 55 | } 56 | 57 | read_tmp_file() { 58 | if [ ! -f "$tmp_file" ]; then 59 | return 60 | fi 61 | IFS_bak="$IFS" 62 | IFS=$'\n' 63 | lines=($(cat ${tmp_file})) 64 | IFS="$IFS_bak" 65 | degrees="${lines[0]}" 66 | conditions="${lines[1]}" 67 | } 68 | 69 | degrees="" 70 | if [ -f "$tmp_file" ]; then 71 | if [ "$PLATFORM" == "mac" ]; then 72 | last_update=$(stat -f "%m" ${tmp_file}) 73 | else 74 | last_update=$(stat -c "%Y" ${tmp_file}) 75 | fi 76 | time_now=$(date +%s) 77 | update_period=600 78 | 79 | up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc) 80 | if [ "$up_to_date" -eq 1 ]; then 81 | read_tmp_file 82 | fi 83 | fi 84 | 85 | if [ -z "$degrees" ]; then 86 | if [ "$unit" == "k" ]; then 87 | search_unit="c" 88 | else 89 | search_unit="$unit" 90 | fi 91 | # Convert spaces before using this in the URL. 92 | if [ "$PLATFORM" == "mac" ]; then 93 | search_location=$(echo "$location" | sed -e 's/[ ]/%20/g') 94 | else 95 | search_location=$(echo "$location" | sed -e 's/\s/%20/g') 96 | fi 97 | 98 | weather_data=$(curl --max-time 4 -s "http://www.google.com/ig/api?weather=${search_location}") 99 | if [ "$?" -eq "0" ]; then 100 | error=$(echo "$weather_data" | grep "problem_cause\|DOCTYPE"); 101 | if [ -n "$error" ]; then 102 | echo "error" 103 | exit 1 104 | fi 105 | degrees=$(echo "$weather_data" | sed "s|.*.*|\1|") 106 | if [ "$PLATFORM" == "mac" ]; then 107 | conditions=$(echo $weather_data | xpath //current_conditions/condition/@data 2> /dev/null | grep -oe '".*"' | sed "s/\"//g") 108 | else 109 | conditions=$(echo "$weather_data" | grep -PZo "(\\n|.)*" | grep -PZo "(?<= $tmp_file 112 | echo "$conditions" >> $tmp_file 113 | elif [ -f "$tmp_file" ]; then 114 | read_tmp_file 115 | fi 116 | fi 117 | 118 | if [ -n "$degrees" ]; then 119 | if [ "$unit" == "k" ]; then 120 | degrees=$(echo "${degrees} + 273.15" | bc) 121 | fi 122 | unit_upper=$(echo "$unit" | tr '[cfk]' '[CFK]') 123 | condition_symbol=$(get_condition_symbol "$conditions") 124 | echo "${condition_symbol} ${degrees}°${unit_upper}" 125 | fi 126 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/xkb_layout.c: -------------------------------------------------------------------------------- 1 | /* xkb_layout 2 | * Description: 3 | * This program will connect to the X Server and print the id of the currently 4 | * active keyboard layout. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef DEBUG 13 | #define DO_DEBUG DEBUG 14 | #else 15 | #define DO_DEBUG 0 16 | #endif 17 | #define DEBUG_PRINTF(...) do{ if (DO_DEBUG) { printf(__VA_ARGS__);} } while(0) 18 | 19 | int main() { 20 | // Get X display 21 | char *displayName = ""; 22 | int eventCode; 23 | int errorReturn; 24 | int major = XkbMajorVersion; 25 | int minor = XkbMinorVersion;; 26 | int reasonReturn; 27 | Display *_display = XkbOpenDisplay(displayName, &eventCode, &errorReturn, 28 | &major, &minor, &reasonReturn); 29 | bool error = false; 30 | switch (reasonReturn) { 31 | case XkbOD_BadLibraryVersion: 32 | DEBUG_PRINTF("Bad XKB library version.\n"); 33 | error = true; 34 | break; 35 | case XkbOD_ConnectionRefused: 36 | DEBUG_PRINTF("Connection to X server refused.\n"); 37 | error = true; 38 | break; 39 | case XkbOD_BadServerVersion: 40 | DEBUG_PRINTF("Bad X11 server version.\n"); 41 | error = true; 42 | break; 43 | case XkbOD_NonXkbServer: 44 | DEBUG_PRINTF("XKB not present.\n"); 45 | error = true; 46 | break; 47 | case XkbOD_Success: 48 | break; 49 | } 50 | 51 | if (error) { 52 | return EXIT_FAILURE; 53 | } 54 | 55 | // Get current state of keyboard. 56 | int _deviceId = XkbUseCoreKbd; 57 | XkbStateRec xkbState; 58 | XkbGetState(_display, _deviceId, &xkbState); 59 | // print the groupnumber, may be used with setxkbmap -query to get name 60 | // of current layout 61 | printf("%d\n", xkbState.group); 62 | return 0; 63 | return EXIT_SUCCESS; 64 | } 65 | -------------------------------------------------------------------------------- /.tmux-powerline/segments/xkb_layout.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Print the currently used keyboard layout 3 | # This depends on a specifically developed program which prints the group id of 4 | # the currently used layout. 5 | # I developed the simple program myself with some guidance as I was unable to 6 | # find anything already developed. 7 | # Some people might suggest: 8 | # $ setxkbmod -query -v | awk -F "+" '{print $2}' 9 | # this will only work if you have set up XKB with a single layout which is true 10 | # for some. 11 | 12 | # This script will print the correct layout even if layout is set per window. 13 | # Exit if platform is not linux as this script is dependant on X11 14 | if [ $PLATFORM != "linux" ]; then 15 | exit 0 16 | fi 17 | 18 | cd "$(dirname $0)" 19 | if [ ! -x "xkb_layout" ]; then 20 | make clean xkb_layout &>/dev/null 21 | fi 22 | 23 | if [ -x ./xkb_layout ]; then 24 | cur_layout_nbr=$(($(./xkb_layout)+1)); 25 | cur_layout=$(setxkbmap -query | grep layout | sed 's/layout:\s\+//g' | \ 26 | awk -F ',' '{print $'$(echo "$cur_layout_nbr")'}') 27 | echo "⌨ $cur_layout" 28 | else 29 | exit 1 30 | fi 31 | 32 | -------------------------------------------------------------------------------- /.tmux-powerline/status-left.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Print the status-left for tmux. 3 | # 4 | # The powerline root directory. 5 | cwd=$(dirname $0) 6 | 7 | # Source global configurations. 8 | source "${cwd}/config.sh" 9 | 10 | # Source lib functions. 11 | source "${cwd}/lib.sh" 12 | 13 | segments_path="${cwd}/${segments_dir}" 14 | 15 | # Segments 16 | 17 | declare -A tmux_session_info 18 | tmux_session_info+=(["script"]="${segments_path}/tmux_session_info.sh") 19 | tmux_session_info+=(["foreground"]="colour250") 20 | tmux_session_info+=(["background"]="colour240") 21 | tmux_session_info+=(["separator"]="${separator_right_bold}") 22 | #tmux_session_info+=(["separator_fg"]="default") 23 | register_segment "tmux_session_info" 24 | 25 | declare -A username 26 | username+=(["script"]="${segments_path}/username.sh") 27 | username+=(["foreground"]="colour253") 28 | username+=(["background"]="colour236") 29 | username+=(["separator"]="${separator_right_bold}") 30 | register_segment "username" 31 | 32 | declare -A hostname 33 | hostname+=(["script"]="${segments_path}/hostname.sh") 34 | hostname+=(["foreground"]="colour253") 35 | hostname+=(["background"]="colour236") 36 | hostname+=(["separator"]="${separator_right_bold}") 37 | register_segment "hostname" 38 | 39 | #declare -A lan_ip 40 | #lan_ip+=(["script"]="${segments_path}/lan_ip.sh") 41 | #lan_ip+=(["foreground"]="colour255") 42 | #lan_ip+=(["background"]="colour234") 43 | #lan_ip+=(["separator"]="${separator_right_bold}") 44 | #register_segment "lan_ip" 45 | 46 | #declare -A wan_ip 47 | #wan_ip+=(["script"]="${segments_path}/wan_ip.sh") 48 | #wan_ip+=(["foreground"]="colour255") 49 | #wan_ip+=(["background"]="colour234") 50 | #wan_ip+=(["separator"]="${separator_right_thin}") 51 | #wan_ip+=(["separator_fg"]="white") 52 | #register_segment "wan_ip" 53 | 54 | ##declare -A vcs_branch 55 | #vcs_branch+=(["script"]="${segments_path}/vcs_branch.sh") 56 | #vcs_branch+=(["foreground"]="colour88") 57 | #vcs_branch+=(["background"]="colour29") 58 | #vcs_branch+=(["separator"]="${separator_right_bold}") 59 | #register_segment "vcs_branch" 60 | 61 | # Print the status line in the order of registration above. 62 | print_status_line_left 63 | 64 | exit 0 65 | -------------------------------------------------------------------------------- /.tmux-powerline/status-right.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script prints a string will be evaluated for text attributes (but not shell commands) by tmux. It consists of a bunch of segments that are simple shell scripts/programs that output the information to show. For each segment the desired foreground and background color can be specified as well as what separator to use. The script the glues together these segments dynamically so that if one script suddenly does not output anything (= nothing should be shown) the separator colors will be nicely handled. 3 | 4 | # The powerline root directory. 5 | cwd=$(dirname $0) 6 | 7 | # Source global configurations. 8 | source "${cwd}/config.sh" 9 | 10 | # Source lib functions. 11 | source "${cwd}/lib.sh" 12 | 13 | segments_path="${cwd}/${segments_dir}" 14 | 15 | # Segment 16 | # Comment/uncomment the register function call to enable or disable a segment. 17 | 18 | #declare -A pwd 19 | #pwd+=(["script"]="${segments_path}/pwd.sh") 20 | #pwd+=(["foreground"]="colour211") 21 | #pwd+=(["background"]="colour89") 22 | #pwd+=(["separator"]="${separator_left_bold}") 23 | #register_segment "pwd" 24 | 25 | #declare -A mail_count 26 | #mail_count+=(["script"]="${segments_path}/maildir_count.sh") 27 | #mail_count+=(["script"]="${segments_path}/apple_mail_count.sh") 28 | #mail_count+=(["foreground"]="white") 29 | #mail_count+=(["background"]="red") 30 | #mail_count+=(["separator"]="${separator_left_bold}") 31 | #register_segment "mail_count" 32 | 33 | declare -A now_playing 34 | if [ "$PLATFORM" == "linux" ]; then 35 | now_playing+=(["script"]="${segments_path}/np_mpd.sh") 36 | #now_playing+=(["script"]="${segments_path}/np_spotify_linux_wine.sh") 37 | #now_playing+=(["script"]="${segments_path}/np_spotify_linux_native.sh") 38 | #now_playing+=(["script"]="${segments_path}/np_rhythmbox.sh") 39 | #now_playing+=(["script"]="${segments_path}/np_banshee.sh") 40 | #now_playing+=(["script"]="${segments_path}/np_audacious.sh") 41 | elif [ "$PLATFORM" == "mac" ]; then 42 | #now_playing+=(["script"]="${segments_path}/np_itunes_mac.sh") 43 | now_playing+=(["script"]="${segments_path}/np_spotify_mac.sh") 44 | fi 45 | if [[ ${now_playing["script"]} ]]; then 46 | now_playing+=(["foreground"]="colour37") 47 | now_playing+=(["background"]="colour234") 48 | now_playing+=(["separator"]="${separator_left_bold}") 49 | register_segment "now_playing" 50 | fi 51 | 52 | 53 | #declare -A cpu 54 | #cpu+=(["script"]="${segments_path}/cpu.sh") 55 | #cpu+=(["foreground"]="colour255") 56 | #cpu+=(["background"]="colour234") 57 | #cpu+=(["separator"]="${separator_left_bold}") 58 | #register_segment "cpu" 59 | 60 | #declare -A load 61 | #load+=(["script"]="${segments_path}/load.sh") 62 | #load+=(["foreground"]="colour253") 63 | #load+=(["background"]="colour235") 64 | #load+=(["separator"]="${separator_left_bold}") 65 | #register_segment "load" 66 | 67 | declare -A battery 68 | if [ "$PLATFORM" == "mac" ]; then 69 | battery+=(["script"]="${segments_path}/battery_mac.sh") 70 | else 71 | battery+=(["script"]="${segments_path}/battery.sh") 72 | fi 73 | battery+=(["foreground"]="colour252") 74 | battery+=(["background"]="colour237") 75 | battery+=(["separator"]="${separator_left_bold}") 76 | register_segment "battery" 77 | 78 | #declare -A weather 79 | #weather+=(["script"]="${segments_path}/weather.sh") 80 | #weather+=(["foreground"]="colour255") 81 | #weather+=(["background"]="colour37") 82 | #weather+=(["separator"]="${separator_left_bold}") 83 | #register_segment "weather" 84 | 85 | #declare -A xkb_layout 86 | #if [ "$PLATFORM" == "linux" ]; then 87 | #xkb_layout+=(["script"]="${segments_path}/xkb_layout.sh") 88 | #xkb_layout+=(["foreground"]="colour117") 89 | #xkb_layout+=(["background"]="colour125") 90 | #xkb_layout+=(["separator"]="${separator_left_bold}") 91 | #fi 92 | #register_segment "xkb_layout" 93 | 94 | declare -A date_day 95 | date_day+=(["script"]="${segments_path}/date_day.sh") 96 | date_day+=(["foreground"]="black") 97 | date_day+=(["background"]="colour249") 98 | date_day+=(["separator"]="${separator_left_bold}") 99 | register_segment "date_day" 100 | 101 | declare -A date_full 102 | date_full+=(["script"]="${segments_path}/date_full.sh") 103 | date_full+=(["foreground"]="black") 104 | date_full+=(["background"]="colour249") 105 | date_full+=(["separator"]="${separator_left_bold}") 106 | date_full+=(["separator_fg"]="colour249") 107 | register_segment "date_full" 108 | 109 | declare -A time 110 | time+=(["script"]="${segments_path}/time.sh") 111 | time+=(["foreground"]="black") 112 | time+=(["background"]="colour249") 113 | time+=(["separator"]="${separator_left_thin}") 114 | time+=(["separator_fg"]="black") 115 | register_segment "time" 116 | 117 | # Print the status line in the order of registration above. 118 | print_status_line_right 119 | 120 | exit 0 121 | -------------------------------------------------------------------------------- /.tmux.conf: -------------------------------------------------------------------------------- 1 | # ^s, not ^d 2 | unbind C-b 3 | set -g prefix C-s 4 | 5 | # Shorten input delay (tmux normally adds a short delay on inputs) 6 | set -sg escape-time 0 7 | 8 | # send commands to nested session with ^s s 9 | bind-key s send-prefix 10 | 11 | # reload this on 'r' 12 | bind r source-file ~/.tmux.conf 13 | 14 | # terminal 15 | set -g default-terminal screen-256color 16 | set -g history-limit 50000 17 | 18 | # bells and monitoring 19 | set -g visual-silence on 20 | set -g visual-bell on 21 | set -g bell-action any 22 | 23 | # statusbar 24 | set-option -g status on 25 | set-option -g status-interval 2 26 | set-option -g status-justify "centre" 27 | set-option -g status-left-length 60 28 | set-option -g status-right-length 90 29 | set-option -g status-left "#(~/.tmux-powerline/status-left.sh)" 30 | set-option -g status-right "#(~/.tmux-powerline/status-right.sh)" 31 | set-option -g status-bg black #base02 32 | set-option -g status-fg white #yellow 33 | set-option -g status-attr default 34 | 35 | # default window title colors 36 | set-window-option -g window-status-fg brightblue #base0 37 | set-window-option -g window-status-bg default 38 | 39 | # active window title colors 40 | set-window-option -g window-status-current-fg white #orange 41 | set-window-option -g window-status-current-bg default 42 | 43 | # pane border 44 | set-option -g pane-border-fg black #base02 45 | set-option -g pane-active-border-fg white #base01 46 | 47 | # message text 48 | set-option -g message-bg black #base02 49 | set-option -g message-fg brightred #orange 50 | 51 | # pane number display 52 | set-option -g display-panes-active-colour blue #blue 53 | set-option -g display-panes-colour brightred #orange 54 | 55 | # clock 56 | set-window-option -g clock-mode-colour green #green 57 | 58 | # fix resizing 59 | setw -g aggressive-resize on 60 | 61 | # vim resizes 62 | bind - resize-pane -D 1 63 | bind + resize-pane -U 1 64 | bind < resize-pane -L 1 65 | bind > resize-pane -R 1 66 | 67 | # split or new window path perserve 68 | bind '"' split-window -c "#{pane_current_path}" 69 | bind % split-window -h -c "#{pane_current_path}" 70 | bind c new-window -c "#{pane_current_path}" 71 | 72 | # and faster resizes 73 | bind J resize-pane -D 5 74 | bind K resize-pane -U 5 75 | bind H resize-pane -L 5 76 | bind L resize-pane -R 5 77 | 78 | # vim copying 79 | setw -g mode-keys vi 80 | bind-key -t vi-copy 'v' begin-selection 81 | bind-key -t vi-copy 'y' copy-selection 82 | 83 | # Similar to 'C-w j' to navigate windows in Vim 84 | unbind-key j 85 | bind-key j select-pane -D 86 | unbind-key k 87 | bind-key k select-pane -U 88 | unbind-key h 89 | bind-key h select-pane -L 90 | unbind-key l 91 | bind-key l select-pane -R 92 | 93 | # Enable mouse support 94 | set-option -g mouse on 95 | 96 | # make scrolling with wheels work 97 | bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'" 98 | bind -n WheelDownPane select-pane -t= \; send-keys -M 99 | 100 | 101 | # Start windows and panes at 1, not 0 102 | set -g base-index 1 103 | set -g pane-base-index 1 104 | 105 | # If we want Vim to be told about focus: http://git.io/2UqSgQ 106 | set -g focus-events on 107 | 108 | # try to set wm window titles with xterm codes 109 | set -g set-titles on 110 | 111 | # colour support 112 | set -g default-terminal "xterm" 113 | 114 | # fix pbcopy/pbpaste 115 | if 'command -v reattach-to-user-namespace >/dev/null' \ 116 | 'set -gq @osx-pasteboard true' 117 | 118 | if 'tmux show -gv @osx-clipboard' \ 119 | 'set -g default-command "reattach-to-user-namespace -l $SHELL"' 120 | 121 | # Copy top of tmux paste buffer stack to OS clipboard. 122 | # Alternatively, this will always immediately copy to system pasteboard: 123 | # bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" 124 | if 'tmux show -gv @osx-clipboard' \ 125 | 'bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy"' 126 | 127 | # smart pane switching with awareness of vim splits 128 | # see https://github.com/christoomey/vim-tmux-navigator 129 | bind -n C-h if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-h" "select-pane -L" 130 | bind -n C-j if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-j" "select-pane -D" 131 | bind -n C-k if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-k" "select-pane -U" 132 | bind -n C-l if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-l" "select-pane -R" 133 | bind -n "C-\\" if "[ $(tmux display -p '#{pane_current_command}') = vim ]" "send-keys C-\\" "select-pane -l" 134 | 135 | # Bring back clear screen under tmux prefix 136 | bind C-l send-keys 'C-l' 137 | 138 | # List of plugins 139 | # Supports `github_username/repo` or full git repo URLs 140 | set -g @tpm_plugins ' \ 141 | tmux-plugins/tpm \ 142 | tmux-plugins/tmux-sensible \ 143 | tmux-plugins/tmux-copycat \ 144 | tmux-plugins/tmux-yank \ 145 | tmux-plugins/tmux-open \ 146 | tmux-plugins/tmux-logging \ 147 | tmux-plugins/tmux-urlview \ 148 | tmux-plugins/tmux-fpp \ 149 | ' 150 | # Other examples: 151 | # github_username/plugin_name \ 152 | # git@github.com/user/plugin \ 153 | # git@bitbucket.com/user/plugin \ 154 | 155 | # resurrect 156 | set -g @resurrect-strategy-vim 'session' 157 | set -g @resurrect-strategy-nvim 'session' 158 | set -g @resurrect-capture-pane-contents 'on' 159 | 160 | # continuum 161 | set -g @continuum-restore 'on' 162 | set -g @continuum-boot 'on' 163 | set -g @continuum-boot-options 'iterm,fullscreen' 164 | 165 | # Initializes TMUX plugin manager. 166 | # Keep this line at the very bottom of tmux.conf. 167 | run-shell '~/.tmux/plugins/tpm/tpm' 168 | 169 | bind e setw synchronize-panes on 170 | bind E setw synchronize-panes off 171 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) Joshua Boy Nicolai Appelman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PWD = `pwd` 2 | FILES = ".tmux.conf" 3 | DIRS = ".tmux-powerline" ".tmux" 4 | 5 | all: linkfiles linkdirs 6 | 7 | linkfiles: 8 | for file in $(FILES); do \ 9 | ln -sf "$$PWD/$$file" ~/"$$file"; \ 10 | done 11 | 12 | linkdirs: 13 | for dir in $(DIRS); do \ 14 | ln -sf "$$PWD/$$dir" ~/ ; \ 15 | done 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tmux config 2 | 3 | Tmux config file and plugins. 4 | 5 | ### Installation 6 | 7 | 1. Clone this repository 8 | `git clone https://github.com/jbnicolai/tmux ~/tmux-config` 9 | 2. Initialize the `tpm` plugin manager submodule 10 | `cd ~/tmux-config && git submodule init` 11 | 3. Run the `Makefile` to symlink the config files 12 | `make` 13 | 4. Open tmux and hit `prefix + I` to fetch all plugins. 14 | 15 | ### Plugins 16 | 17 | All plugins are installed through [`tpm`](https://github.com/tmux-plugins/tpm). 18 | 19 | - [tmux-plugins/tpm](https://github.com/tmux-plugins/tpm) - plugin manager 20 | - [tmux-plugins/tmux-sensible](https://github.com/tmux-plugins/tmux-sensible) - sensible default config 21 | - [tmux-plugins/tmux-copycat](https://github.com/tmux-plugins/tmux-copycat) - improved copy mode 22 | - [tmux-plugins/tmux-yank](https://github.com/tmux-plugins/tmux-yank) - yank to system clipboard 23 | - [tmux-plugins/tmux-open](https://github.com/tmux-plugins/tmux-open) - open files in copy mode 24 | - [tmux-plugins/tmux-logging](https://github.com/tmux-plugins/tmux-logging) - record history 25 | - [tmux-plugins/tmux-resurrect](https://github.com/tmux-plugins/tmux-resurrect) - save tmux sessions 26 | - [tmux-plugins/tmux-continuum](https://github.com/tmux-plugins/tmux-continuum) - restore tmux sessions 27 | - [jbnicolai/tmux-urlview](https://github.com/jbnicolai/tmux-urlview) - open urls 28 | - [jbnicolai/tmux-fpp](https://github.com/jbnicolai/tmux-fpp) - open paths 29 | 30 | ### Contributions and new features 31 | 32 | Bug fixes and contributions are welcome. 33 | 34 | Feel free to suggest new features, via github issues. 35 | 36 | If you have a bigger idea you'd like to work on, please get in touch, also via 37 | github issues. 38 | 39 | ### License 40 | 41 | [MIT](LICENSE.md) 42 | --------------------------------------------------------------------------------