From 616b70ba670b0e43a4411267f3ac99431f866354 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Fri, 9 Oct 2015 17:28:05 -0400 Subject: Add spacemacs download to setup.sh. --- bin/setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/setup.sh b/bin/setup.sh index c054646..441b8e8 100755 --- a/bin/setup.sh +++ b/bin/setup.sh @@ -87,3 +87,7 @@ if [[ "$success" == "1" ]]; then else printf "${red}[WARNING]${none} failed to install vim plugins\n" fi + +if which emacs >/dev/null && [[ ! -d .emacs.d ]]; then + git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d +fi -- cgit v1.2.3 From 96d184c8426d20696ae5b90d00dcca59275e1359 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Fri, 9 Oct 2015 17:28:24 -0400 Subject: Add additional languages to spacemacs. --- spacemacs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spacemacs b/spacemacs index 4a2efb1..85223e5 100644 --- a/spacemacs +++ b/spacemacs @@ -26,6 +26,12 @@ values." ;; auto-completion ;; better-defaults emacs-lisp + shell + c-c++ + haskell + html + javascript + markdown ;; git ;; markdown ;; org @@ -94,7 +100,7 @@ values." :size 20 :weight normal :width normal - :powerline-scale 1.0) + :powerline-scale 1.1) ;; The leader key dotspacemacs-leader-key "SPC" ;; The leader key accessible in `emacs state' and `insert state' @@ -193,6 +199,14 @@ values." "Initialization function for user code. It is called immediately after `dotspacemacs/init'. You are free to put any user code." + ;; bind ctrl-w to backwards-kill-word when no region is selected + (global-set-key (kbd "C-w") 'backward-kill-word-or-kill-region) + + (defun backward-kill-word-or-kill-region (&optional arg) + (interactive "p") + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (backward-kill-word arg))) ) (defun dotspacemacs/user-config () @@ -200,6 +214,7 @@ user code." This function is called at the very end of Spacemacs initialization after layers configuration. You are free to put any user code." (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) + (setq-default vc-follow-symlinks nil) ) ;; Do not write anything past this comment. This is where Emacs will -- cgit v1.2.3 From 996a49a1598c1d93581ea04a8645cb4fddf3a8a7 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 10 Oct 2015 15:50:53 -0400 Subject: Add missing 'exec'. --- i3/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3/config b/i3/config index 7400efa..e4fd4f2 100644 --- a/i3/config +++ b/i3/config @@ -163,7 +163,7 @@ bar { } exec xrdb -merge $HOME/.Xresources -setxkbmap us -variant dvorak -option compose:ralt -option caps:ctrl_modifier +exec setxkbmap us -variant dvorak -option compose:ralt -option caps:ctrl_modifier exec $HOME/bin/keyboard_setup.sh exec xbindkeys exec xset -b -- cgit v1.2.3 From 55e42679b93cb40fa01354a5feaeb1f1038b8782 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 10 Oct 2015 15:51:23 -0400 Subject: Spacemacs extra config. --- spacemacs | 17 ++++++++++------- zshrc | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spacemacs b/spacemacs index 85223e5..ff95c6f 100644 --- a/spacemacs +++ b/spacemacs @@ -28,18 +28,20 @@ values." emacs-lisp shell c-c++ + semantic haskell html javascript markdown - ;; git + haskell + git ;; markdown ;; org ;; (shell :variables ;; shell-default-height 30 ;; shell-default-position 'bottom) ;; spell-checking - ;; syntax-checking + syntax-checking ;; version-control ) ;; List of additional packages that will be installed without being @@ -48,7 +50,7 @@ values." ;; configuration in `dotspacemacs/config'. dotspacemacs-additional-packages '(haskell-mode) ;; A list of packages and/or extensions that will not be install and loaded. - dotspacemacs-excluded-packages '() + dotspacemacs-excluded-packages '(smartparens) ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that ;; are declared in a layer which is not a member of ;; the list `dotspacemacs-configuration-layers'. (default t) @@ -84,8 +86,7 @@ values." ;; List of themes, the first of the list is loaded when spacemacs starts. ;; Press T n to cycle to the next theme in the list (works great ;; with 2 themes variants, one dark and one light) - dotspacemacs-themes '(base16-tomorrow-dark - spacemacs-dark + dotspacemacs-themes '(spacemacs-dark spacemacs-light solarized-light solarized-dark @@ -141,7 +142,7 @@ values." dotspacemacs-enable-paste-micro-state nil ;; Which-key delay in seconds. The which-key buffer is the popup listing ;; the commands bound to the current keystroke sequence. (default 0.4) - dotspacemacs-which-key-delay 0.4 + dotspacemacs-which-key-delay 0.2 ;; Which-key frame position. Possible values are `right', `bottom' and ;; `right-then-bottom'. right-then-bottom tries to display the frame to the ;; right; if there is insufficient space it displays it at the bottom. @@ -214,7 +215,9 @@ user code." This function is called at the very end of Spacemacs initialization after layers configuration. You are free to put any user code." (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) - (setq-default vc-follow-symlinks nil) + (setq-default + vc-follow-symlinks nil + web-mode-code-indent-offset 2) ) ;; Do not write anything past this comment. This is where Emacs will diff --git a/zshrc b/zshrc index 4856cd2..e936d78 100755 --- a/zshrc +++ b/zshrc @@ -52,7 +52,7 @@ setopt DVORAK # alias ls="ls --color" if which gvim >/dev/null; then alias vi="gvim --remote" - alias e="gvim --remote" + alias e="emacsclient -n" fi alias ff="fileutil --gfs_user=gfp-reporting" alias diff=colordiff -- cgit v1.2.3 From 0eb5cc3deb96e657b581e495bf6c53b421c16ca1 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 10 Oct 2015 19:07:10 -0400 Subject: Script to set brightness with a scaling factor. --- bin/brightness.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 bin/brightness.sh diff --git a/bin/brightness.sh b/bin/brightness.sh new file mode 100755 index 0000000..5a1939e --- /dev/null +++ b/bin/brightness.sh @@ -0,0 +1,25 @@ +#!/bin/bash +readonly XBACKLIGHT=xbacklight +readonly levels=(0 1 2 3 4 6 10 15 20 25 30 40 50 60 70 80 90 100) + +current_level=$($XBACKLIGHT) +current_level=$((${current_level%.*})) + +if (( "$current_level" < 8 )); then + diff=1 +elif (( "$current_level" < 24 )); then + diff=6 +elif (( "$current_level" < 50 )); then + diff=12 +else + diff=24 +fi + +if [[ $1 == "+" ]]; then + $XBACKLIGHT -inc $diff +elif [[ $1 == "-" ]]; then + $XBACKLIGHT -dec $diff +else + echo "Usage: $0 +|-" + exit 1 +fi -- cgit v1.2.3 From b3ecc3b33f6bfd4b8e7cc49e6bb2873dc1d36de1 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 10 Oct 2015 19:09:58 -0400 Subject: Add spacemacs nyan-mode. --- spacemacs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spacemacs b/spacemacs index ff95c6f..3223e41 100644 --- a/spacemacs +++ b/spacemacs @@ -35,8 +35,8 @@ values." markdown haskell git - ;; markdown - ;; org + markdown + org ;; (shell :variables ;; shell-default-height 30 ;; shell-default-position 'bottom) @@ -48,7 +48,7 @@ values." ;; wrapped in a layer. If you need some configuration for these ;; packages then consider to create a layer, you can also put the ;; configuration in `dotspacemacs/config'. - dotspacemacs-additional-packages '(haskell-mode) + dotspacemacs-additional-packages '(nyan-mode) ;; A list of packages and/or extensions that will not be install and loaded. dotspacemacs-excluded-packages '(smartparens) ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that @@ -86,7 +86,8 @@ values." ;; List of themes, the first of the list is loaded when spacemacs starts. ;; Press T n to cycle to the next theme in the list (works great ;; with 2 themes variants, one dark and one light) - dotspacemacs-themes '(spacemacs-dark + dotspacemacs-themes '(base16-bright-dark + spacemacs-dark spacemacs-light solarized-light solarized-dark @@ -218,7 +219,7 @@ layers configuration. You are free to put any user code." (setq-default vc-follow-symlinks nil web-mode-code-indent-offset 2) + (nyan-mode) ) - ;; Do not write anything past this comment. This is where Emacs will ;; auto-generate custom variable definitions. -- cgit v1.2.3 From 689f50ab64e08154c7ece0b86dc4393e7616b40d Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 10 Oct 2015 19:10:11 -0400 Subject: Use brightness script in xbindkeys. --- xbindkeysrc-pincer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbindkeysrc-pincer b/xbindkeysrc-pincer index b1eccf0..569df58 100644 --- a/xbindkeysrc-pincer +++ b/xbindkeysrc-pincer @@ -1,7 +1,7 @@ -"xbacklight -inc 10 && pkill -SIGUSR1 i3status" +"/home/orbekk/bin/brightness.sh + && pkill -SIGUSR1 i3status" XF86MonBrightnessUp -"xbacklight -dec 10 && pkill -SIGUSR1 i3status" +"/home/orbekk/bin/brightness.sh - && pkill -SIGUSR1 i3status" XF86MonBrightnessDown "amixer -c 1 set Master 1dB- && pkill -SIGUSR1 i3status" -- cgit v1.2.3 From b48ff88a8b6ee94fd70e88127800fdbe29858805 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 10:57:22 -0400 Subject: Tweak brightness increments. --- bin/brightness.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bin/brightness.sh b/bin/brightness.sh index 5a1939e..7a2107d 100755 --- a/bin/brightness.sh +++ b/bin/brightness.sh @@ -1,6 +1,5 @@ #!/bin/bash readonly XBACKLIGHT=xbacklight -readonly levels=(0 1 2 3 4 6 10 15 20 25 30 40 50 60 70 80 90 100) current_level=$($XBACKLIGHT) current_level=$((${current_level%.*})) @@ -9,10 +8,8 @@ if (( "$current_level" < 8 )); then diff=1 elif (( "$current_level" < 24 )); then diff=6 -elif (( "$current_level" < 50 )); then - diff=12 else - diff=24 + diff=10 fi if [[ $1 == "+" ]]; then -- cgit v1.2.3 From 0f8273c5fb9c090b0a53715f2965f032885540c3 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 10:58:04 -0400 Subject: Add i3blocks config. --- bin/setup.sh | 1 + i3/config | 2 +- i3blocks.conf | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ xbindkeysrc-pincer | 14 +++---- 4 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 i3blocks.conf diff --git a/bin/setup.sh b/bin/setup.sh index 441b8e8..e3b7c4f 100755 --- a/bin/setup.sh +++ b/bin/setup.sh @@ -68,6 +68,7 @@ if which i3 >/dev/null; then mkdir -p .i3 create_symlink ../dotfiles/i3/config .i3/config create_symlink dotfiles/i3status.conf .i3status.conf + create_symlink dotfiles/i3blocks.conf .i3blocks.conf else printf "${orange}[SKIPPED]${none} i3 not installed.\n" fi diff --git a/i3/config b/i3/config index e4fd4f2..ed8f6d7 100644 --- a/i3/config +++ b/i3/config @@ -158,7 +158,7 @@ mode "resize" { # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { - status_command i3status + status_command i3blocks font xft:Droid Sans Mono 8 } diff --git a/i3blocks.conf b/i3blocks.conf new file mode 100644 index 0000000..62df263 --- /dev/null +++ b/i3blocks.conf @@ -0,0 +1,106 @@ +# i3blocks config file +# Global properties +# +# The top properties below are applied to every block, but can be overridden. +# Each block command defaults to the script name to avoid boilerplate. +command=/usr/lib/i3blocks/$BLOCK_NAME +separator_block_width=15 +markup=none + +# Volume indicator +# +# The first parameter sets the step (and units to display) +# The second parameter overrides the mixer selection +# See the script for details. +[volume] +label=♪ +instance=Master +#instance=PCM +interval=once +signal=10 + +[brightness] +label=☼ +command=xbacklight | awk -F. '{print $1}' +interval=once +signal=10 + +[disk] +label=/ +instance=/ +interval=30 + +# Network interface monitoring +# +# If the instance is not specified, use the interface used for default route. +# The address can be forced to IPv4 or IPv6 with -4 or -6 switches. +[iface] +#instance=wlan0 +color=#00FF00 +interval=10 +separator=false + +[wifi] +#instance=wlp3s0 +interval=10 +separator=false + +[ipv6] +label= +command=ip -6 a show scope global | grep -q global && echo -e "ipv6\nipv6\n#A8FF00" || echo -e "ipv4\nipv4\n#cc0000" +interval=10 + +[bandwidth] +#instance=eth0 +interval=5 + +[load_average] +interval=10 + +# Battery indicator +# +# The battery instance defaults to 0. +[battery] +label=bat +#label=⚡ +#instance=1 +interval=30 +separator=false + +[power] +label= +command=zsh -c '[[ $(cat /sys/class/power_supply/BAT0/status) == "Discharging" ]] && printf "%.2f W" $(( $(cat /sys/class/power_supply/BAT0/power_now) / 1000000.0 )) || echo ""' +color=77bb33 +interval=30 +signal=10 + +# Date Time +# +[time] +command=date '+%Y-%m-%d %H:%M' +interval=60 + +# Temperature +# +# Support multiple chips, though lm-sensors. +# The script may be called with -w and -c switches to specify thresholds, +# see the script for details. +[temperature] +label= +interval=10 + +# Key indicators +# +# Add the following bindings to i3 config file: +# +# bindsym --release Caps_Lock exec pkill -SIGRTMIN+11 i3blocks +# bindsym --release Num_Lock exec pkill -SIGRTMIN+11 i3blocks +#[keyindicator] +#instance=CAPS +#interval=once +#signal=11 + +#[keyindicator] +#instance=NUM +#interval=once +#signal=11 diff --git a/xbindkeysrc-pincer b/xbindkeysrc-pincer index 569df58..a72b809 100644 --- a/xbindkeysrc-pincer +++ b/xbindkeysrc-pincer @@ -1,20 +1,20 @@ -"/home/orbekk/bin/brightness.sh + && pkill -SIGUSR1 i3status" +"/home/orbekk/bin/brightness.sh + && pkill -RTMIN+10 i3blocks" XF86MonBrightnessUp -"/home/orbekk/bin/brightness.sh - && pkill -SIGUSR1 i3status" +"/home/orbekk/bin/brightness.sh - && pkill -RTMIN+10 i3blocks" XF86MonBrightnessDown -"amixer -c 1 set Master 1dB- && pkill -SIGUSR1 i3status" +"amixer -c 1 set Master 1dB- && pkill -RTMIN+10 i3blocks" XF86AudioLowerVolume -"amixer -c 1 set Master 1dB+ && pkill -SIGUSR1 i3status" +"amixer -c 1 set Master 1dB+ && pkill -RTMIN+10 i3blocks" XF86AudioRaiseVolume -"amixer -c 1 set Master toggle && pkill -SIGUSR1 i3status" +"amixer -c 1 set Master toggle && pkill -RTMIN+10 i3blocks" XF86AudioMute -"amixer -c 1 set Mic toggle && pkill -SIGUSR1 i3status" +"amixer -c 1 set Mic toggle && pkill -RTMIN+10 i3blocks" XF86AudioMicMute -"i3lock -c 2A3462 && pkill -SIGUSR1 i3status" +"i3lock -c 2A3462" XF86Tools -- cgit v1.2.3 From 2e8ec4e34b7c509c242c448b4702a5c912f7dc02 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 11:09:05 -0400 Subject: Increase i3block intervals. --- i3blocks.conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/i3blocks.conf b/i3blocks.conf index 62df263..847bb7b 100644 --- a/i3blocks.conf +++ b/i3blocks.conf @@ -28,7 +28,7 @@ signal=10 [disk] label=/ instance=/ -interval=30 +interval=300 # Network interface monitoring # @@ -37,25 +37,25 @@ interval=30 [iface] #instance=wlan0 color=#00FF00 -interval=10 +interval=20 separator=false [wifi] #instance=wlp3s0 -interval=10 +interval=20 separator=false [ipv6] label= command=ip -6 a show scope global | grep -q global && echo -e "ipv6\nipv6\n#A8FF00" || echo -e "ipv4\nipv4\n#cc0000" -interval=10 +interval=20 [bandwidth] #instance=eth0 -interval=5 +interval=30 [load_average] -interval=10 +interval=20 # Battery indicator # @@ -87,7 +87,7 @@ interval=60 # see the script for details. [temperature] label= -interval=10 +interval=60 # Key indicators # -- cgit v1.2.3 From 05e4a67576fb8a302da293b54bded555879fcd08 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 11:28:22 -0400 Subject: Update colors. --- i3blocks.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/i3blocks.conf b/i3blocks.conf index 847bb7b..1d2668e 100644 --- a/i3blocks.conf +++ b/i3blocks.conf @@ -35,13 +35,13 @@ interval=300 # If the instance is not specified, use the interface used for default route. # The address can be forced to IPv4 or IPv6 with -4 or -6 switches. [iface] -#instance=wlan0 -color=#00FF00 +label= interval=20 separator=false [wifi] -#instance=wlp3s0 +instance=wlp4s0 +label=W: interval=20 separator=false @@ -61,8 +61,8 @@ interval=20 # # The battery instance defaults to 0. [battery] -label=bat -#label=⚡ +#label=bat +label=⚡ #instance=1 interval=30 separator=false -- cgit v1.2.3 From c6597eae480d1645a89e4ba44ea8f0435f0e0dff Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 11:50:01 -0400 Subject: Remove annoying "select parent" from i3config. --- i3/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3/config b/i3/config index ed8f6d7..9e49a23 100644 --- a/i3/config +++ b/i3/config @@ -72,7 +72,7 @@ bindsym Mod4+Shift+space floating toggle bindsym Mod4+space focus mode_toggle # focus the parent container -bindsym Mod4+a focus parent +# bindsym Mod4+a focus parent # focus the child container #bindsym Mod4+d focus child -- cgit v1.2.3 From ac6b89c1724f4b872ab7de427d134b79171a9bee Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 11:50:34 -0400 Subject: Add kill signal for network blocks. --- i3blocks.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i3blocks.conf b/i3blocks.conf index 1d2668e..24b0d10 100644 --- a/i3blocks.conf +++ b/i3blocks.conf @@ -38,21 +38,25 @@ interval=300 label= interval=20 separator=false +signal=11 [wifi] instance=wlp4s0 label=W: interval=20 separator=false +signal=11 [ipv6] label= command=ip -6 a show scope global | grep -q global && echo -e "ipv6\nipv6\n#A8FF00" || echo -e "ipv4\nipv4\n#cc0000" interval=20 +signal=11 [bandwidth] #instance=eth0 interval=30 +signal=11 [load_average] interval=20 -- cgit v1.2.3 From 404e60caa500606d324a4021fb42321d118a5223 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 11 Oct 2015 11:57:25 -0400 Subject: Rename setup script. --- bin/kj-setup.sh | 94 ++++++++++++++++++++++++++++++++++++++++++ bin/kj-sync-keys.sh | 56 +++++++++++++++++++++++++ bin/kj_sync_authorized_keys.sh | 56 ------------------------- bin/setup.sh | 94 ------------------------------------------ 4 files changed, 150 insertions(+), 150 deletions(-) create mode 100755 bin/kj-setup.sh create mode 100755 bin/kj-sync-keys.sh delete mode 100755 bin/kj_sync_authorized_keys.sh delete mode 100755 bin/setup.sh diff --git a/bin/kj-setup.sh b/bin/kj-setup.sh new file mode 100755 index 0000000..5058bb5 --- /dev/null +++ b/bin/kj-setup.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +red='\e[0;31m' +orange='\e[0;33m' +green='\e[0;32m' +none='\e[0m' + +cd +# Check that things are in their right places. +if [[ ! -f dotfiles/bin/kj-setup.sh ]]; then + printf "${red}[FAIL]${none} expected to find myself\n" + exit 1 +fi + +required_commands=(git basename) +for command in ${required_commands[@]}; do + if ! which "${command}" >/dev/null; then + printf "${red}[FAIL]${none} ${command} not installed\n" + exit 1 + fi +done + +cd ~/dotfiles +git submodule update --init --recursive +git submodule foreach pull + +cd +# Creates a symlink with target $1 at location $2. +# Does nothing and prints an error message if $2 exists and is not a symlink. +create_symlink() { + if [[ -e "$2" && ! -h "$2" ]]; then + printf "${orange}[SKIPPED]${none} '$2' exists and is not a symlink.\n" + return + else + if ln -sf "$1" "$2"; then + printf "${green}[OK]${none} '$2' → '$1'\n" + else + printf "${red}[WARNING]${none} could not create '$2'\n" + fi + fi + if ! diff "$2" "$(dirname $2)/$1"; then + printf "${red}[WARNING]${none} diffs in $2\n" + fi +} + +create_symlink dotfiles/gitconfig .gitconfig +create_symlink dotfiles/taskrc .taskrc +create_symlink dotfiles/tmux.conf .tmux.conf +create_symlink dotfiles/spacemacs .spacemacs +create_symlink /dev/null .vimrc.local + +mkdir -p bin +for binary in dotfiles/bin/*; do + binary=$(basename "${binary}") + create_symlink "../dotfiles/bin/${binary}" "bin/${binary}" +done + +if [[ "${SHELL}" = *zsh* ]]; then + create_symlink dotfiles/zshrc .zshrc +else + printf "${orange}[SKIPPED]${none} shell is not zsh :-(.\n" +fi + +mkdir -p .ssh +create_symlink ../dotfiles/ssh/config .ssh/config + +if which i3 >/dev/null; then + mkdir -p .i3 + create_symlink ../dotfiles/i3/config .i3/config + create_symlink dotfiles/i3status.conf .i3status.conf + create_symlink dotfiles/i3blocks.conf .i3blocks.conf +else + printf "${orange}[SKIPPED]${none} i3 not installed.\n" +fi + +create_symlink dotfiles/vimrc .vimrc +if [[ -e .vim/bundle/Vundle.vim ]]; then + printf "${orange}[SKIPPED]${none} Vundle.vim already installed\n" +else + success=1 + mkdir -p .vim/bundle + git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim \ + || success=0 +fi +vim +PluginInstall +qall || success=0 +if [[ "$success" == "1" ]]; then + printf "${green}[OK]${none} installed vim plugins\n" +else + printf "${red}[WARNING]${none} failed to install vim plugins\n" +fi + +if which emacs >/dev/null && [[ ! -d .emacs.d ]]; then + git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d +fi diff --git a/bin/kj-sync-keys.sh b/bin/kj-sync-keys.sh new file mode 100755 index 0000000..b8be72d --- /dev/null +++ b/bin/kj-sync-keys.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# This script syncs authorized keys (found in the $authorized_keys_file below) +# to a list of remote hosts. It does not touch existing keys unless overwrite +# is set to true, but creates a special section containing the keys. + +declare -r begin_marker="### BEGIN MANAGED_BY_KJ_SYNC_AUTHORIZED_KEYS.SH ###" +declare -r end_marker="### END MANAGED_BY_KJ_SYNC_AUTHORIZED_KEYS.SH ###" +# If overwrite=true, the entire authorized_keys file is overwritten. +declare -r overwrite=false +declare -r tmpdir=$(mktemp -d /tmp/kj_sync_authorized_keys.XXXXX) + +targets=( + root@orbekk.osl.trygveandre.net + tesuji.6.orbekk.com + login.6.orbekk.com + minecraft.6.orbekk.com + login.pvv.ntnu.no + aji.orbekk.com + moyo.orbekk.com + pi@photobox.6.orbekk.com +) +authorized_keys_file=$HOME/dotfiles/authorized_keys +if [[ ! -f "${authorized_keys_file}" ]]; then + echo "could not find authorized_keys_file: ${authorized_keys_file}" + exit 1 +fi + +add_keys_to_file() { + local filename="$1" + awk \ + "/$begin_marker/"' { exit 0 } { print }' \ + ${filename} > ${filename}.header + awk \ + "/$end_marker/"' { should_output=1 } should_output { print }' \ + ${filename} > ${filename}.footer + + cat "${filename}.header" > ${filename} + echo "${begin_marker}" >> ${filename} + echo "# WARNING: ANY CHANGES WILL BE OVERWRITTEN" >> ${filename} + cat "$authorized_keys_file" >> ${filename} + echo "${end_marker}" >> ${filename} + cat "${filename}.footer" >> ${filename} +} + +for target in ${targets[@]}; do + echo "syncing $target" + tmp="${tmpdir}/${target}" + touch ${tmp} + if [[ $overwrite != true ]]; then + ssh ${target} 'cat .ssh/authorized_keys || echo -n' > ${tmp} + fi + add_keys_to_file "${tmp}" + ssh ${target} 'mkdir -p .ssh' + cat "${tmp}" | ssh ${target} 'cat > .ssh/authorized_keys.tmp && mv .ssh/authorized_keys{.tmp,}' +done diff --git a/bin/kj_sync_authorized_keys.sh b/bin/kj_sync_authorized_keys.sh deleted file mode 100755 index b8be72d..0000000 --- a/bin/kj_sync_authorized_keys.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# -# This script syncs authorized keys (found in the $authorized_keys_file below) -# to a list of remote hosts. It does not touch existing keys unless overwrite -# is set to true, but creates a special section containing the keys. - -declare -r begin_marker="### BEGIN MANAGED_BY_KJ_SYNC_AUTHORIZED_KEYS.SH ###" -declare -r end_marker="### END MANAGED_BY_KJ_SYNC_AUTHORIZED_KEYS.SH ###" -# If overwrite=true, the entire authorized_keys file is overwritten. -declare -r overwrite=false -declare -r tmpdir=$(mktemp -d /tmp/kj_sync_authorized_keys.XXXXX) - -targets=( - root@orbekk.osl.trygveandre.net - tesuji.6.orbekk.com - login.6.orbekk.com - minecraft.6.orbekk.com - login.pvv.ntnu.no - aji.orbekk.com - moyo.orbekk.com - pi@photobox.6.orbekk.com -) -authorized_keys_file=$HOME/dotfiles/authorized_keys -if [[ ! -f "${authorized_keys_file}" ]]; then - echo "could not find authorized_keys_file: ${authorized_keys_file}" - exit 1 -fi - -add_keys_to_file() { - local filename="$1" - awk \ - "/$begin_marker/"' { exit 0 } { print }' \ - ${filename} > ${filename}.header - awk \ - "/$end_marker/"' { should_output=1 } should_output { print }' \ - ${filename} > ${filename}.footer - - cat "${filename}.header" > ${filename} - echo "${begin_marker}" >> ${filename} - echo "# WARNING: ANY CHANGES WILL BE OVERWRITTEN" >> ${filename} - cat "$authorized_keys_file" >> ${filename} - echo "${end_marker}" >> ${filename} - cat "${filename}.footer" >> ${filename} -} - -for target in ${targets[@]}; do - echo "syncing $target" - tmp="${tmpdir}/${target}" - touch ${tmp} - if [[ $overwrite != true ]]; then - ssh ${target} 'cat .ssh/authorized_keys || echo -n' > ${tmp} - fi - add_keys_to_file "${tmp}" - ssh ${target} 'mkdir -p .ssh' - cat "${tmp}" | ssh ${target} 'cat > .ssh/authorized_keys.tmp && mv .ssh/authorized_keys{.tmp,}' -done diff --git a/bin/setup.sh b/bin/setup.sh deleted file mode 100755 index e3b7c4f..0000000 --- a/bin/setup.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -red='\e[0;31m' -orange='\e[0;33m' -green='\e[0;32m' -none='\e[0m' - -cd -# Check that things are in their right places. -if [[ ! -f dotfiles/bin/setup.sh ]]; then - printf "${red}[FAIL]${none} expected to find myself\n" - exit 1 -fi - -required_commands=(git basename) -for command in ${required_commands[@]}; do - if ! which "${command}" >/dev/null; then - printf "${red}[FAIL]${none} ${command} not installed\n" - exit 1 - fi -done - -cd ~/dotfiles -git submodule update --init --recursive -git submodule foreach pull - -cd -# Creates a symlink with target $1 at location $2. -# Does nothing and prints an error message if $2 exists and is not a symlink. -create_symlink() { - if [[ -e "$2" && ! -h "$2" ]]; then - printf "${orange}[SKIPPED]${none} '$2' exists and is not a symlink.\n" - return - else - if ln -sf "$1" "$2"; then - printf "${green}[OK]${none} '$2' → '$1'\n" - else - printf "${red}[WARNING]${none} could not create '$2'\n" - fi - fi - if ! diff "$2" "$(dirname $2)/$1"; then - printf "${red}[WARNING]${none} diffs in $2\n" - fi -} - -create_symlink dotfiles/gitconfig .gitconfig -create_symlink dotfiles/taskrc .taskrc -create_symlink dotfiles/tmux.conf .tmux.conf -create_symlink dotfiles/spacemacs .spacemacs -create_symlink /dev/null .vimrc.local - -mkdir -p bin -for binary in dotfiles/bin/*; do - binary=$(basename "${binary}") - create_symlink "../dotfiles/bin/${binary}" "bin/${binary}" -done - -if [[ "${SHELL}" = *zsh* ]]; then - create_symlink dotfiles/zshrc .zshrc -else - printf "${orange}[SKIPPED]${none} shell is not zsh :-(.\n" -fi - -mkdir -p .ssh -create_symlink ../dotfiles/ssh/config .ssh/config - -if which i3 >/dev/null; then - mkdir -p .i3 - create_symlink ../dotfiles/i3/config .i3/config - create_symlink dotfiles/i3status.conf .i3status.conf - create_symlink dotfiles/i3blocks.conf .i3blocks.conf -else - printf "${orange}[SKIPPED]${none} i3 not installed.\n" -fi - -create_symlink dotfiles/vimrc .vimrc -if [[ -e .vim/bundle/Vundle.vim ]]; then - printf "${orange}[SKIPPED]${none} Vundle.vim already installed\n" -else - success=1 - mkdir -p .vim/bundle - git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim \ - || success=0 -fi -vim +PluginInstall +qall || success=0 -if [[ "$success" == "1" ]]; then - printf "${green}[OK]${none} installed vim plugins\n" -else - printf "${red}[WARNING]${none} failed to install vim plugins\n" -fi - -if which emacs >/dev/null && [[ ! -d .emacs.d ]]; then - git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d -fi -- cgit v1.2.3