-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-sx-fish.fish
More file actions
80 lines (68 loc) · 2.54 KB
/
setup-sx-fish.fish
File metadata and controls
80 lines (68 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env fish
# SX Setup Script for Fish Shell - Creates fish functions for SX commands
set -l RED '\033[0;31m'
set -l GREEN '\033[0;32m'
set -l YELLOW '\033[1;33m'
set -l BLUE '\033[0;34m'
set -l NC '\033[0m' # No Color
echo -e "$YELLOW"'SX Setup - Creating Fish Functions'"$NC"
echo -e "$YELLOW"'================================='"$NC"
echo ""
# Check if sx tool is installed
if not test -e ~/.dotnet/tools/sx
echo -e "$RED"'❌ SX tool not found. Please install it first:'"$NC"
echo ' dotnet tool install -g SX.Client'
echo ""
echo -e "$BLUE"'Or install from local build:'"$NC"
echo ' dotnet tool install --global --add-source ./packages SX.Client'
exit 1
end
echo -e "$GREEN"'✅ SX tool found'"$NC"
echo ""
# Create fish functions directory
set -l FISH_FUNCTIONS_DIR "$HOME/.config/fish/functions"
mkdir -p "$FISH_FUNCTIONS_DIR"
echo -e "$BLUE"'Creating fish functions in '"$FISH_FUNCTIONS_DIR"'...'"$NC"
# Create sxd function
echo 'function sxd --description "SX Download - Get file from server"
~/.dotnet/tools/sx sxd $argv
end' > "$FISH_FUNCTIONS_DIR/sxd.fish"
# Create sxu function
echo 'function sxu --description "SX Upload - Send file to server"
~/.dotnet/tools/sx sxu $argv
end' > "$FISH_FUNCTIONS_DIR/sxu.fish"
# Create sxls function
echo 'function sxls --description "SX List - List files on server"
~/.dotnet/tools/sx sxls $argv
end' > "$FISH_FUNCTIONS_DIR/sxls.fish"
echo -e "$GREEN"'✅ Fish functions created:'"$NC"
echo " $FISH_FUNCTIONS_DIR/sxd.fish"
echo " $FISH_FUNCTIONS_DIR/sxu.fish"
echo " $FISH_FUNCTIONS_DIR/sxls.fish"
echo ""
# Test the functions
echo -e "$BLUE"'Testing installation...'"$NC"
if fish -c 'sxd --help' >/dev/null 2>&1
echo -e "$GREEN"'✅ SX functions working'"$NC"
else
echo -e "$RED"'❌ SX function test failed'"$NC"
exit 1
end
echo ""
echo -e "$GREEN"'🎉 Fish setup completed successfully!'"$NC"
echo ""
echo -e "$YELLOW"'Next steps:'"$NC"
echo '1. Functions are ready to use!'
echo '2. Start SX server locally: sx-server --dir ~/Downloads'
echo '3. Reconnect this SSH session with tunnel: ssh -R 53690:localhost:53690 user@server'
echo '4. Use commands: sxd, sxu, sxls'
echo ""
echo -e "$BLUE"'Example usage:'"$NC"
echo ' sxls # List files'
echo ' sxd largefile.zip # Download file'
echo ' sxu myfile.txt # Upload file'
echo ""
echo -e "$BLUE"'Fish-specific features:'"$NC"
echo ' - Tab completion for function names'
echo ' - Built-in help: help sxd, help sxu, help sxls'
echo ' - Functions available in all new fish sessions'