Split out fish functions and add the right ssh key

This commit is contained in:
Max Bucknell 2015-05-02 20:25:23 +01:00
parent 6781da5828
commit c3bf84deb0
5 changed files with 23 additions and 22 deletions

View file

@ -1,21 +1,3 @@
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
function __fish_prompt_git_branch
set __git_branch (git current-branch ^ /dev/null)
if test -z $__git_branch
return
else if test $__git_branch = HEAD
set __rev (git log -1 --oneline ^ /dev/null)
if not test -z $__rev
echo -n (git log -1 --oneline | cut -d " " -f 1)
end
else
echo -n $__git_branch
end
end
####
# Fish prompt
# Looks like: user@host in cwd(branch)
function fish_prompt
@ -50,7 +32,7 @@ function fish_prompt
set_color normal
set_color blue
echo -n (hostname)
echo -n (nice_hostname)
set_color normal
set_color -o black
@ -73,7 +55,7 @@ function fish_prompt
# Git branch
#
set branch (__fish_prompt_git_branch)
set branch (git_branch)
if not test -z $branch
echo -n "("

View file

@ -0,0 +1,15 @@
function git_branch
set __git_branch (git current-branch ^ /dev/null)
if test -z $__git_branch
return
else if test $__git_branch = HEAD
set __rev (git log -1 --oneline ^ /dev/null)
if not test -z $__rev
echo -n (git log -1 --oneline | cut -d " " -f 1)
end
else
echo -n $__git_branch
end
end

View file

@ -0,0 +1,4 @@
function nice_hostname
hostname | cut -d . -f 1
end

View file

@ -4,6 +4,6 @@ function start_agent
echo "succeeded"
chmod 600 $SSH_ENV
. $SSH_ENV > /dev/null
ssh-add
ssh-add "~/.ssh/id_(nice_hostname)"
end

View file

@ -1,7 +1,7 @@
function test_identities
ssh-add -l | grep "The agent has no identities" > /dev/null
if [ $status -eq 0 ]
ssh-add
ssh-add "~/.ssh/id_(nice_hostname)"
if [ $status -eq 2 ]
start_agent
end