Split out fish functions and add the right ssh key
This commit is contained in:
parent
6781da5828
commit
c3bf84deb0
5 changed files with 23 additions and 22 deletions
|
@ -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
|
# Fish prompt
|
||||||
# Looks like: user@host in cwd(branch)
|
# Looks like: user@host in cwd(branch)
|
||||||
function fish_prompt
|
function fish_prompt
|
||||||
|
@ -50,7 +32,7 @@ function fish_prompt
|
||||||
set_color normal
|
set_color normal
|
||||||
set_color blue
|
set_color blue
|
||||||
|
|
||||||
echo -n (hostname)
|
echo -n (nice_hostname)
|
||||||
|
|
||||||
set_color normal
|
set_color normal
|
||||||
set_color -o black
|
set_color -o black
|
||||||
|
@ -73,7 +55,7 @@ function fish_prompt
|
||||||
# Git branch
|
# Git branch
|
||||||
#
|
#
|
||||||
|
|
||||||
set branch (__fish_prompt_git_branch)
|
set branch (git_branch)
|
||||||
if not test -z $branch
|
if not test -z $branch
|
||||||
echo -n "("
|
echo -n "("
|
||||||
|
|
||||||
|
|
15
fish/functions/git_branch.fish
Normal file
15
fish/functions/git_branch.fish
Normal 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
|
||||||
|
|
4
fish/functions/nice_hostname.fish
Normal file
4
fish/functions/nice_hostname.fish
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
function nice_hostname
|
||||||
|
hostname | cut -d . -f 1
|
||||||
|
end
|
||||||
|
|
|
@ -4,6 +4,6 @@ function start_agent
|
||||||
echo "succeeded"
|
echo "succeeded"
|
||||||
chmod 600 $SSH_ENV
|
chmod 600 $SSH_ENV
|
||||||
. $SSH_ENV > /dev/null
|
. $SSH_ENV > /dev/null
|
||||||
ssh-add
|
ssh-add "~/.ssh/id_(nice_hostname)"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function test_identities
|
function test_identities
|
||||||
ssh-add -l | grep "The agent has no identities" > /dev/null
|
ssh-add -l | grep "The agent has no identities" > /dev/null
|
||||||
if [ $status -eq 0 ]
|
if [ $status -eq 0 ]
|
||||||
ssh-add
|
ssh-add "~/.ssh/id_(nice_hostname)"
|
||||||
if [ $status -eq 2 ]
|
if [ $status -eq 2 ]
|
||||||
start_agent
|
start_agent
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue