Removed tmux-powerline, added public ssh key, improved install script.
More changes coming soon to allow script to clone itself.
This commit is contained in:
parent
1062255312
commit
e7f9bd0376
1
.ssh/id_rsa.pub
Normal file
1
.ssh/id_rsa.pub
Normal file
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtt0xshFI+daB3hqLuJuZV1wphbeH2bxGJS0Tf+BsdVedt7+HbLwnZ8YdRQ5BpXqIZ8SgG+q5wJca0TyhZWFD4eUoKv8EE44MSQfJZu0QFQwy4XBSPpLrRwvXxNiW6MWkUhKCSO0BCea3tquACVWxPy5Gj3jRMVYaQDCIwV4AXzX4Hfvf8+r+/vpyiD1NNGK1CfVuOlMLWY6ofGOUEWeSyN/g1H2zqWS/w2Ek7G3zNQ+Xx7Lw6QTs/Zwzriynzch5aYHnRJQqKFefLn4AyLJ8/Z4Lod4KVEG+4mYoNkf6lZzDARZBCy4OnDZNSCeCCd1fBc2wVZ7twunjig+0pmRcf agrosinger@expedia.com
|
@ -1 +0,0 @@
|
||||
/home/tony/Documents/personal/dotfiles/.tmux-powerline
|
@ -1,14 +0,0 @@
|
||||
tmux-powerline - Statusbar configuration for tmux that looks like vim-powerline and consist of dynamic segments.
|
||||
|
||||
Copyright (c) 2012, see AUTHORS
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
* Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
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.
|
||||
|
||||
http://opensource.org/licenses/BSD-3-Clause
|
@ -1,174 +0,0 @@
|
||||
# tmux-powerline
|
||||
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.
|
||||
|
||||
The following segments exists for now:
|
||||
* LAN & WAN IP addresses.
|
||||
* Now Playing for MPD, Spotify (GNU/Linux native or wine, OS X), iTunes (OS X), Rhythmbox, Banshee, MOC, and Audacious.
|
||||
* New mail count for GMail, Maildir and Apple Mail.
|
||||
* GNU/Linux and Macintosh OS X battery status (uses [richo/dotfiles/bin/battery](https://github.com/richoH/dotfiles/blob/master/bin/battery)).
|
||||
* Weather in Celsius, Fahrenheit and Kelvin using Yahoo Weather.
|
||||
* System load, cpu usage and uptime.
|
||||
* Git, SVN and Mercurial branch in CWD.
|
||||
* Date and time.
|
||||
* Hostname.
|
||||
* tmux info.
|
||||
* CWD in pane.
|
||||
* Current X keyboard layout.
|
||||
|
||||
Check [segments/](https://github.com/erikw/tmux-powerline/tree/master/segments) for more undocumented segments and details.
|
||||
|
||||
# Screenshots
|
||||
**Full screenshot**
|
||||
|
||||
![Full screenshot](https://github.com/erikw/tmux-powerline/raw/master/img/full.png)
|
||||
|
||||
**left-status**
|
||||
|
||||
Current tmux session, window and pane, hostname and LAN & WAN IP address.
|
||||
|
||||
![left-status](https://github.com/erikw/tmux-powerline/raw/master/img/left-status.png)
|
||||
|
||||
**right-status**
|
||||
|
||||
New mails, now playing, average load, weather, date and time.
|
||||
|
||||
![right-status](https://github.com/erikw/tmux-powerline/raw/master/img/right-status.png)
|
||||
|
||||
Now I've read my inbox so the mail segment disappears!
|
||||
|
||||
![right-status, no mail](https://github.com/erikw/tmux-powerline/raw/master/img/right-status_no_mail.png)
|
||||
|
||||
After pausing the music there's no need for showing NP anymore. Also the weather has become much nicer!
|
||||
|
||||
![right-status, no mpd](https://github.com/erikw/tmux-powerline/raw/master/img/right-status_no_mpd.png)
|
||||
|
||||
Remaining battery.
|
||||
|
||||
![right-status, weather and battery](https://github.com/erikw/tmux-powerline/raw/master/img/right-status_weather_battery.png)
|
||||
|
||||
# Requirements
|
||||
Requirements for the lib to work are:
|
||||
|
||||
* Recent tmux version
|
||||
* `bash --version` >= 4.0
|
||||
* A patched font. Follow instructions at [Lokaltog/vim-powerline/fontpatcher](https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher) or [download](https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts) a new one. However you can use other substitute symbols as well; see `config.sh`.
|
||||
|
||||
## Segment Requirements
|
||||
Requirements for some segments. You only need to fullfill the requirements for those segments you want to use.
|
||||
|
||||
* WAN IP: curl, bc
|
||||
* MPD now playing: [libmpdclient](http://sourceforge.net/projects/musicpd/files/libmpdclient/)
|
||||
* xkb_layout: X11, XKB
|
||||
* GMail count: wget.
|
||||
|
||||
## OS X specific requirements
|
||||
|
||||
**You still need to follow the first part of these instructions even if you are running zsh or something else as your default shell!**
|
||||
|
||||
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
|
||||
`bash --version` to see your version). In order to use tmux-powerline, you need to install a newer version of bash, fortunately,
|
||||
[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).
|
||||
Then follow these steps:
|
||||
|
||||
```bash
|
||||
$ brew install bash
|
||||
```
|
||||
|
||||
**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
|
||||
seems broken, try following the last two steps and see if it helps:
|
||||
|
||||
```bash
|
||||
$ sudo bash -c "echo /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash >> /private/etc/shells"
|
||||
$ chsh -s /usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash
|
||||
```
|
||||
|
||||
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.
|
||||
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
|
||||
terminal, running `echo $SHELL` should result in the following:
|
||||
|
||||
```bash
|
||||
$ echo $SHELL
|
||||
/usr/local/Cellar/bash/%INSTALLED_VERSION%/bin/bash
|
||||
```
|
||||
|
||||
# Installation
|
||||
Just check out the repository with:
|
||||
|
||||
```console
|
||||
$ cd ~/some/path/
|
||||
$ git clone git://github.com/erikw/tmux-powerline.git
|
||||
```
|
||||
|
||||
Now edit your `~/.tmux.conf` to use the scripts:
|
||||
|
||||
<!-- Close syntax enought. -->
|
||||
```vim
|
||||
set-option -g status on
|
||||
set-option -g status-interval 2
|
||||
set-option -g status-utf8 on
|
||||
set-option -g status-justify "centre"
|
||||
set-option -g status-left-length 60
|
||||
set-option -g status-right-length 90
|
||||
set-option -g status-left "#(~/path/to/tmux-powerline/status-left.sh)"
|
||||
set-option -g status-right "#(~/path/to/tmux-powerline/status-right.sh)"
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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) :)):
|
||||
|
||||
```bash
|
||||
source ~/path/to/tmux-colors-solarized/tmuxcolors.conf
|
||||
```
|
||||
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 shell prompt is displayed. Put the line below in your `~/.bashrc` or where you define you PS1 variable. zsh users can put it in e.g. `~/.zshrc` and may change `PS1` to `PROMPT` (but that's not necessary).
|
||||
|
||||
```bash
|
||||
PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")'
|
||||
```
|
||||
|
||||
You can toggle the visibility of the statusbars by adding the following to your `~/.tmux.conf`:
|
||||
|
||||
```vim
|
||||
bind C-[ run '~/path/to/tmux-powerline/mute_statusbar.sh left' # Mute left statusbar.
|
||||
bind C-] run '~/path/to/tmux-powerline/mute_statusbar.sh right' # Mute right statusbar.
|
||||
```
|
||||
|
||||
# Configuration
|
||||
|
||||
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.
|
||||
|
||||
```console
|
||||
$ $EDITOR ~/path/to/tmux-powerline/status-left.sh
|
||||
$ $EDITOR ~/path/to/tmux-powerline/status-right.sh
|
||||
```
|
||||
|
||||
|
||||
Here is one segment configuration explained so you'll know how to make you own.
|
||||
|
||||
```bash
|
||||
declare -A time # The name of the array.
|
||||
time+=(["script"]="${segments_path}/time.sh") # mandatory, the shell script producing the output text to be shown.
|
||||
time+=(["foreground"]="colour136") # mandatory, the text foreground color.
|
||||
time+=(["background"]="colour235") # mandatory, the text background color.
|
||||
time+=(["separator"]="${separator_left_thin}") # mandatory, the separator to use. Can be (as described in `lib.sh`) any of separator_(left|right)_(bold|thin)
|
||||
time+=(["separator_fg"]="default") # optional, overrides the default blending coloring of the separator with a custom colored foreground.
|
||||
register_segment "time" # Registers the name of the array declared above.
|
||||
```
|
||||
# Debugging
|
||||
|
||||
Some segments might not work on your system for various reasons such as missing programs or different versions not having the same options. If a segment fails the printing should be aborted. To investigate further why a segment fails you can run
|
||||
|
||||
```bash
|
||||
$ bash -x ~/path/to/failing/segment.sh
|
||||
```
|
||||
To see all output even if some segment fails you can set `DEBUG_MODE="true"` in `config.sh`.
|
||||
|
||||
## Common problems
|
||||
|
||||
### VCS_branch is not updating
|
||||
The issue is probably that the update of the current directory in the active pane is not updated correctly. Make sure that your PS1 or PROMPT variable actually contains the line from the installation step above by simply inspecing the output of `echo $PS1`. You might have placed the PS1 line in you shell confugration such that it is overwritten later. The simplest solution is to put it at the very end to make sure that nothing overwrites it. See [issue #52](https://github.com/erikw/tmux-powerline/issues/52).
|
||||
|
||||
|
||||
# Hacking
|
||||
|
||||
This project can only gain positively from contributions. Fork today and make your own enhancments and segments to share back!
|
@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Cofigurations for tmux-powerline.
|
||||
|
||||
if [ -z "$DEBUG_MODE" ]; then
|
||||
# Disable debug mode by default
|
||||
export DEBUG_MODE="false"
|
||||
fi
|
||||
|
||||
if [ -z "$PLATFORM" ]; then
|
||||
# You platform \in {linux,bsd,mac}.
|
||||
export PLATFORM="linux"
|
||||
fi
|
||||
|
||||
if [ -z "$USE_PATCHED_FONT" ]; then
|
||||
# Useage of patched font for symbols. true or false.
|
||||
export USE_PATCHED_FONT="false"
|
||||
fi
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
@ -1,221 +0,0 @@
|
||||
# Library functions.
|
||||
|
||||
segments_dir="segments"
|
||||
declare entries
|
||||
|
||||
if [ -n "$USE_PATCHED_FONT" -a "$USE_PATCHED_FONT" == "true" ]; then
|
||||
# Separators (patched font required)
|
||||
separator_left_bold="⮂"
|
||||
separator_left_thin="⮃"
|
||||
separator_right_bold="⮀"
|
||||
separator_right_thin="⮁"
|
||||
else
|
||||
# Alternative separators in the normal Unicode table.
|
||||
separator_left_bold="◀"
|
||||
separator_left_thin="❮"
|
||||
separator_right_bold="▶"
|
||||
separator_right_thin="❯"
|
||||
fi
|
||||
|
||||
# Make sure that grep does not emit colors.
|
||||
export GREP_OPTIONS="--color=never"
|
||||
|
||||
# Create temp directory for segments to use.
|
||||
export tp_tmpdir="/tmp/tmux-powerline"
|
||||
if [ ! -d "$tp_tmpdir" ]; then
|
||||
mkdir "$tp_tmpdir"
|
||||
fi
|
||||
|
||||
# Register a segment.
|
||||
register_segment() {
|
||||
segment_name="$1"
|
||||
entries[${#entries[*]}]="$segment_name"
|
||||
|
||||
}
|
||||
|
||||
print_status_line_right() {
|
||||
local prev_bg="colour235"
|
||||
for entry in ${entries[*]}; do
|
||||
local script=$(eval echo \${${entry}["script"]})
|
||||
local foreground=$(eval echo \${${entry}["foreground"]})
|
||||
local background=$(eval echo \${${entry}["background"]})
|
||||
local separator=$(eval echo \${${entry}["separator"]})
|
||||
local separator_fg=""
|
||||
if [ $(eval echo \${${entry}["separator_fg"]+_}) ];then
|
||||
separator_fg=$(eval echo \${${entry}["separator_fg"]})
|
||||
fi
|
||||
|
||||
# Can't be declared local if we want the exit code.
|
||||
output=$(${script})
|
||||
local exit_code="$?"
|
||||
if [ "$DEBUG_MODE" != "false" ]; then
|
||||
if [ "$exit_code" -ne 0 ]; then
|
||||
echo "Segment ${script} exited with code ${exit_code}. Aborting."
|
||||
exit 1
|
||||
elif [ -z "$output" ]; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
__ui_right "$prev_bg" "$background" "$foreground" "$separator" "$separator_fg"
|
||||
echo -n "$output"
|
||||
unset output
|
||||
prev_bg="$background"
|
||||
done
|
||||
# End in a clean state.
|
||||
echo "#[default]"
|
||||
}
|
||||
|
||||
first_segment_left=1
|
||||
print_status_line_left() {
|
||||
prev_bg="colour148"
|
||||
for entry in ${entries[*]}; do
|
||||
local script=$(eval echo \${${entry}["script"]})
|
||||
local foreground=$(eval echo \${${entry}["foreground"]})
|
||||
local background=$(eval echo \${${entry}["background"]})
|
||||
local separator=$(eval echo \${${entry}["separator"]})
|
||||
local separator_fg=""
|
||||
if [ $(eval echo \${${entry}["separator_fg"]+_}) ];then
|
||||
separator_fg=$(eval echo \${${entry}["separator_fg"]})
|
||||
fi
|
||||
|
||||
local output=$(${script})
|
||||
if [ -n "$output" ]; then
|
||||
__ui_left "$prev_bg" "$background" "$foreground" "$separator" "$separator_fg"
|
||||
echo -n "$output"
|
||||
prev_bg="$background"
|
||||
if [ "$first_segment_left" -eq "1" ]; then
|
||||
first_segment_left=0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
__ui_left "colour235" "colour235" "red" "$separator_right_bold" "$prev_bg"
|
||||
|
||||
# End in a clean state.
|
||||
echo "#[default]"
|
||||
}
|
||||
|
||||
#Internal printer for right.
|
||||
__ui_right() {
|
||||
local bg_left="$1"
|
||||
local bg_right="$2"
|
||||
local fg_right="$3"
|
||||
local separator="$4"
|
||||
local separator_fg
|
||||
if [ -n "$5" ]; then
|
||||
separator_fg="$5"
|
||||
else
|
||||
separator_fg="$bg_right"
|
||||
fi
|
||||
echo -n " #[fg=${separator_fg}, bg=${bg_left}]${separator}#[fg=${fg_right},bg=${bg_right}] "
|
||||
}
|
||||
|
||||
# Internal printer for left.
|
||||
__ui_left() {
|
||||
local bg_left="$1"
|
||||
local bg_right="$2"
|
||||
local fg_right="$3"
|
||||
local separator
|
||||
if [ "$first_segment_left" -eq "1" ]; then
|
||||
separator=""
|
||||
else
|
||||
separator="$4"
|
||||
fi
|
||||
|
||||
local separator_bg
|
||||
if [ -n "$5" ]; then
|
||||
bg_left="$5"
|
||||
separator_bg="$bg_right"
|
||||
else
|
||||
separator_bg="$bg_right"
|
||||
fi
|
||||
|
||||
if [ "$first_segment_left" -eq "1" ]; then
|
||||
echo -n "#[bg=${bg_right}]"
|
||||
fi
|
||||
|
||||
echo -n " #[fg=${bg_left}, bg=${separator_bg}]${separator}#[fg=${fg_right},bg=${bg_right}]"
|
||||
|
||||
if [ "$first_segment_left" -ne "1" ]; then
|
||||
echo -n " "
|
||||
fi
|
||||
}
|
||||
|
||||
# Get the current path in the segment.
|
||||
get_tmux_cwd() {
|
||||
local env_name=$(tmux display -p "TMUXPWD_#I_#P")
|
||||
local env_val=$(tmux show-environment | grep "$env_name")
|
||||
# The version below is still quite new for tmux. Uncommented this in the future :-)
|
||||
#local env_val=$(tmux show-environment "$env_name" 2>&1)
|
||||
|
||||
if [[ ! $env_val =~ "unknown variable" ]]; then
|
||||
local tmux_pwd=$(echo "$env_val" | sed 's/^.*=//')
|
||||
echo "$tmux_pwd"
|
||||
fi
|
||||
}
|
||||
|
||||
# Exit this script if a mute file exists.
|
||||
mute_status_check() {
|
||||
local side="$1"
|
||||
local tmux_session=$(tmux display -p "#S")
|
||||
local mute_file="${tp_tmpdir}/mute_${tmux_session}_${side}"
|
||||
if [ -e "$mute_file" ]; then
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Toggles the visibility of a statusbar side.
|
||||
mute_status() {
|
||||
local side="$1"
|
||||
local tmux_session=$(tmux display -p "#S")
|
||||
local mute_file="${tp_tmpdir}/mute_${tmux_session}_${side}"
|
||||
if [ -e "$mute_file" ]; then
|
||||
rm "$mute_file"
|
||||
else
|
||||
touch "$mute_file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Rolling anything what you want.
|
||||
# arg1: text to roll.
|
||||
# arg2: max length to display.
|
||||
# arg3: roll speed in characters per second.
|
||||
roll_stuff() {
|
||||
local stuff="$1" # Text to print
|
||||
if [ -z "$stuff" ]; then
|
||||
return;
|
||||
fi
|
||||
local max_len="10" # Default max length.
|
||||
if [ -n "$2" ]; then
|
||||
max_len="$2"
|
||||
fi
|
||||
local speed="1" # Default roll speed in chars per second.
|
||||
if [ -n "$3" ]; then
|
||||
speed="$3"
|
||||
fi
|
||||
# Anything starting with 0 is an Octal number in Shell,C or Perl,
|
||||
# so we must explicityly state the base of a number using base#number
|
||||
local offset=$((10#$(date +%s) * ${speed} % ${#stuff}))
|
||||
# Truncate stuff.
|
||||
stuff=${stuff:offset}
|
||||
local char # Character.
|
||||
local bytes # The bytes of one character.
|
||||
local index
|
||||
for ((index=0; index < max_len; index++)); do
|
||||
char=${stuff:index:1}
|
||||
bytes=$(echo -n $char | wc -c)
|
||||
# The character will takes twice space
|
||||
# of an alphabet if (bytes > 1).
|
||||
if ((bytes > 1)); then
|
||||
max_len=$((max_len - 1))
|
||||
fi
|
||||
done
|
||||
stuff=${stuff:0:max_len}
|
||||
#echo "index=${index} max=${max_len} len=${#stuff}"
|
||||
# How many spaces we need to fill to keep
|
||||
# the length of stuff that will be shown?
|
||||
local fill_count=$((${index} - ${#stuff}))
|
||||
for ((index=0; index < fill_count; index++)); do
|
||||
stuff="${stuff} "
|
||||
done
|
||||
echo "${stuff}"
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Toggles the visibility of a statusbar side.
|
||||
|
||||
# The powerline root directory.
|
||||
cwd=$(dirname $0)
|
||||
|
||||
# Source lib functions.
|
||||
source "${cwd}/lib.sh"
|
||||
|
||||
side="$1"
|
||||
mute_status "$side"
|
@ -1,18 +0,0 @@
|
||||
# Build the small MPD NP program.
|
||||
# Enable debug printing with $ make -e DEBUG=1
|
||||
DEBUG=0
|
||||
CC = $(shell hash clang 2>/dev/null && echo clang || echo gcc)
|
||||
CFLAGS = -O3 -Wall -std=c99 -I /usr/include/ -D DEBUG=${DEBUG}
|
||||
LDLIBS = -lmpdclient
|
||||
XKB_LAYOUT_LDLIBS= -lX11
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: np_mpd xkb_layout
|
||||
|
||||
xkb_layout: xkb_layout.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $< $(XKB_LAYOUT_LDLIBS) -o $@
|
||||
|
||||
clean:
|
||||
$(RM) np_mpd
|
||||
$(RM) xkb_layout
|
@ -1,130 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
#CUTE_BATTERY_INDICATOR="true"
|
||||
|
||||
HEART_FULL=♥
|
||||
HEART_EMPTY=♡
|
||||
[ -z "$NUM_HEARTS" ] &&
|
||||
NUM_HEARTS=5
|
||||
|
||||
cutinate()
|
||||
{
|
||||
perc=$1
|
||||
inc=$(( 100 / $NUM_HEARTS))
|
||||
|
||||
|
||||
for i in `seq $NUM_HEARTS`; do
|
||||
if [ $perc -lt 100 ]; then
|
||||
echo $HEART_EMPTY
|
||||
else
|
||||
echo $HEART_FULL
|
||||
fi
|
||||
perc=$(( $perc + $inc ))
|
||||
done
|
||||
}
|
||||
|
||||
linux_get_bat ()
|
||||
{
|
||||
bf=$(cat $BAT_FULL)
|
||||
bn=$(cat $BAT_NOW)
|
||||
echo $(( 100 * $bn / $bf ))
|
||||
}
|
||||
|
||||
freebsd_get_bat ()
|
||||
{
|
||||
echo "$(sysctl -n hw.acpi.battery.life)"
|
||||
|
||||
}
|
||||
|
||||
# Do with grep and awk unless too hard
|
||||
|
||||
# TODO Identify which machine we're on from teh script.
|
||||
|
||||
battery_status()
|
||||
{
|
||||
case $(uname -s) in
|
||||
"Linux")
|
||||
BATPATH=/sys/class/power_supply/BAT0
|
||||
if [ ! -d $BATPATH ]; then
|
||||
BATPATH=/sys/class/power_supply/BAT1
|
||||
fi
|
||||
STATUS=$BATPATH/status
|
||||
BAT_FULL=$BATPATH/charge_full
|
||||
if [ ! -r $BAT_FULL ]; then
|
||||
BAT_FULL=$BATPATH/energy_full
|
||||
fi
|
||||
BAT_NOW=$BATPATH/charge_now
|
||||
if [ ! -r $BAT_NOW ]; then
|
||||
BAT_NOW=$BATPATH/energy_now
|
||||
fi
|
||||
|
||||
if [ "$1" = `cat $STATUS` -o "$1" = "" ]; then
|
||||
linux_get_bat
|
||||
fi
|
||||
;;
|
||||
"FreeBSD")
|
||||
STATUS=`sysctl -n hw.acpi.battery.state`
|
||||
case $1 in
|
||||
"Discharging")
|
||||
if [ $STATUS -eq 1 ]; then
|
||||
freebsd_get_bat
|
||||
fi
|
||||
;;
|
||||
"Charging")
|
||||
if [ $STATUS -eq 2 ]; then
|
||||
freebsd_get_bat
|
||||
fi
|
||||
;;
|
||||
"")
|
||||
freebsd_get_bat
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
"Darwin")
|
||||
case $1 in
|
||||
"Discharging")
|
||||
ext="No";;
|
||||
"Charging")
|
||||
ext="Yes";;
|
||||
esac
|
||||
|
||||
ioreg -c AppleSmartBattery -w0 | \
|
||||
grep -o '"[^"]*" = [^ ]*' | \
|
||||
sed -e 's/= //g' -e 's/"//g' | \
|
||||
sort | \
|
||||
while read key value; do
|
||||
case $key in
|
||||
"MaxCapacity")
|
||||
export maxcap=$value;;
|
||||
"CurrentCapacity")
|
||||
export curcap=$value;;
|
||||
"ExternalConnected")
|
||||
if [ "$ext" != "$value" ]; then
|
||||
exit
|
||||
fi
|
||||
;;
|
||||
"FullyCharged")
|
||||
if [ "$value" = "Yes" ]; then
|
||||
exit
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [[ -n "$maxcap" && -n $curcap ]]; then
|
||||
echo $(( 100 * $curcap / $maxcap ))
|
||||
break
|
||||
fi
|
||||
done
|
||||
esac
|
||||
}
|
||||
|
||||
BATTERY_STATUS=`battery_status $1`
|
||||
[ -z "$BATTERY_STATUS" ] && exit
|
||||
|
||||
if [ -n "$CUTE_BATTERY_INDICATOR" ]; then
|
||||
echo `cutinate $BATTERY_STATUS`
|
||||
else
|
||||
echo "${HEART_FULL} ${BATTERY_STATUS}%"
|
||||
#echo "⛁ ${BATTERY_STATUS}%"
|
||||
fi
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Prints the CPU usage: user% sys% idle.
|
||||
|
||||
if [ "$PLATFORM" == "linux" ] ; then
|
||||
cpu_line=$(top -b -n 1 | grep "Cpu(s)" )
|
||||
cpu_user=$(echo "$cpu_line" | grep -Po "(\d+(.\d+)?)(?=%?\s?(us(er)?))")
|
||||
cpu_system=$(echo "$cpu_line" | grep -Po "(\d+(.\d+)?)(?=%?\s?(sys?))")
|
||||
cpu_idle=$(echo "$cpu_line" | grep -Po "(\d+(.\d+)?)(?=%?\s?(id(le)?))")
|
||||
else
|
||||
cpus_line=$(top -e -l 1 | grep "CPU usage:" | sed 's/CPU usage: //')
|
||||
cpu_user=$(echo "$cpus_line" | awk '{print $1}' | sed 's/%//' )
|
||||
cpu_system=$(echo "$cpus_line" | awk '{print $3}'| sed 's/%//' )
|
||||
cpu_idle=$(echo "$cpus_line" | awk '{print $5}' | sed 's/%//' )
|
||||
fi
|
||||
|
||||
if [ -n "$cpu_user" ] && [ -n "$cpu_system" ] && [ -n "$cpu_idle" ]; then
|
||||
echo "${cpu_user}, ${cpu_system}, ${cpu_idle}" | awk -F', ' '{printf("%5.1f,%5.1f,%5.1f",$1,$2,$3)}'
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Prints the name of the current day.
|
||||
date +"%a"
|
||||
|
||||
exit 0
|
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Print the current date in ISO 8601 format.
|
||||
#date +"%F"
|
||||
date +"%b %d"
|
||||
|
||||
exit 0
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Prints the hostname
|
||||
hostname -s
|
||||
|
||||
exit 0
|
@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prints the local network IP address for a staticly defined NIC or search for an IP address on all active NICs.
|
||||
|
||||
# TODO fix the mac part so it also can search for interfaces like the Linux one can.
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
nic0="en0"
|
||||
nic1="en1"
|
||||
|
||||
# Get wired lan IP.
|
||||
lan_ip=$(/sbin/ifconfig $nic0 2>/dev/null | grep 'inet ' | awk '{print $2}')
|
||||
# If no wired lan, get wireless lan IP.
|
||||
if [ -z "$lan_ip" ]; then
|
||||
lan_ip=$(/sbin/ifconfig $nic1 2>/dev/null | grep 'inet ' | awk '{print $2}')
|
||||
fi
|
||||
else
|
||||
# Get the names of all attached NICs.
|
||||
all_nics=$(ip addr show | cut -d ' ' -f2 | tr -d :)
|
||||
all_nics=(${all_nics[@]//lo/}) # Remove lo interface.
|
||||
|
||||
for nic in ${all_nics[@]}; do
|
||||
# Parse IP address for the NIC.
|
||||
lan_ip=$(ip addr show ${nic} | grep '\<inet\>' | tr -s ' ' | cut -d ' ' -f3)
|
||||
# Trim the CIDR suffix.
|
||||
lan_ip=${lan_ip%/*}
|
||||
|
||||
[ -n "$lan_ip" ] && break
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$lan_ip" ]; then
|
||||
echo "ⓛ ${lan_ip}"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Print the average load.
|
||||
uptime | cut -d "," -f 3- | cut -d ":" -f2
|
||||
|
||||
exit 0
|
@ -1,78 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Return the number of new mails in your Gmail(or Gmail App email) inbox
|
||||
# Supports plain text password or OS X keychain.
|
||||
# You really shouldn't store your password in clear text. Use the Mac OS X keychain,
|
||||
# or some other encrypted password management solution that can be accessed from the terminal.
|
||||
# You may enter your password below, but you do so at your own peril!
|
||||
# Also, for optimum security, don't use your account password. Enable 2-step verification
|
||||
# on your Google account, and set up an application-specific password for this script,
|
||||
# then store that in your keychain.
|
||||
# See http://support.google.com/accounts/bin/answer.py?hl=en&answer=185833 for more info.
|
||||
#
|
||||
# For OSX users : MAKE SURE that you add a key to the keychain in the format as follows
|
||||
# Keychain Item name : http://<value-you-fill-in-server-variable-below>
|
||||
# Account name : <username-below>@<server-below>
|
||||
# Password : Your password ( Once again, try to use 2 step-verification and application-specific password)
|
||||
|
||||
username="" # Enter your Gmail username here WITH OUT @gmail.com.( OR @domain )
|
||||
password="" # Leave this empty to get password from keychain.
|
||||
server="gmail.com" # Domain name that will complete your email. For normal GMail users it probably is "gmail.com but can be "foo.tld" for Google Apps users.
|
||||
interval=5 # Query interval in minutes .
|
||||
tmp_file="/tmp/tmux-powerline_gmail_count.txt" # File to store mail count in.
|
||||
override=false # When true a force reloaded will be done.
|
||||
|
||||
# Get password from OS X keychain.
|
||||
mac_keychain_get_pass() {
|
||||
result=$(security 2>&1 > /dev/null find-internet-password -ga $1 -s $2)
|
||||
if [ $? -eq 0 ]; then
|
||||
password=$(echo $result | sed -e 's/password: \"\(.*\)\"/\1/g') #<<< $result)
|
||||
# unset $result
|
||||
return 0
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create the cache file if it doesn't exist.
|
||||
if [ ! -f $tmp_file ]; then
|
||||
touch $tmp_file
|
||||
override=true
|
||||
fi
|
||||
|
||||
# Refresh mail count if the tempfile is older than $interval minutes.
|
||||
let interval=60*$interval
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
last_update=$(stat -f "%m" ${tmp_file})
|
||||
else
|
||||
last_update=$(stat -c "%Y" ${tmp_file})
|
||||
fi
|
||||
if [ "$(( $(date +"%s") - ${last_update} ))" -gt "$interval" ] || [ "$override" == true ]; then
|
||||
if [ -z "$password" ]; then # Get password from keychain if it isn't already set.
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
mac_keychain_get_pass "${username}@${server}" $server
|
||||
else
|
||||
echo "Implement your own sexy password fetching mechanism here."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for wget before proceeding.
|
||||
which wget 2>&1 > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "This script requires wget." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mail=$(wget -q -O - https://mail.google.com/a/${server}/feed/atom --http-user="${username}@${server}" --http-password="${password}" --no-check-certificate | grep fullcount | sed 's/<[^0-9]*>//g')
|
||||
|
||||
if [ "$mail" != "" ]; then
|
||||
echo $mail > $tmp_file
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
let interval=$interval*60
|
||||
# echo "$(( $(date +"%s") - $(stat -f %m $tmp_file) ))"
|
||||
mailcount=$(cat $tmp_file)
|
||||
echo "✉ $mailcount"
|
||||
exit 0;
|
@ -1,27 +0,0 @@
|
||||
#/usr/bin/env bash
|
||||
# Print the current working directory (trimmed to max length).
|
||||
# NOTE The trimming code's stolen from the web. Courtesy to who ever wrote it.
|
||||
|
||||
pwdmaxlen=40 # Max output length.
|
||||
|
||||
segment_cwd=$(dirname $0)
|
||||
source "$segment_cwd/../lib.sh"
|
||||
|
||||
# Truncate from the right.
|
||||
#echo $(get_tmux_cwd | sed -e "s|${HOME}|~|" -e 's/^~$/~\//' -e 's/\(.\{40\}\).*$/\1.../')
|
||||
|
||||
# Truncate from the left.
|
||||
tcwd=$(get_tmux_cwd)
|
||||
trunc_symbol=".."
|
||||
dir=${tcwd##*/}
|
||||
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
|
||||
ttcwd=${tcwd/#$HOME/\~}
|
||||
pwdoffset=$(( ${#ttcwd} - pwdmaxlen ))
|
||||
if [ ${pwdoffset} -gt "0" ]; then
|
||||
ttcwd=${ttcwd:$pwdoffset:$pwdmaxlen}
|
||||
ttcwd=${trunc_symbol}/${ttcwd#*/}
|
||||
fi
|
||||
|
||||
echo "$ttcwd"
|
||||
|
||||
exit 0
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Prints the current time.
|
||||
date +"%H:%M "
|
||||
|
||||
exit 0
|
@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Prints tmux session info.
|
||||
# Assuems that [ -n "$TMUX"].
|
||||
tmux display-message -p '#S:#I.#P'
|
||||
|
||||
exit 0
|
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# Prints the uptime.
|
||||
uptime | grep -PZo "(?<=up )[^,]*"
|
@ -1,98 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prints current branch in a VCS directory if it could be detected.
|
||||
|
||||
# Source lib to get the function get_tmux_pwd
|
||||
segment_path=$(dirname $0)
|
||||
source "$segment_path/../lib.sh"
|
||||
|
||||
tmux_path=$(get_tmux_cwd)
|
||||
cd "$tmux_path"
|
||||
|
||||
branch_symbol="⋔"
|
||||
git_colour="colour5"
|
||||
git_svn_colour="colour34"
|
||||
svn_colour="colour220"
|
||||
hg_colour="colour45"
|
||||
|
||||
# Show git banch.
|
||||
parse_git_branch() {
|
||||
type git >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
#git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
|
||||
|
||||
# Quit if this is not a Git repo.
|
||||
branch=$(git symbolic-ref HEAD 2> /dev/null)
|
||||
if [[ -z $branch ]] ; then
|
||||
# attempt to get short-sha-name
|
||||
branch=":$(git rev-parse --short HEAD 2> /dev/null)"
|
||||
fi
|
||||
if [ "$?" -ne 0 ]; then
|
||||
# this must not be a git repo
|
||||
return
|
||||
fi
|
||||
|
||||
# clean off unnecessary information
|
||||
branch=${branch##*/}
|
||||
|
||||
echo "$(git branch --no-color 2>/dev/null)" | grep "remotes/git-svn" &>/dev/null
|
||||
is_gitsvn=$([ "$?" -eq 0 ] && echo 1 || echo 0)
|
||||
|
||||
echo -n "#[fg="
|
||||
if [ "$is_gitsvn" -eq "0" ]; then
|
||||
echo -n "$git_colour"
|
||||
else
|
||||
echo -n "$git_svn_colour"
|
||||
fi
|
||||
# TODO pass colour arguments as paramters/globals to segments?
|
||||
echo "]${branch_symbol} #[fg=colour42]${branch}"
|
||||
}
|
||||
|
||||
# Show SVN branch.
|
||||
parse_svn_branch() {
|
||||
type svn >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -d ".svn/" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
local svn_root=$(svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p')
|
||||
local svn_url=$(svn info 2>/dev/null | sed -ne 's#^URL: ##p')
|
||||
|
||||
local branch=$(echo $svn_url | sed -e 's#^'"${svn_root}"'##g' | egrep -o '(tags|branches)/[^/]+|trunk' | egrep -o '[^/]+$' | awk '{print $1}')
|
||||
echo "#[fg=${svn_colour}]${branch_symbol} #[fg=colour42]${branch}"
|
||||
}
|
||||
|
||||
parse_hg_branch() {
|
||||
type hg >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
summary=$(hg summary)
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local branch=$(echo "$summary" | grep 'branch:' | cut -d ' ' -f2)
|
||||
echo "#[fg=${hg_colour}]${branch_symbol} #[fg=colour42]${branch}"
|
||||
}
|
||||
|
||||
branch=""
|
||||
if [ -n "${git_branch=$(parse_git_branch)}" ]; then
|
||||
branch="$git_branch"
|
||||
elif [ -n "${svn_branch=$(parse_svn_branch)}" ]; then
|
||||
branch="$svn_branch"
|
||||
elif [ -n "${hg_branch=$(parse_hg_branch)}" ]; then
|
||||
branch="$hg_branch"
|
||||
fi
|
||||
|
||||
if [ -n "$branch" ]; then
|
||||
echo "${branch}"
|
||||
fi
|
@ -1,86 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This checks if the current branch is ahead of
|
||||
# or behind the remote branch with which it is tracked
|
||||
|
||||
# Source lib to get the function get_tmux_pwd
|
||||
segment_path=$(dirname $0)
|
||||
source "$segment_path/../lib.sh"
|
||||
|
||||
tmux_path=$(get_tmux_cwd)
|
||||
cd "$tmux_path"
|
||||
|
||||
flat_symbol="⤚"
|
||||
git_colour="colour5"
|
||||
git_svn_colour="colour34"
|
||||
svn_colour="colour220"
|
||||
hg_colour="colour45"
|
||||
|
||||
parse_git_stats(){
|
||||
type git >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# check if git
|
||||
[[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return
|
||||
|
||||
refs=$(git symbolic-ref HEAD 2> /dev/null)
|
||||
branch=${refs##*/}
|
||||
if [[ -z $branch ]] ; then
|
||||
branch=$(git rev-parse --short HEAD)
|
||||
fi
|
||||
|
||||
# look up this branch in the configuration
|
||||
remote=$(git config branch.$branch.remote)
|
||||
remote_ref=$(git config branch.$branch.merge)
|
||||
|
||||
# if this branch is not connected to a remote
|
||||
[[ -z $remote ]] && return
|
||||
|
||||
# convert the remote ref into the tracking ref... this is a hack
|
||||
remote_branch=$(expr $remote_ref : 'refs/heads/\(.*\)')
|
||||
tracking_branch=refs/remotes/$remote/$remote_branch
|
||||
|
||||
# make a list of behind/ahead left/right sha's
|
||||
tmpLR=/tmp/$(basename $0).left-right
|
||||
git rev-list --left-right $tracking_branch...HEAD &> $tmpLR
|
||||
|
||||
numAhead=$(grep ">" $tmpLR | wc -l)
|
||||
numBehind=$(grep "<" $tmpLR | wc -l)
|
||||
|
||||
# print out the information
|
||||
if [[ $numBehind -gt 0 ]] ; then
|
||||
local ret="↓ $numBehind"
|
||||
fi
|
||||
if [[ $numAhead -gt 0 ]] ; then
|
||||
local ret="${ret}↑ $numAhead"
|
||||
fi
|
||||
echo $ret
|
||||
}
|
||||
parse_hg_stats(){
|
||||
type svn >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
parse_svn_stats(){
|
||||
type hg >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
|
||||
stats=""
|
||||
if [ -n "${git_stats=$(parse_git_stats)}" ]; then
|
||||
stats="$git_stats"
|
||||
elif [ -n "${svn_stats=$(parse_svn_stats)}" ]; then
|
||||
stats="$svn_stats"
|
||||
elif [ -n "${hg_stats=$(parse_hg_stats)}" ]; then
|
||||
stats="$hg_stats"
|
||||
fi
|
||||
|
||||
if [ -n "$stats" ]; then
|
||||
echo "${stats}"
|
||||
fi
|
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This checks if the current branch is ahead of
|
||||
# or behind the remote branch with which it is tracked
|
||||
|
||||
# Source lib to get the function get_tmux_pwd
|
||||
segment_path=$(dirname $0)
|
||||
source "$segment_path/../lib.sh"
|
||||
|
||||
tmux_path=$(get_tmux_cwd)
|
||||
cd "$tmux_path"
|
||||
|
||||
mod_symbol="﹢"
|
||||
git_colour="colour5"
|
||||
git_svn_colour="colour34"
|
||||
svn_colour="colour220"
|
||||
hg_colour="colour45"
|
||||
|
||||
parse_git_stats(){
|
||||
type git >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# check if git
|
||||
[[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return
|
||||
|
||||
# return the number of staged items
|
||||
staged=$(git ls-files --modified | wc -l)
|
||||
echo $staged
|
||||
}
|
||||
parse_hg_stats(){
|
||||
type svn >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
parse_svn_stats(){
|
||||
type hg >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
|
||||
stats=""
|
||||
if [ -n "${git_stats=$(parse_git_stats)}" ]; then
|
||||
stats="$git_stats"
|
||||
elif [ -n "${svn_stats=$(parse_svn_stats)}" ]; then
|
||||
stats="$svn_stats"
|
||||
elif [ -n "${hg_stats=$(parse_hg_stats)}" ]; then
|
||||
stats="$hg_stats"
|
||||
fi
|
||||
if [[ -n "$stats" && $stats -gt 0 ]]; then
|
||||
echo "${mod_symbol}${stats}"
|
||||
fi
|
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This checks if the current branch is ahead of
|
||||
# or behind the remote branch with which it is tracked
|
||||
|
||||
# Source lib to get the function get_tmux_pwd
|
||||
segment_path=$(dirname $0)
|
||||
source "$segment_path/../lib.sh"
|
||||
|
||||
tmux_path=$(get_tmux_cwd)
|
||||
cd "$tmux_path"
|
||||
|
||||
other_symbol="⋯ "
|
||||
git_colour="colour5"
|
||||
git_svn_colour="colour34"
|
||||
svn_colour="colour220"
|
||||
hg_colour="colour45"
|
||||
|
||||
parse_git_stats(){
|
||||
type git >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# check if git
|
||||
[[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return
|
||||
|
||||
# return the number of staged items
|
||||
other=$(git ls-files --others --exclude-standard | wc -l)
|
||||
echo $other
|
||||
}
|
||||
parse_hg_stats(){
|
||||
type svn >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
parse_svn_stats(){
|
||||
type hg >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
|
||||
stats=""
|
||||
if [ -n "${git_stats=$(parse_git_stats)}" ]; then
|
||||
stats="$git_stats"
|
||||
elif [ -n "${svn_stats=$(parse_svn_stats)}" ]; then
|
||||
stats="$svn_stats"
|
||||
elif [ -n "${hg_stats=$(parse_hg_stats)}" ]; then
|
||||
stats="$hg_stats"
|
||||
fi
|
||||
if [[ -n "$stats" && $stats -gt 0 ]]; then
|
||||
echo "${other_symbol}${stats}"
|
||||
fi
|
@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This checks if the current branch is ahead of
|
||||
# or behind the remote branch with which it is tracked
|
||||
|
||||
# Source lib to get the function get_tmux_pwd
|
||||
segment_path=$(dirname $0)
|
||||
source "$segment_path/../lib.sh"
|
||||
|
||||
tmux_path=$(get_tmux_cwd)
|
||||
cd "$tmux_path"
|
||||
|
||||
staged_symbol="⊕ "
|
||||
git_colour="colour5"
|
||||
git_svn_colour="colour34"
|
||||
svn_colour="colour220"
|
||||
hg_colour="colour45"
|
||||
|
||||
parse_git_stats(){
|
||||
type git >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# check if git
|
||||
[[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return
|
||||
|
||||
# return the number of staged items
|
||||
staged=$(git diff --staged --name-status | wc -l)
|
||||
echo $staged
|
||||
}
|
||||
parse_hg_stats(){
|
||||
type svn >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
parse_svn_stats(){
|
||||
type hg >/dev/null 2>&1
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
# not yet implemented
|
||||
}
|
||||
|
||||
stats=""
|
||||
if [ -n "${git_stats=$(parse_git_stats)}" ]; then
|
||||
stats="$git_stats"
|
||||
elif [ -n "${svn_stats=$(parse_svn_stats)}" ]; then
|
||||
stats="$svn_stats"
|
||||
elif [ -n "${hg_stats=$(parse_hg_stats)}" ]; then
|
||||
stats="$hg_stats"
|
||||
fi
|
||||
if [[ -n "$stats" && $stats -gt 0 ]]; then
|
||||
echo "${staged_symbol}${stats}"
|
||||
fi
|
@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Prints the WAN IP address. The result is cached and updated according to $update_period.
|
||||
|
||||
# Cache file.
|
||||
tmp_file="${tp_tmpdir}/wan_ip.txt"
|
||||
|
||||
wan_ip=""
|
||||
if [ -f "$tmp_file" ]; then
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
last_update=$(stat -f "%m" ${tmp_file})
|
||||
else
|
||||
last_update=$(stat -c "%Y" ${tmp_file})
|
||||
fi
|
||||
time_now=$(date +%s)
|
||||
update_period=900
|
||||
|
||||
up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc)
|
||||
if [ "$up_to_date" -eq 1 ]; then
|
||||
wan_ip=$(cat ${tmp_file})
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$wan_ip" ]; then
|
||||
#wan_ip=$(wget --timeout=1 --tries=1 -O - http://formyip.com/ 2>/dev/null | grep -Pzo "(?<=Your IP is )[^<]*")
|
||||
wan_ip=$(curl --max-time 2 -s http://whatismyip.akamai.com/)
|
||||
if [ "$?" -eq "0" ]; then
|
||||
echo "${wan_ip}" > $tmp_file
|
||||
elif [ -f "${tmp_file}" ]; then
|
||||
wan_ip=$(cat "$tmp_file")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$wan_ip" ]; then
|
||||
#echo "Ⓦ ${wan_ip}"
|
||||
echo "ⓦ ${wan_ip}"
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,129 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Prints the current weather in Celsius, Fahrenheits or lord Kelvins. The forecast is cached and updated with a period of $update_period.
|
||||
# NOTE this has stoppned working, sadly.
|
||||
|
||||
# You location. Find a string that works for you by Googling on "weather in <location-string>"
|
||||
location="Seattle, WA"
|
||||
|
||||
# Can be any of {c,f,k}.
|
||||
unit="f"
|
||||
|
||||
# Update time in seconds.
|
||||
update_period=600
|
||||
|
||||
# Cach file.
|
||||
tmp_file="${tp_tmpdir}/weather_google.txt"
|
||||
|
||||
get_condition_symbol() {
|
||||
local conditions=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
||||
case "$conditions" in
|
||||
sunny | "partly sunny" | "mostly sunny")
|
||||
hour=$(date +%H)
|
||||
if [ "$hour" -ge "22" -o "$hour" -le "5" ]; then
|
||||
#echo "☽"
|
||||
echo "☾"
|
||||
else
|
||||
#echo "☀"
|
||||
echo "☼"
|
||||
fi
|
||||
;;
|
||||
"rain and snow" | "chance of rain" | "light rain" | rain | "heavy rain" | "freezing drizzle" | flurries | showers | "scattered showers" | drizzle | "rain showers")
|
||||
#echo "☂"
|
||||
echo "☔"
|
||||
;;
|
||||
snow | "light snow" | "scattered snow showers" | icy | ice/snow | "chance of snow" | "snow showers" | sleet)
|
||||
#echo "☃"
|
||||
echo "❅"
|
||||
;;
|
||||
"partly cloudy" | "mostly cloudy" | cloudy | overcast)
|
||||
echo "☁"
|
||||
;;
|
||||
"chance of storm" | thunderstorm | "chance of tstorm" | storm | "scattered thunderstorms")
|
||||
#echo "⚡"
|
||||
echo "☈"
|
||||
;;
|
||||
dust | fog | smoke | haze | mist)
|
||||
echo "♨"
|
||||
;;
|
||||
windy)
|
||||
echo "⚑"
|
||||
#echo "⚐"
|
||||
;;
|
||||
clear)
|
||||
#echo "☐"
|
||||
echo "✈" # So clear you can see the aeroplanes! TODO what symbol does best represent a clear sky?
|
||||
;;
|
||||
*)
|
||||
echo "?"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
read_tmp_file() {
|
||||
if [ ! -f "$tmp_file" ]; then
|
||||
return
|
||||
fi
|
||||
IFS_bak="$IFS"
|
||||
IFS=$'\n'
|
||||
lines=($(cat ${tmp_file}))
|
||||
IFS="$IFS_bak"
|
||||
degrees="${lines[0]}"
|
||||
conditions="${lines[1]}"
|
||||
}
|
||||
|
||||
degrees=""
|
||||
if [ -f "$tmp_file" ]; then
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
last_update=$(stat -f "%m" ${tmp_file})
|
||||
else
|
||||
last_update=$(stat -c "%Y" ${tmp_file})
|
||||
fi
|
||||
time_now=$(date +%s)
|
||||
|
||||
up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc)
|
||||
if [ "$up_to_date" -eq 1 ]; then
|
||||
read_tmp_file
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$degrees" ]; then
|
||||
if [ "$unit" == "k" ]; then
|
||||
search_unit="c"
|
||||
else
|
||||
search_unit="$unit"
|
||||
fi
|
||||
# Convert spaces before using this in the URL.
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
search_location=$(echo "$location" | sed -e 's/[ ]/%20/g')
|
||||
else
|
||||
search_location=$(echo "$location" | sed -e 's/\s/%20/g')
|
||||
fi
|
||||
|
||||
weather_data=$(curl --max-time 4 -s "http://www.google.com/ig/api?weather=${search_location}")
|
||||
if [ "$?" -eq "0" ]; then
|
||||
error=$(echo "$weather_data" | grep "problem_cause\|DOCTYPE");
|
||||
if [ -n "$error" ]; then
|
||||
echo "error"
|
||||
exit 1
|
||||
fi
|
||||
degrees=$(echo "$weather_data" | sed "s|.*<temp_${search_unit} data=\"\([^\"]*\)\"/>.*|\1|")
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
conditions=$(echo $weather_data | xpath //current_conditions/condition/@data 2> /dev/null | grep -oe '".*"' | sed "s/\"//g")
|
||||
else
|
||||
conditions=$(echo "$weather_data" | grep -PZo "<current_conditions>(\\n|.)*</current_conditions>" | grep -PZo "(?<=<condition\sdata=\")([^\"]*)")
|
||||
fi
|
||||
echo "$degrees" > $tmp_file
|
||||
echo "$conditions" >> $tmp_file
|
||||
elif [ -f "$tmp_file" ]; then
|
||||
read_tmp_file
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$degrees" ]; then
|
||||
if [ "$unit" == "k" ]; then
|
||||
degrees=$(echo "${degrees} + 273.15" | bc)
|
||||
fi
|
||||
unit_upper=$(echo "$unit" | tr '[cfk]' '[CFK]')
|
||||
condition_symbol=$(get_condition_symbol "$conditions")
|
||||
echo "${condition_symbol} ${degrees}°${unit_upper}"
|
||||
fi
|
@ -1,122 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prints the current weather in Celsius, Fahrenheits or lord Kelvins. The forecast is cached and updated with a period of $update_period.
|
||||
|
||||
# You location. Find a code that works for you:
|
||||
# 1. Go to Yahoo weather http://weather.yahoo.com/
|
||||
# 2. Find the weather for you location
|
||||
# 3. Copy the last numbers in that URL. e.g. "http://weather.yahoo.com/united-states/california/newport-beach-12796587/" has the number "12796587"
|
||||
location="12798958"
|
||||
|
||||
# Can be any of {c,f,k}.
|
||||
unit="f"
|
||||
|
||||
# The update period in seconds.
|
||||
update_period=600
|
||||
|
||||
# Cache file.
|
||||
tmp_file="${tp_tmpdir}/weather_yahoo.txt"
|
||||
|
||||
# Get symbol for condition. Available conditions: http://developer.yahoo.com/weather/#codes
|
||||
get_condition_symbol() {
|
||||
local condition=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
||||
case "$condition" in
|
||||
"sunny" | "hot")
|
||||
hour=$(date +%H)
|
||||
if [ "$hour" -ge "22" -o "$hour" -le "5" ]; then
|
||||
#echo "☽"
|
||||
echo "☾"
|
||||
else
|
||||
#echo "☀"
|
||||
echo "☼"
|
||||
fi
|
||||
;;
|
||||
"rain" | "mixed rain and snow" | "mixed rain and sleet" | "freezing drizzle" | "drizzle" | "freezing rain" | "showers" | "mixed rain and hail" | "scattered showers" | "isolated thundershowers" | "thundershowers")
|
||||
#echo "☂"
|
||||
echo "☔"
|
||||
;;
|
||||
"snow" | "mixed snow and sleet" | "snow flurries" | "light snow showers" | "blowing snow" | "sleet" | "hail" | "heavy snow" | "scattered snow showers" | "snow showers")
|
||||
#echo "☃"
|
||||
echo "❅"
|
||||
;;
|
||||
"cloudy" | "mostly cloudy" | "partly cloudy")
|
||||
echo "☁"
|
||||
;;
|
||||
"tornado" | "tropical storm" | "hurricane" | "severe thunderstorms" | "thunderstorms" | "isolated thunderstorms" | "scattered thunderstorms")
|
||||
#echo "⚡"
|
||||
echo "☈"
|
||||
;;
|
||||
"dust" | "foggy" | "haze" | "smoky" | "blustery" | "mist")
|
||||
#echo "♨"
|
||||
#echo "﹌"
|
||||
echo "〰"
|
||||
;;
|
||||
"windy")
|
||||
#echo "⚐"
|
||||
echo "⚑"
|
||||
;;
|
||||
"clear" | "fair" | "cold")
|
||||
#echo "✈" # So clear you can see the aeroplanes!
|
||||
echo "〇"
|
||||
;;
|
||||
*)
|
||||
echo "?"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
read_tmp_file() {
|
||||
if [ ! -f "$tmp_file" ]; then
|
||||
return
|
||||
fi
|
||||
IFS_bak="$IFS"
|
||||
IFS=$'\n'
|
||||
lines=($(cat ${tmp_file}))
|
||||
IFS="$IFS_bak"
|
||||
degree="${lines[0]}"
|
||||
condition="${lines[1]}"
|
||||
}
|
||||
|
||||
degree=""
|
||||
if [ -f "$tmp_file" ]; then
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
last_update=$(stat -f "%m" ${tmp_file})
|
||||
else
|
||||
last_update=$(stat -c "%Y" ${tmp_file})
|
||||
fi
|
||||
time_now=$(date +%s)
|
||||
|
||||
up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc)
|
||||
if [ "$up_to_date" -eq 1 ]; then
|
||||
read_tmp_file
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$degree" ]; then
|
||||
weather_data=$(curl --max-time 4 -s "http://weather.yahooapis.com/forecastrss?w=${location}&u=${unit}")
|
||||
if [ "$?" -eq "0" ]; then
|
||||
error=$(echo "$weather_data" | grep "problem_cause\|DOCTYPE");
|
||||
if [ -n "$error" ]; then
|
||||
echo "error"
|
||||
exit 1
|
||||
fi
|
||||
# <yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
|
||||
unit=$(echo "$weather_data" | grep -PZo "<yweather:units [^<>]*/>" | sed 's/.*temperature="\([^"]*\)".*/\1/')
|
||||
condition=$(echo "$weather_data" | grep -PZo "<yweather:condition [^<>]*/>")
|
||||
# <yweather:condition text="Clear" code="31" temp="66" date="Mon, 01 Oct 2012 8:00 pm CST" />
|
||||
degree=$(echo "$condition" | sed 's/.*temp="\([^"]*\)".*/\1/')
|
||||
condition=$(echo "$condition" | sed 's/.*text="\([^"]*\)".*/\1/')
|
||||
echo "$degree" > $tmp_file
|
||||
echo "$condition" >> $tmp_file
|
||||
elif [ -f "$tmp_file" ]; then
|
||||
read_tmp_file
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$degree" ]; then
|
||||
if [ "$unit" == "k" ]; then
|
||||
degree=$(echo "${degree} + 273.15" | bc)
|
||||
fi
|
||||
unit_upper=$(echo "$unit" | tr '[cfk]' '[CFK]')
|
||||
condition_symbol=$(get_condition_symbol "$condition")
|
||||
echo "${condition_symbol} ${degree}°${unit_upper}"
|
||||
fi
|
@ -1,64 +0,0 @@
|
||||
/* xkb_layout
|
||||
* Description:
|
||||
* This program will connect to the X Server and print the id of the currently
|
||||
* active keyboard layout.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DO_DEBUG DEBUG
|
||||
#else
|
||||
#define DO_DEBUG 0
|
||||
#endif
|
||||
#define DEBUG_PRINTF(...) do{ if (DO_DEBUG) { printf(__VA_ARGS__);} } while(0)
|
||||
|
||||
int main() {
|
||||
// Get X display
|
||||
char *displayName = "";
|
||||
int eventCode;
|
||||
int errorReturn;
|
||||
int major = XkbMajorVersion;
|
||||
int minor = XkbMinorVersion;;
|
||||
int reasonReturn;
|
||||
Display *_display = XkbOpenDisplay(displayName, &eventCode, &errorReturn,
|
||||
&major, &minor, &reasonReturn);
|
||||
bool error = false;
|
||||
switch (reasonReturn) {
|
||||
case XkbOD_BadLibraryVersion:
|
||||
DEBUG_PRINTF("Bad XKB library version.\n");
|
||||
error = true;
|
||||
break;
|
||||
case XkbOD_ConnectionRefused:
|
||||
DEBUG_PRINTF("Connection to X server refused.\n");
|
||||
error = true;
|
||||
break;
|
||||
case XkbOD_BadServerVersion:
|
||||
DEBUG_PRINTF("Bad X11 server version.\n");
|
||||
error = true;
|
||||
break;
|
||||
case XkbOD_NonXkbServer:
|
||||
DEBUG_PRINTF("XKB not present.\n");
|
||||
error = true;
|
||||
break;
|
||||
case XkbOD_Success:
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Get current state of keyboard.
|
||||
int _deviceId = XkbUseCoreKbd;
|
||||
XkbStateRec xkbState;
|
||||
XkbGetState(_display, _deviceId, &xkbState);
|
||||
// print the groupnumber, may be used with setxkbmap -query to get name
|
||||
// of current layout
|
||||
printf("%d\n", xkbState.group);
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Print the currently used keyboard layout
|
||||
# This depends on a specifically developed program which prints the group id of
|
||||
# the currently used layout.
|
||||
# I developed the simple program myself with some guidance as I was unable to
|
||||
# find anything already developed.
|
||||
# Some people might suggest:
|
||||
# $ setxkbmod -query -v | awk -F "+" '{print $2}'
|
||||
# this will only work if you have set up XKB with a single layout which is true
|
||||
# for some.
|
||||
|
||||
# This script will print the correct layout even if layout is set per window.
|
||||
# Exit if platform is not linux as this script is dependant on X11
|
||||
if [ $PLATFORM != "linux" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd "$(dirname $0)"
|
||||
if [ ! -x "xkb_layout" ]; then
|
||||
make clean xkb_layout &>/dev/null
|
||||
fi
|
||||
|
||||
if [ -x ./xkb_layout ]; then
|
||||
cur_layout_nbr=$(($(./xkb_layout)+1));
|
||||
cur_layout=$(setxkbmap -query | grep layout | sed 's/layout:\s\+//g' | \
|
||||
awk -F ',' '{print $'$(echo "$cur_layout_nbr")'}')
|
||||
echo "⌨ $cur_layout"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1,88 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#Print the status-left for tmux.
|
||||
#
|
||||
# The powerline root directory.
|
||||
cwd=$(dirname $0)
|
||||
|
||||
# Source global configurations.
|
||||
source "${cwd}/config.sh"
|
||||
|
||||
# Source lib functions.
|
||||
source "${cwd}/lib.sh"
|
||||
|
||||
segments_path="${cwd}/${segments_dir}"
|
||||
|
||||
# Mute this statusbar?
|
||||
mute_status_check "left"
|
||||
|
||||
# Segments
|
||||
|
||||
declare -A tmux_session_info
|
||||
tmux_session_info+=(["script"]="${segments_path}/tmux_session_info.sh")
|
||||
tmux_session_info+=(["foreground"]="colour234")
|
||||
tmux_session_info+=(["background"]="colour148")
|
||||
tmux_session_info+=(["separator"]="${separator_right_bold}")
|
||||
#tmux_session_info+=(["separator_fg"]="default")
|
||||
#register_segment "tmux_session_info"
|
||||
|
||||
declare -A hostname
|
||||
hostname+=(["script"]="${segments_path}/hostname.sh")
|
||||
hostname+=(["foreground"]="colour0")
|
||||
hostname+=(["background"]="colour33")
|
||||
hostname+=(["separator"]="${separator_right_bold}")
|
||||
#register_segment "hostname"
|
||||
|
||||
declare -A lan_ip
|
||||
lan_ip+=(["script"]="${segments_path}/lan_ip.sh")
|
||||
lan_ip+=(["foreground"]="colour255")
|
||||
lan_ip+=(["background"]="colour24")
|
||||
lan_ip+=(["separator"]="${separator_right_bold}")
|
||||
register_segment "lan_ip"
|
||||
|
||||
declare -A wan_ip
|
||||
wan_ip+=(["script"]="${segments_path}/wan_ip.sh")
|
||||
wan_ip+=(["foreground"]="colour255")
|
||||
wan_ip+=(["background"]="colour24")
|
||||
wan_ip+=(["separator"]="${separator_right_thin}")
|
||||
wan_ip+=(["separator_fg"]="white")
|
||||
register_segment "wan_ip"
|
||||
|
||||
declare -A vcs_branch
|
||||
vcs_branch+=(["script"]="${segments_path}/vcs_branch.sh")
|
||||
vcs_branch+=(["foreground"]="colour88")
|
||||
vcs_branch+=(["background"]="colour29")
|
||||
vcs_branch+=(["separator"]="${separator_right_bold}")
|
||||
register_segment "vcs_branch"
|
||||
|
||||
declare -A vcs_compare
|
||||
vcs_compare+=(["script"]="${segments_path}/vcs_compare.sh")
|
||||
vcs_compare+=(["foreground"]="white")
|
||||
vcs_compare+=(["background"]="colour60")
|
||||
vcs_compare+=(["separator"]="${separator_right_bold}")
|
||||
register_segment "vcs_compare"
|
||||
|
||||
declare -A vcs_staged
|
||||
vcs_staged+=(["script"]="${segments_path}/vcs_staged.sh")
|
||||
vcs_staged+=(["foreground"]="white")
|
||||
vcs_staged+=(["background"]="colour64")
|
||||
vcs_staged+=(["separator"]="${separator_right_bold}")
|
||||
register_segment "vcs_staged"
|
||||
|
||||
declare -A vcs_modified
|
||||
vcs_modified+=(["script"]="${segments_path}/vcs_modified.sh")
|
||||
vcs_modified+=(["foreground"]="white")
|
||||
vcs_modified+=(["background"]="red")
|
||||
vcs_modified+=(["separator"]="${separator_right_bold}")
|
||||
register_segment "vcs_modified"
|
||||
|
||||
declare -A vcs_others
|
||||
vcs_others+=(["script"]="${segments_path}/vcs_others.sh")
|
||||
vcs_others+=(["foreground"]="black")
|
||||
vcs_others+=(["background"]="colour245")
|
||||
vcs_others+=(["separator"]="${separator_right_bold}")
|
||||
register_segment "vcs_others"
|
||||
|
||||
# Print the status line in the order of registration above.
|
||||
print_status_line_left
|
||||
|
||||
exit 0
|
@ -1,132 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
# The powerline root directory.
|
||||
cwd=$(dirname $0)
|
||||
|
||||
# Source global configurations.
|
||||
source "${cwd}/config.sh"
|
||||
|
||||
# Source lib functions.
|
||||
source "${cwd}/lib.sh"
|
||||
|
||||
segments_path="${cwd}/${segments_dir}"
|
||||
|
||||
# Mute this statusbar?
|
||||
mute_status_check "right"
|
||||
|
||||
# Segment
|
||||
# Comment/uncomment the register function call to enable or disable a segment.
|
||||
|
||||
declare -A pwd
|
||||
pwd+=(["script"]="${segments_path}/pwd.sh")
|
||||
pwd+=(["foreground"]="colour211")
|
||||
pwd+=(["background"]="colour89")
|
||||
pwd+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "pwd"
|
||||
|
||||
declare -A mail_count
|
||||
mail_count+=(["script"]="${segments_path}/mail_count_maildir.sh")
|
||||
#mail_count+=(["script"]="${segments_path}/mail_count_gmail.sh")
|
||||
#mail_count+=(["script"]="${segments_path}/mail_count_apple_mail.sh")
|
||||
mail_count+=(["foreground"]="white")
|
||||
mail_count+=(["background"]="red")
|
||||
mail_count+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "mail_count"
|
||||
|
||||
declare -A now_playing
|
||||
if [ "$PLATFORM" == "linux" ]; then
|
||||
now_playing+=(["script"]="${segments_path}/np_mpd.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_mpd_simple.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_mocp.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_spotify_linux_wine.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_spotify_linux_native.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_rhythmbox.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_banshee.sh")
|
||||
#now_playing+=(["script"]="${segments_path}/np_audacious.sh")
|
||||
elif [ "$PLATFORM" == "mac" ]; then
|
||||
now_playing+=(["script"]="${segments_path}/np_itunes_mac.sh")
|
||||
fi
|
||||
if [[ ${now_playing["script"]} ]]; then
|
||||
now_playing+=(["foreground"]="colour37")
|
||||
now_playing+=(["background"]="colour234")
|
||||
now_playing+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "now_playing"
|
||||
fi
|
||||
|
||||
declare -A uptime
|
||||
uptime+=(["script"]="${segments_path}/uptime.sh")
|
||||
uptime+=(["foreground"]="colour136")
|
||||
uptime+=(["background"]="colour240")
|
||||
#uptime+=(["separator"]="${separator_left_bold}")
|
||||
register_segment "uptime"
|
||||
|
||||
declare -A cpu
|
||||
cpu+=(["script"]="${segments_path}/cpu.sh")
|
||||
cpu+=(["foreground"]="colour136")
|
||||
cpu+=(["background"]="colour240")
|
||||
cpu+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "cpu"
|
||||
|
||||
declare -A load
|
||||
load+=(["script"]="${segments_path}/load.sh")
|
||||
load+=(["foreground"]="colour167")
|
||||
load+=(["background"]="colour237")
|
||||
load+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "load"
|
||||
|
||||
declare -A battery
|
||||
if [ "$PLATFORM" == "mac" ]; then
|
||||
battery+=(["script"]="${segments_path}/battery_mac.sh")
|
||||
else
|
||||
battery+=(["script"]="${segments_path}/battery.sh")
|
||||
fi
|
||||
battery+=(["foreground"]="colour127")
|
||||
battery+=(["background"]="colour137")
|
||||
battery+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "battery"
|
||||
|
||||
declare -A weather
|
||||
weather+=(["script"]="${segments_path}/weather_yahoo.sh")
|
||||
#weather+=(["script"]="${segments_path}/weather_google.sh")
|
||||
weather+=(["foreground"]="colour255")
|
||||
weather+=(["background"]="colour37")
|
||||
weather+=(["separator"]="${separator_left_bold}")
|
||||
register_segment "weather"
|
||||
|
||||
declare -A xkb_layout
|
||||
if [ "$PLATFORM" == "linux" ]; then
|
||||
xkb_layout+=(["script"]="${segments_path}/xkb_layout.sh")
|
||||
xkb_layout+=(["foreground"]="colour117")
|
||||
xkb_layout+=(["background"]="colour125")
|
||||
xkb_layout+=(["separator"]="${separator_left_bold}")
|
||||
fi
|
||||
#register_segment "xkb_layout"
|
||||
|
||||
declare -A date_day
|
||||
date_day+=(["script"]="${segments_path}/date_day.sh")
|
||||
date_day+=(["foreground"]="colour136")
|
||||
date_day+=(["background"]="colour235")
|
||||
date_day+=(["separator"]="${separator_left_bold}")
|
||||
#register_segment "date_day"
|
||||
|
||||
declare -A date_full
|
||||
date_full+=(["script"]="${segments_path}/date_full.sh")
|
||||
date_full+=(["foreground"]="colour136")
|
||||
date_full+=(["background"]="colour235")
|
||||
date_full+=(["separator"]="${separator_left_bold}")
|
||||
#date_full+=(["separator_fg"]="default")
|
||||
register_segment "date_full"
|
||||
|
||||
declare -A time
|
||||
time+=(["script"]="${segments_path}/time.sh")
|
||||
time+=(["foreground"]="colour136")
|
||||
time+=(["background"]="colour235")
|
||||
time+=(["separator"]="${separator_left_thin}")
|
||||
time+=(["separator_fg"]="default")
|
||||
register_segment "time"
|
||||
|
||||
# Print the status line in the order of registration above.
|
||||
print_status_line_right
|
||||
|
||||
exit 0
|
35
install.sh
35
install.sh
@ -1,27 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Initialize any submodules
|
||||
git submodule init
|
||||
git submodule update
|
||||
# Make sure git is installed. Exit if it isn't
|
||||
if which git; then
|
||||
echo "Please install git before continuing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
OS="$(lsb_release -si)"
|
||||
REPO_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
# Helper function to remove old file and link the new one
|
||||
# Remove a file if it exists then create a symlink to the one contained in ${REPO_DIR}
|
||||
function linkFile() {
|
||||
if [ -f $1 ]; then
|
||||
rm $1;
|
||||
elif [ -d $1 ]; then
|
||||
rm -rf $1
|
||||
fi
|
||||
ln -s $DIR/$1 $1;
|
||||
if [ -e $1 ]; then rm -rf $1; fi
|
||||
ln -s ${REPO_DIR}/$1 $1;
|
||||
}
|
||||
|
||||
# Create a directory named by first parameter. Delete directory first if it already exists.
|
||||
function createDirectory() {
|
||||
if [ -d $1 ]; then
|
||||
rm -rf $1
|
||||
fi
|
||||
|
||||
if [ -d $1 ]; then rm -rf $1; fi
|
||||
mkdir $1
|
||||
}
|
||||
|
||||
@ -33,6 +28,13 @@ case "$choice" in
|
||||
Y|y|yes )
|
||||
echo "Moving to Home directory...";
|
||||
cd ~;
|
||||
|
||||
echo "Adding id_rsa.pub to authorized keys if necessary"
|
||||
if [ ! -e ".ssh/authorized_keys" ] ; then
|
||||
cp ${REPO_DIR}/.ssh/id_rsa.pub .ssh/authorized_keys
|
||||
elif ! grep -q `cat ${REPO_DIR}/.ssh/id_rsa.pub` ".ssh/authorized_keys"; then
|
||||
cat ${REPO_DIR}/.ssh/id_rsa.pub >> .ssh/authorized_keys
|
||||
fi
|
||||
|
||||
echo "Linking shell configs...";
|
||||
linkFile .bashrc
|
||||
@ -48,7 +50,6 @@ case "$choice" in
|
||||
|
||||
echo "Linking tmux...";
|
||||
linkFile .tmux.conf
|
||||
linkFile .tmux-powerline
|
||||
|
||||
echo "Linking inputrc..."
|
||||
linkFile .inputrc
|
||||
|
Loading…
Reference in New Issue
Block a user